1
0
mirror of https://github.com/moodle/moodle.git synced 2025-04-25 10:26:17 +02:00

Merge branch 'MDL-74664-master' of https://github.com/call-learning/moodle

This commit is contained in:
Andrew Nicols 2023-03-30 11:27:09 +08:00
commit 43caf1bee7
8 changed files with 204 additions and 17 deletions

@ -119,7 +119,7 @@ class roles {
*/
public static function has_capability_in_course(int $courseid, string $capability) {
global $DB;
if (empty($courseid) || $DB->record_exists('course', ['id' => $courseid])) {
if (empty($courseid) || !$DB->record_exists('course', ['id' => $courseid])) {
return has_capability('moodle/site:config', \context_system::instance());
}

@ -18,6 +18,7 @@ namespace mod_bigbluebuttonbn\output;
use mod_bigbluebuttonbn\instance;
use mod_bigbluebuttonbn\local\bigbluebutton\recordings\recording_data;
use mod_bigbluebuttonbn\local\config;
use mod_bigbluebuttonbn\local\helpers\roles;
use mod_bigbluebuttonbn\recording;
use renderable;
@ -106,25 +107,21 @@ class recording_row_playback implements renderable, templatable {
if (array_key_exists('restricted', $playback) && strtolower($playback['restricted']) == 'false') {
return true;
}
// All types that are not statistics are included.
if ($playback['type'] != 'statistics') {
return true;
}
// Exclude imported recordings.
if ($this->recording->get('imported')) {
return false;
}
// Exclude non moderators.
if ($this->instance) {
if (!$this->instance->is_admin() && !$this->instance->is_moderator()) {
return false;
}
} else {
return roles::has_capability_in_course($this->recording->get('courseid'), 'mod/bigbluebuttonbn:managerecordings');
$canmanagerecordings = roles::has_capability_in_course(
$this->recording->get('courseid'), 'mod/bigbluebuttonbn:managerecordings');
$canviewallformats = roles::has_capability_in_course(
$this->recording->get('courseid'), 'mod/bigbluebuttonbn:viewallrecordingformats');
$issafeformat = false;
// Now check the list of safe formats.
if ($safeformats = config::get('recording_safe_formats')) {
$safeformatarray = str_getcsv($safeformats);
$issafeformat = in_array($playback['type'], $safeformatarray);
}
return true;
return ($canmanagerecordings && $canviewallformats) || $issafeformat;
}
}

@ -377,6 +377,26 @@ class settings {
$item,
$recordingsetting
);
$recordingsafeformat = [
'notes' => get_string('view_recording_format_notes', 'mod_bigbluebuttonbn'),
'podcast' => get_string('view_recording_format_podcast', 'mod_bigbluebuttonbn'),
'presentation' => get_string('view_recording_format_presentation', 'mod_bigbluebuttonbn'),
'screenshare' => get_string('view_recording_format_screenshare', 'mod_bigbluebuttonbn'),
'statistics' => get_string('view_recording_format_statistics', 'mod_bigbluebuttonbn'),
'video' => get_string('view_recording_format_video', 'mod_bigbluebuttonbn'),
];
$item = new admin_setting_configmultiselect(
'bigbluebuttonbn_recording_safe_formats',
get_string('config_recording_safe_formats', 'mod_bigbluebuttonbn'),
get_string('config_recording_safe_formats_description', 'mod_bigbluebuttonbn'),
['video', 'presentation'],
$recordingsafeformat
);
$this->add_conditional_element(
'recording_hide_button_editable',
$item,
$recordingsetting
);
}
$this->admin->add($this->parent, $recordingsetting);
}

@ -98,6 +98,17 @@ $capabilities = [
],
],
// Ability to view all recordings formats (if not user can only see the formats
// defined in bigbluebuttonbn_recording_safe_formats).
'mod/bigbluebuttonbn:viewallrecordingformats' => [
'captype' => 'read',
'contextlevel' => CONTEXT_MODULE,
'archetypes' => [
'manager' => CAP_ALLOW,
'editingteacher' => CAP_ALLOW,
],
],
// Ability to publish recordings.
'mod/bigbluebuttonbn:publishrecordings' => [
'captype' => 'write',

@ -43,6 +43,7 @@ $string['bigbluebuttonbn:protectrecordings'] = 'Protect recordings';
$string['bigbluebuttonbn:unprotectrecordings'] = 'Unprotect recordings';
$string['bigbluebuttonbn:deleterecordings'] = 'Delete recordings';
$string['bigbluebuttonbn:importrecordings'] = 'Import recordings';
$string['bigbluebuttonbn:viewallrecordingformats'] = 'View all recording formats';
$string['bigbluebuttonbn'] = 'BigBlueButton';
$string['bigbluebuttondisablednotification_subject'] = 'BigBlueButton activity module disabled.';
$string['bigbluebuttondisablednotification'] = 'The BigBlueButton activity module has been disabled and any existing BigBlueButton course activities are currently not accessible. Prior to re-enabling this plugin, please ensure that you have read and accepted the <a href="{$a}" target="_blank">data processing agreement</a> with Blindside Networks Inc.';
@ -190,6 +191,11 @@ $string['config_recordings_preview_editable_description'] = 'Preview feature can
$string['config_recordings_asc_sort'] = 'List recordings in chronological order';
$string['config_recordings_asc_sort_description'] = 'Recordings are ordered by date, either chronological or reverse chronological order (most recent recording first).';
$string['config_recording_safe_formats'] = 'Recording formats viewable by everyone';
$string['config_recording_safe_formats_description'] = 'Select the formats which are viewable by everyone.
All other formats are only viewable by teachers and other users with the mod/bigbluebuttonbn:viewallrecordingformats and
mod/bigbluebuttonbn:managerecordings capabilities.';
$string['config_importrecordings'] = 'Import recordings';
$string['config_importrecordings_description'] = 'These settings are feature specific.';
$string['config_importrecordings_enabled'] = 'Import recordings enabled';

@ -258,7 +258,9 @@ class mod_bigbluebuttonbn_generator extends \testing_module_generator {
]);
$mockdata['startTime'] = $data['starttime'] ?? $now;
$mockdata['endTime'] = $data['endtime'] ?? $mockdata['startTime'] + HOURSECS;
if (!empty($data['playback'])) {
$mockdata['playback'] = json_encode($data['playback']);
}
if (!empty($data['isBreakout'])) {
// If it is a breakout meeting, we do not have any way to know the real Id of the meeting
// unless we query the list of submeetings.

@ -0,0 +1,151 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
namespace mod_bigbluebuttonbn\output;
use mod_bigbluebuttonbn\instance;
use mod_bigbluebuttonbn\recording;
use mod_bigbluebuttonbn\test\testcase_helper_trait;
/**
* Recording row
*
* @package mod_bigbluebuttonbn
* @copyright 2010 onwards, Blindside Networks Inc
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
* @author Laurent David (laurent.david [at] call-learning [dt] fr)
*/
class recording_row_playback_test extends \advanced_testcase {
use testcase_helper_trait;
/**
* Setup for test
*/
public function setUp(): void {
parent::setUp();
$this->initialise_mock_server();
}
/**
* Recording sample data
*/
const RECORDING_DATA = [
[
'status' => recording::RECORDING_STATUS_PROCESSED,
'playback' => [
'format' =>
[
[
'type' => 'podcast',
'url' => 'http://mypodcast',
'processingTime' => 0,
'length' => 0,
],
[
'type' => 'presentation',
'url' => 'http://mypresentation',
'processingTime' => 0,
'length' => 0,
],
[
'type' => 'video',
'url' => 'http://myvideo',
'processingTime' => 0,
'length' => 0,
],
[
'type' => 'settings',
'url' => 'http://mysettings',
'processingTime' => 0,
'length' => 0,
]
]
]
]
];
/**
* Should this recording be included ?
*
* @param string $role
* @param array $canview
* @param object|null $globalsettings
* @return void
* @covers \recording_row_playback::should_be_included
* @dataProvider should_be_included_data_provider
*/
public function test_should_be_included(string $role, array $canview, object $globalsettings = null) {
global $PAGE;
$this->resetAfterTest();
['recordings' => $recordingsdata, 'activity' => $activity] = $this->create_activity_with_recordings(
$this->get_course(),
instance::TYPE_ALL,
self::RECORDING_DATA
);
$user = $this->getDataGenerator()->create_user();
$this->getDataGenerator()->enrol_user($user->id, $activity->course, $role);
if (!empty($globalsettings)) {
foreach ((array) $globalsettings as $key => $value) {
set_config($key, $value);
}
}
$this->setUser($user);
$recording = new recording(0, $recordingsdata[0]);
$rowplayback = new recording_row_playback($recording, instance::get_from_instanceid($activity->id));
$rowinfo = $rowplayback->export_for_template($PAGE->get_renderer('mod_bigbluebuttonbn'));
$playbacktypes = array_map(function($playback) {
foreach ($playback->attributes as $attributearray) {
if (in_array('data-target', $attributearray)) {
return $attributearray['value'];
}
}
return '';
}, $rowinfo->playbacks);
$this->assertEmpty(array_diff($canview, $playbacktypes));
}
/**
* Data provider for the should be included method
*
* @return array
*/
public function should_be_included_data_provider() {
return [
'editingteacher user should see all' => [
'role' => 'editingteacher',
'canview' => ['video', 'presentation', 'podcast', 'settings'],
],
'student can see only default' => [
'role' => 'student',
'canview' => ['video', 'presentation'],
],
'student can see only default except when we add more format to all users' => [
'role' => 'student',
'canview' => ['video', 'presentation', 'settings'],
'globalsettings' => (object) ['bigbluebuttonbn_recording_safe_formats' => 'video,presentation,settings']
]
];
}
}

@ -27,6 +27,6 @@
defined('MOODLE_INTERNAL') || die;
$plugin->version = 2023021300;
$plugin->version = 2023032200;
$plugin->requires = 2022111800;
$plugin->component = 'mod_bigbluebuttonbn';