Skip to content

Commit

Permalink
Merge branch 'MDL-73199' of git://github.com/jfederico/moodle
Browse files Browse the repository at this point in the history
  • Loading branch information
vmdef committed Dec 16, 2021
2 parents 3bdfc0f + 36caeca commit c8abe79
Show file tree
Hide file tree
Showing 7 changed files with 42 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

use mod_bigbluebuttonbn\instance;
use mod_bigbluebuttonbn\recording;
use mod_bigbluebuttonbn\local\config;

/**
* Collection of helper methods for handling recordings actions in Moodle.
Expand Down Expand Up @@ -70,10 +71,12 @@ public static function edit(recording $recording) {
* @param recording $recording
*/
public static function unprotect(recording $recording) {
if (!(boolean) config::get('recording_protect_editable')) {
// Recording protect action through UI is disabled, there is no need to do anything else.
throw new \moodle_exception('cannotperformaction', 'mod_bigblubuebuttobn', '', 'unprotect');
}
if ($recording->get('imported')) {
/* Since the recording link is the one fetched from the BBB server, imported recordings can not be
* unprotected. There is no need to do anything else.
*/
// Imported recordings can not be unprotected. There is no need to do anything else.
throw new \moodle_exception('cannotperformaction', 'mod_bigblubuebuttobn', '', 'unprotect');
}
$recording->set('protected', false);
Expand All @@ -86,10 +89,12 @@ public static function unprotect(recording $recording) {
* @param recording $recording
*/
public static function protect(recording $recording) {
if (!(boolean) config::get('recording_protect_editable')) {
// Recording protect action through UI is disabled, there is no need to do anything else.
throw new \moodle_exception('cannotperformaction', 'mod_bigblubuebuttobn', '', 'protect');
}
if ($recording->get('imported')) {
/* Since the recording link is the one fetched from the BBB server, imported recordings can not be
* protected. There is no need to do anything else.
*/
// Imported recordings can not be unprotected. There is no need to do anything else.
throw new \moodle_exception('cannotperformaction', 'mod_bigblubuebuttobn', '', 'protect');
}
$recording->set('protected', true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,12 @@ public static function get_recording_table(array $recordings, array $tools, inst

// Build table content.
foreach ($recordings as $recording) {
// Protected recordings is not a standard feature, remove actions when protected flag is not present.
$rowtools = $tools;
// Protected recordings may be enabled or disabled from UI through configuration.
if (!(boolean) config::get('recording_protect_editable')) {
$rowtools = array_diff($rowtools, ['protect', 'unprotect']);
}
// Protected recordings is not a standard feature, remove actions when protected flag is not present.
if (in_array('protect', $rowtools) && $recording->get('protected') === null) {
$rowtools = array_diff($rowtools, ['protect', 'unprotect']);
}
Expand Down
2 changes: 2 additions & 0 deletions mod/bigbluebuttonbn/classes/local/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ protected static function defaultvalues() {
'recording_all_from_start_editable' => false,
'recording_hide_button_default' => false,
'recording_hide_button_editable' => false,
'recording_protect_editable' => true,
'general_warning_message' => '',
'general_warning_roles' => 'editingteacher,teacher',
'general_warning_box_type' => 'info',
Expand Down Expand Up @@ -204,6 +205,7 @@ public static function get_options() {
'recording_all_from_start_editable' => self::get('recording_all_from_start_editable'),
'recording_hide_button_default' => self::get('recording_hide_button_default'),
'recording_hide_button_editable' => self::get('recording_hide_button_editable'),
'recording_protect_editable' => self::get('recording_protect_editable'),
'general_warning_message' => self::get('general_warning_message'),
'general_warning_box_type' => self::get('general_warning_box_type'),
'general_warning_button_text' => self::get('general_warning_button_text'),
Expand Down
7 changes: 7 additions & 0 deletions mod/bigbluebuttonbn/classes/local/proxy/recording_proxy.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,13 @@ public static function publish_recording(string $recordid, string $publish = 'tr
* @return bool
*/
public static function protect_recording(string $recordid, string $protected = 'true'): bool {
global $CFG;

// Ignore action if recording_protect_editable is set to false.
if (empty($CFG->bigbluebuttonbn_recording_protect_editable)) {
return false;
}

$result = self::fetch_endpoint_xml('updateRecordings', [
'recordID' => $recordid,
'protect' => $protected,
Expand Down
6 changes: 4 additions & 2 deletions mod/bigbluebuttonbn/classes/setting_validator.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,8 @@ public static function section_record_meeting_shown() {
!isset($CFG->bigbluebuttonbn['recording_all_from_start_default']) ||
!isset($CFG->bigbluebuttonbn['recording_all_from_start_editable']) ||
!isset($CFG->bigbluebuttonbn['recording_hide_button_default']) ||
!isset($CFG->bigbluebuttonbn['recording_hide_button_editable']) );
!isset($CFG->bigbluebuttonbn['recording_hide_button_editable'])
);
}

/**
Expand Down Expand Up @@ -82,7 +83,8 @@ public static function section_show_recordings_shown() {
!isset($CFG->bigbluebuttonbn['recordings_imported_editable']) ||
!isset($CFG->bigbluebuttonbn['recordings_preview_default']) ||
!isset($CFG->bigbluebuttonbn['recordings_preview_editable']) ||
!isset($CFG->bigbluebuttonbn['recordings_validate_url'])
!isset($CFG->bigbluebuttonbn['recordings_validate_url']) ||
!isset($CFG->bigbluebuttonbn['recording_protect_editable'])
);
}

Expand Down
11 changes: 11 additions & 0 deletions mod/bigbluebuttonbn/classes/settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -486,6 +486,17 @@ protected function add_showrecordings_settings(): void {
$item,
$showrecordingsettings
);
$item = new admin_setting_configcheckbox(
'bigbluebuttonbn_recording_protect_editable',
get_string('config_recording_protect_editable', 'bigbluebuttonbn'),
get_string('config_recording_protect_editable_description', 'bigbluebuttonbn'),
1
);
$this->add_conditional_element(
'recording_protect_editable',
$item,
$showrecordingsettings
);
}
$this->admin->add($this->section, $showrecordingsettings);
}
Expand Down
2 changes: 2 additions & 0 deletions mod/bigbluebuttonbn/lang/en/bigbluebuttonbn.php
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,8 @@
$string['config_recording_default_description'] = 'If enabled the sessions created in BigBlueButton will have recording capabilities.';
$string['config_recording_editable'] = 'Recording feature can be edited';
$string['config_recording_editable_description'] = 'If checked the interface includes an option for enable and disable the recording feature.';
$string['config_recording_protect_editable'] = 'Protected recordings state can be edited';
$string['config_recording_protect_editable_description'] = 'If checked the interface includes an option for protecting/unprotecting recordings.';
$string['config_recording_icons_enabled'] = 'Icons for recording management';
$string['config_recording_icons_enabled_description'] = 'When enabled, the recording management panel shows icons for the publish/unpublish and delete actions.';
$string['config_recording_all_from_start_default'] = 'Record all from start';
Expand Down

0 comments on commit c8abe79

Please sign in to comment.