Skip to content

Commit

Permalink
Merge branch 'MDL-75604-400' of https://github.com/ssj365/moodle into…
Browse files Browse the repository at this point in the history
… MOODLE_400_STABLE
  • Loading branch information
andrewnicols authored and ilyatregubov committed Dec 1, 2022
2 parents cb26fec + c72574f commit 1d35066
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 9 deletions.
14 changes: 13 additions & 1 deletion mod/bigbluebuttonbn/classes/setting_validator.php
Expand Up @@ -37,7 +37,19 @@ class setting_validator {
public static function section_general_shown() {
global $CFG;
return (!isset($CFG->bigbluebuttonbn['server_url']) ||
!isset($CFG->bigbluebuttonbn['shared_secret']));
!isset($CFG->bigbluebuttonbn['shared_secret'])
);
}

/**
* Validate if default messages section will be shown.
*
* @return bool
*/
public static function section_default_messages_shown() {
global $CFG;
return (!isset($CFG->bigbluebuttonbn['welcome_default']) ||
!isset($CFG->bigbluebuttonbn['welcome_editable']));
}

/**
Expand Down
33 changes: 25 additions & 8 deletions mod/bigbluebuttonbn/classes/settings.php
Expand Up @@ -84,8 +84,9 @@ public function __construct(admin_category $admin, \core\plugininfo\mod $module,
* Add all settings.
*/
public function add_all_settings(): void {
// Renders settings for welcome messages.
$this->add_defaultmessages_settings();
// Evaluates if recordings are enabled for the Moodle site.

// Renders settings for record feature.
$this->add_record_settings();
// Renders settings for import recordings.
Expand Down Expand Up @@ -187,13 +188,29 @@ function() {
$item,
$settingsgeneral
);
$settingsgeneral->add($item);
}
return $settingsgeneral;
}

/**
* Helper function renders default messages settings if the feature is enabled.
*/
protected function add_defaultmessages_settings(): void {
// Configuration for 'default messages' feature.
$defaultmessagessetting = new admin_settingpage(
"{$this->sectionnameprefix}_default_messages",
get_string('config_default_messages', 'bigbluebuttonbn'),
'moodle/site:config',
!((boolean) setting_validator::section_default_messages_shown()) && ($this->moduleenabled)
);

if ($this->admin->fulltree) {
$item = new admin_setting_heading(
'bigbluebuttonbn_config_default_messages',
get_string('config_default_messages', 'bigbluebuttonbn'),
'',
get_string('config_default_messages_description', 'bigbluebuttonbn')
);
$settingsgeneral->add($item);
$defaultmessagessetting->add($item);
$item = new admin_setting_configtextarea(
'bigbluebuttonbn_welcome_default',
get_string('config_welcome_default', 'bigbluebuttonbn'),
Expand All @@ -204,9 +221,8 @@ function() {
$this->add_conditional_element(
'welcome_default',
$item,
$settingsgeneral
$defaultmessagessetting
);
$settingsgeneral->add($item);
$item = new admin_setting_configcheckbox(
'bigbluebuttonbn_welcome_editable',
get_string('config_welcome_editable', 'bigbluebuttonbn'),
Expand All @@ -216,10 +232,11 @@ function() {
$this->add_conditional_element(
'welcome_editable',
$item,
$settingsgeneral
$defaultmessagessetting
);
}
return $settingsgeneral;
$this->admin->add($this->parent, $defaultmessagessetting);

}

/**
Expand Down

0 comments on commit 1d35066

Please sign in to comment.