diff --git a/mod/bigbluebuttonbn/classes/local/bigbluebutton/recordings/recording_action.php b/mod/bigbluebuttonbn/classes/local/bigbluebutton/recordings/recording_action.php index 94297785628d4..dd3e38553b1c9 100644 --- a/mod/bigbluebuttonbn/classes/local/bigbluebutton/recordings/recording_action.php +++ b/mod/bigbluebuttonbn/classes/local/bigbluebutton/recordings/recording_action.php @@ -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. @@ -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); @@ -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); diff --git a/mod/bigbluebuttonbn/classes/local/bigbluebutton/recordings/recording_data.php b/mod/bigbluebuttonbn/classes/local/bigbluebutton/recordings/recording_data.php index 9cbe66922c3b2..a4536fcfb535a 100644 --- a/mod/bigbluebuttonbn/classes/local/bigbluebutton/recordings/recording_data.php +++ b/mod/bigbluebuttonbn/classes/local/bigbluebutton/recordings/recording_data.php @@ -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']); } diff --git a/mod/bigbluebuttonbn/classes/local/config.php b/mod/bigbluebuttonbn/classes/local/config.php index bb957c00696e9..a7caaa0c2a2ac 100644 --- a/mod/bigbluebuttonbn/classes/local/config.php +++ b/mod/bigbluebuttonbn/classes/local/config.php @@ -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', @@ -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'), diff --git a/mod/bigbluebuttonbn/classes/local/proxy/recording_proxy.php b/mod/bigbluebuttonbn/classes/local/proxy/recording_proxy.php index 507529eac4802..9fe952cfc0b45 100644 --- a/mod/bigbluebuttonbn/classes/local/proxy/recording_proxy.php +++ b/mod/bigbluebuttonbn/classes/local/proxy/recording_proxy.php @@ -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, diff --git a/mod/bigbluebuttonbn/classes/setting_validator.php b/mod/bigbluebuttonbn/classes/setting_validator.php index a38e58123ea25..7000d739b6ccb 100644 --- a/mod/bigbluebuttonbn/classes/setting_validator.php +++ b/mod/bigbluebuttonbn/classes/setting_validator.php @@ -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']) + ); } /** @@ -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']) ); } diff --git a/mod/bigbluebuttonbn/classes/settings.php b/mod/bigbluebuttonbn/classes/settings.php index f572e5ca597ea..5b19d3f7b896d 100644 --- a/mod/bigbluebuttonbn/classes/settings.php +++ b/mod/bigbluebuttonbn/classes/settings.php @@ -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); } diff --git a/mod/bigbluebuttonbn/lang/en/bigbluebuttonbn.php b/mod/bigbluebuttonbn/lang/en/bigbluebuttonbn.php index a6254ea1f77b6..a31f6c845a981 100644 --- a/mod/bigbluebuttonbn/lang/en/bigbluebuttonbn.php +++ b/mod/bigbluebuttonbn/lang/en/bigbluebuttonbn.php @@ -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';