Search moodle.org's
Developer Documentation

See Release Notes
Long Term Support Release

  • Bug fixes for general core bugs in 4.1.x will end 13 November 2023 (12 months).
  • Bug fixes for security issues in 4.1.x will end 10 November 2025 (36 months).
  • PHP version: minimum PHP 7.4.0 Note: minimum PHP version has increased since Moodle 4.0. PHP 8.0.x is supported too.

Differences Between: [Versions 400 and 401] [Versions 401 and 402] [Versions 401 and 403]

   1  <?php
   2  // This file is part of Moodle - http://moodle.org/
   3  //
   4  // Moodle is free software: you can redistribute it and/or modify
   5  // it under the terms of the GNU General Public License as published by
   6  // the Free Software Foundation, either version 3 of the License, or
   7  // (at your option) any later version.
   8  //
   9  // Moodle is distributed in the hope that it will be useful,
  10  // but WITHOUT ANY WARRANTY; without even the implied warranty of
  11  // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  12  // GNU General Public License for more details.
  13  //
  14  // You should have received a copy of the GNU General Public License
  15  // along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
  16  
  17  namespace mod_bigbluebuttonbn;
  18  
  19  use admin_category;
  20  use admin_setting;
  21  use admin_setting_configcheckbox;
  22  use admin_setting_configmultiselect;
  23  use admin_setting_configpasswordunmask;
  24  use admin_setting_configstoredfile;
  25  use admin_setting_configtext;
  26  use admin_setting_configtextarea;
  27  use admin_setting_heading;
  28  use admin_settingpage;
  29  use cache_helper;
  30  use lang_string;
  31  use mod_bigbluebuttonbn\local\config;
  32  use mod_bigbluebuttonbn\local\helpers\roles;
  33  use mod_bigbluebuttonbn\local\proxy\bigbluebutton_proxy;
  34  
  35  /**
  36   * The mod_bigbluebuttonbn settings helper
  37   *
  38   * @package   mod_bigbluebuttonbn
  39   * @copyright 2021 onwards, Blindside Networks Inc
  40   * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  41   * @author    Laurent David  (laurent [at] call-learning [dt] fr)
  42   */
  43  class settings {
  44  
  45      /** @var admin_setting shared value */
  46      private $admin;
  47  
  48      /** @var bool Module is enabled */
  49      private $moduleenabled;
  50  
  51      /** @var string The name of the section */
  52      private $section;
  53  
  54      /** @var string The parent name */
  55      private $parent = "modbigbluebuttonbnfolder";
  56  
  57      /** @var string The section name prefix */
  58      private $sectionnameprefix = "mod_bigbluebuttonbn";
  59  
  60      /**
  61       * Constructor for the bigbluebuttonbn settings.
  62       *
  63       * @param admin_category $admin
  64       * @param \core\plugininfo\mod $module
  65       * @param string $categoryname for the plugin setting (main setting page)
  66       */
  67      public function __construct(admin_category $admin, \core\plugininfo\mod $module, string $categoryname) {
  68          $this->moduleenabled = $module->is_enabled() === true;
  69          $this->admin = $admin;
  70          $this->section = $categoryname;
  71  
  72          $modbigbluebuttobnfolder = new admin_category(
  73              $this->parent,
  74              new lang_string('pluginname', 'mod_bigbluebuttonbn'),
  75              $module->is_enabled() === false
  76          );
  77  
  78          $admin->add('modsettings', $modbigbluebuttobnfolder);
  79  
  80          $mainsettings = $this->add_general_settings();
  81          $admin->add($this->parent, $mainsettings);
  82      }
  83  
  84      /**
  85       * Add all settings.
  86       */
  87      public function add_all_settings(): void {
  88          // Renders settings for welcome messages.
  89          $this->add_defaultmessages_settings();
  90          // Evaluates if recordings are enabled for the Moodle site.
  91          // Renders settings for record feature.
  92          $this->add_record_settings();
  93          // Renders settings for import recordings.
  94          $this->add_importrecordings_settings();
  95          // Renders settings for showing recordings.
  96          $this->add_showrecordings_settings();
  97  
  98          // Renders settings for meetings.
  99          $this->add_waitmoderator_settings();
 100          $this->add_voicebridge_settings();
 101          $this->add_preupload_settings();
 102          $this->add_userlimit_settings();
 103          $this->add_participants_settings();
 104          $this->add_muteonstart_settings();
 105          $this->add_lock_settings();
 106          // Renders settings for extended capabilities.
 107          $this->add_extended_settings();
 108          // Renders settings for experimental features.
 109          $this->add_experimental_settings();
 110      }
 111  
 112      /**
 113       * Add the setting and lock it conditionally.
 114       *
 115       * @param string $name
 116       * @param admin_setting $item
 117       * @param admin_settingpage $settings
 118       */
 119      protected function add_conditional_element(string $name, admin_setting $item, admin_settingpage $settings): void {
 120          global $CFG;
 121          if (isset($CFG->bigbluebuttonbn) && isset($CFG->bigbluebuttonbn[$name])) {
 122              if ($item->config_read($item->name)) {
 123                  // A value has been set, we can safely omit the setting and it won't interfere with installation
 124                  // process.
 125                  // The idea behind it is to hide values from end-users in case we use multitenancy for example.
 126                  return;
 127              }
 128          }
 129          $settings->add($item);
 130      }
 131  
 132      /**
 133       * Helper function renders general settings if the feature is enabled.
 134       *
 135       * @return admin_settingpage
 136       * @throws \coding_exception
 137       */
 138      protected function add_general_settings(): admin_settingpage {
 139          global $CFG;
 140  
 141          $settingsgeneral = new admin_settingpage(
 142              $this->section,
 143              get_string('config_general', 'bigbluebuttonbn'),
 144              'moodle/site:config',
 145              !((boolean) setting_validator::section_general_shown()) && ($this->moduleenabled)
 146          );
 147          if ($this->admin->fulltree) {
 148              // Configuration for BigBlueButton.
 149              $item = new admin_setting_heading('bigbluebuttonbn_config_general',
 150                  '',
 151                  get_string('config_general_description', 'bigbluebuttonbn')
 152              );
 153  
 154              if (empty($CFG->bigbluebuttonbn_default_dpa_accepted)) {
 155                  $settingsgeneral->add(new admin_setting_configcheckbox(
 156                      'bigbluebuttonbn_default_dpa_accepted',
 157                      get_string('acceptdpa', 'mod_bigbluebuttonbn'),
 158                      get_string('enablingbigbluebuttondpainfo', 'mod_bigbluebuttonbn', config::DEFAULT_DPA_URL),
 159                      0
 160                  ));
 161              }
 162  
 163              $settingsgeneral->add($item);
 164              $item = new admin_setting_configtext(
 165                  'bigbluebuttonbn_server_url',
 166                  get_string('config_server_url', 'bigbluebuttonbn'),
 167                  get_string('config_server_url_description', 'bigbluebuttonbn'),
 168                  config::DEFAULT_SERVER_URL,
 169                  PARAM_RAW
 170              );
 171              $item->set_updatedcallback(
 172                  function() {
 173                      $this->reset_cache();
 174                      $task = new \mod_bigbluebuttonbn\task\reset_recordings();
 175                      \core\task\manager::queue_adhoc_task($task);
 176                  }
 177              );
 178              $this->add_conditional_element(
 179                  'server_url',
 180                  $item,
 181                  $settingsgeneral
 182              );
 183              $item = new admin_setting_configpasswordunmask(
 184                  'bigbluebuttonbn_shared_secret',
 185                  get_string('config_shared_secret', 'bigbluebuttonbn'),
 186                  get_string('config_shared_secret_description', 'bigbluebuttonbn'),
 187                  config::DEFAULT_SHARED_SECRET
 188              );
 189              $this->add_conditional_element(
 190                  'shared_secret',
 191                  $item,
 192                  $settingsgeneral
 193              );
 194              $item = new \admin_setting_description(
 195                  'bigbluebuttonbn_dpa_info',
 196                  '',
 197                  get_string('config_dpa_note', 'bigbluebuttonbn', config::DEFAULT_DPA_URL),
 198              );
 199              $this->add_conditional_element(
 200                  'dpa_info',
 201                  $item,
 202                  $settingsgeneral
 203              );
 204              $item = new admin_setting_configtext(
 205                  'bigbluebuttonbn_poll_interval',
 206                  get_string('config_poll_interval', 'bigbluebuttonbn'),
 207                  get_string('config_poll_interval_description', 'bigbluebuttonbn'),
 208                  bigbluebutton_proxy::DEFAULT_POLL_INTERVAL,
 209                  PARAM_INT
 210              );
 211              $this->add_conditional_element(
 212                  'poll_interval',
 213                  $item,
 214                  $settingsgeneral
 215              );
 216          }
 217          return $settingsgeneral;
 218      }
 219  
 220      /**
 221       * Helper function renders default messages settings if the feature is enabled.
 222       */
 223      protected function add_defaultmessages_settings(): void {
 224          // Configuration for 'default messages' feature.
 225          $defaultmessagessetting = new admin_settingpage(
 226              "{$this->sectionnameprefix}_default_messages",
 227              get_string('config_default_messages', 'bigbluebuttonbn'),
 228              'moodle/site:config',
 229              !((boolean) setting_validator::section_default_messages_shown()) && ($this->moduleenabled)
 230          );
 231  
 232          if ($this->admin->fulltree) {
 233              $item = new admin_setting_heading(
 234                  'bigbluebuttonbn_config_default_messages',
 235                  '',
 236                  get_string('config_default_messages_description', 'bigbluebuttonbn')
 237              );
 238              $defaultmessagessetting->add($item);
 239              $item = new admin_setting_configtextarea(
 240                  'bigbluebuttonbn_welcome_default',
 241                  get_string('config_welcome_default', 'bigbluebuttonbn'),
 242                  get_string('config_welcome_default_description', 'bigbluebuttonbn'),
 243                  '',
 244                  PARAM_TEXT
 245              );
 246              $this->add_conditional_element(
 247                  'welcome_default',
 248                  $item,
 249                  $defaultmessagessetting
 250              );
 251              $item = new admin_setting_configcheckbox(
 252                  'bigbluebuttonbn_welcome_editable',
 253                  get_string('config_welcome_editable', 'bigbluebuttonbn'),
 254                  get_string('config_welcome_editable_description', 'bigbluebuttonbn'),
 255                  1,
 256              );
 257              $this->add_conditional_element(
 258                  'welcome_editable',
 259                  $item,
 260                  $defaultmessagessetting
 261              );
 262          }
 263          $this->admin->add($this->parent, $defaultmessagessetting);
 264  
 265      }
 266  
 267      /**
 268       * Helper function renders record settings if the feature is enabled.
 269       */
 270      protected function add_record_settings(): void {
 271          // Configuration for 'recording' feature.
 272          $recordingsetting = new admin_settingpage(
 273              "{$this->sectionnameprefix}_recording",
 274              get_string('config_recording', 'bigbluebuttonbn'),
 275              'moodle/site:config',
 276              !((boolean) setting_validator::section_record_meeting_shown()) && ($this->moduleenabled)
 277          );
 278  
 279          if ($this->admin->fulltree) {
 280              $item = new admin_setting_heading(
 281                  'bigbluebuttonbn_config_recording',
 282                  '',
 283                  get_string('config_recording_description', 'bigbluebuttonbn')
 284              );
 285              $recordingsetting->add($item);
 286              $item = new admin_setting_configcheckbox(
 287                  'bigbluebuttonbn_recording_default',
 288                  get_string('config_recording_default', 'bigbluebuttonbn'),
 289                  get_string('config_recording_default_description', 'bigbluebuttonbn'),
 290                  1
 291              );
 292              $this->add_conditional_element(
 293                  'recording_default',
 294                  $item,
 295                  $recordingsetting
 296              );
 297              $item = new admin_setting_configtext(
 298                  'bigbluebuttonbn_recording_refresh_period',
 299                  get_string('config_recording_refresh_period', 'bigbluebuttonbn'),
 300                  get_string('config_recording_refresh_period_description', 'bigbluebuttonbn'),
 301                  recording::RECORDING_REFRESH_DEFAULT_PERIOD,
 302                  PARAM_INT
 303              );
 304              $this->add_conditional_element(
 305                  'recording_refresh_period',
 306                  $item,
 307                  $recordingsetting
 308              );
 309              $item = new admin_setting_configcheckbox(
 310                  'bigbluebuttonbn_recording_editable',
 311                  get_string('config_recording_editable', 'bigbluebuttonbn'),
 312                  get_string('config_recording_editable_description', 'bigbluebuttonbn'),
 313                  1
 314              );
 315              $this->add_conditional_element(
 316                  'recording_editable',
 317                  $item,
 318                  $recordingsetting
 319              );
 320  
 321              // Add recording start to load and allow/hide stop/pause.
 322              $item = new admin_setting_configcheckbox(
 323                  'bigbluebuttonbn_recording_all_from_start_default',
 324                  get_string('config_recording_all_from_start_default', 'bigbluebuttonbn'),
 325                  get_string('config_recording_all_from_start_default_description', 'bigbluebuttonbn'),
 326                  0
 327              );
 328              $this->add_conditional_element(
 329                  'recording_all_from_start_default',
 330                  $item,
 331                  $recordingsetting
 332              );
 333              $item = new admin_setting_configcheckbox(
 334                  'bigbluebuttonbn_recording_all_from_start_editable',
 335                  get_string('config_recording_all_from_start_editable', 'bigbluebuttonbn'),
 336                  get_string('config_recording_all_from_start_editable_description', 'bigbluebuttonbn'),
 337                  0
 338              );
 339              $this->add_conditional_element(
 340                  'recording_all_from_start_editable',
 341                  $item,
 342                  $recordingsetting
 343              );
 344              $item = new admin_setting_configcheckbox(
 345                  'bigbluebuttonbn_recording_hide_button_default',
 346                  get_string('config_recording_hide_button_default', 'bigbluebuttonbn'),
 347                  get_string('config_recording_hide_button_default_description', 'bigbluebuttonbn'),
 348                  0
 349              );
 350              $this->add_conditional_element(
 351                  'recording_hide_button_default',
 352                  $item,
 353                  $recordingsetting
 354              );
 355              $item = new admin_setting_configcheckbox(
 356                  'bigbluebuttonbn_recording_hide_button_editable',
 357                  get_string('config_recording_hide_button_editable', 'bigbluebuttonbn'),
 358                  get_string('config_recording_hide_button_editable_description', 'bigbluebuttonbn'),
 359                  0
 360              );
 361              $this->add_conditional_element(
 362                  'recording_hide_button_editable',
 363                  $item,
 364                  $recordingsetting
 365              );
 366          }
 367          $this->admin->add($this->parent, $recordingsetting);
 368      }
 369  
 370      /**
 371       * Helper function renders import recording settings if the feature is enabled.
 372       */
 373      protected function add_importrecordings_settings(): void {
 374          // Configuration for 'import recordings' feature.
 375          $importrecordingsettings = new admin_settingpage(
 376              "{$this->sectionnameprefix}_importrecording",
 377              get_string('config_importrecordings', 'bigbluebuttonbn'),
 378              'moodle/site:config',
 379              !((boolean) setting_validator::section_import_recordings_shown()) && ($this->moduleenabled)
 380          );
 381  
 382          if ($this->admin->fulltree) {
 383              $item = new admin_setting_heading(
 384                  'bigbluebuttonbn_config_importrecordings',
 385                  '',
 386                  get_string('config_importrecordings_description', 'bigbluebuttonbn')
 387              );
 388              $importrecordingsettings->add($item);
 389              $item = new admin_setting_configcheckbox(
 390                  'bigbluebuttonbn_importrecordings_enabled',
 391                  get_string('config_importrecordings_enabled', 'bigbluebuttonbn'),
 392                  get_string('config_importrecordings_enabled_description', 'bigbluebuttonbn'),
 393                  0
 394              );
 395              $this->add_conditional_element(
 396                  'importrecordings_enabled',
 397                  $item,
 398                  $importrecordingsettings
 399              );
 400              $item = new admin_setting_configcheckbox(
 401                  'bigbluebuttonbn_importrecordings_from_deleted_enabled',
 402                  get_string('config_importrecordings_from_deleted_enabled', 'bigbluebuttonbn'),
 403                  get_string('config_importrecordings_from_deleted_enabled_description', 'bigbluebuttonbn'),
 404                  0
 405              );
 406              $this->add_conditional_element(
 407                  'importrecordings_from_deleted_enabled',
 408                  $item,
 409                  $importrecordingsettings
 410              );
 411          }
 412          $this->admin->add($this->parent, $importrecordingsettings);
 413      }
 414  
 415      /**
 416       * Helper function renders show recording settings if the feature is enabled.
 417       */
 418      protected function add_showrecordings_settings(): void {
 419          // Configuration for 'show recordings' feature.
 420          $showrecordingsettings = new admin_settingpage(
 421              "{$this->sectionnameprefix}_showrecordings",
 422              get_string('config_recordings', 'bigbluebuttonbn'),
 423              'moodle/site:config',
 424              !((boolean) setting_validator::section_show_recordings_shown()) && ($this->moduleenabled)
 425          );
 426  
 427          if ($this->admin->fulltree) {
 428              $item = new admin_setting_heading(
 429                  'bigbluebuttonbn_config_recordings',
 430                  '',
 431                  get_string('config_recordings_description', 'bigbluebuttonbn')
 432              );
 433              $showrecordingsettings->add($item);
 434              $item = new admin_setting_configcheckbox(
 435                  'bigbluebuttonbn_recordings_deleted_default',
 436                  get_string('config_recordings_deleted_default', 'bigbluebuttonbn'),
 437                  get_string('config_recordings_deleted_default_description', 'bigbluebuttonbn'),
 438                  1
 439              );
 440              $this->add_conditional_element(
 441                  'recordings_deleted_default',
 442                  $item,
 443                  $showrecordingsettings
 444              );
 445              $item = new admin_setting_configcheckbox(
 446                  'bigbluebuttonbn_recordings_deleted_editable',
 447                  get_string('config_recordings_deleted_editable', 'bigbluebuttonbn'),
 448                  get_string('config_recordings_deleted_editable_description', 'bigbluebuttonbn'),
 449                  0
 450              );
 451              $this->add_conditional_element(
 452                  'recordings_deleted_editable',
 453                  $item,
 454                  $showrecordingsettings
 455              );
 456              $item = new admin_setting_configcheckbox(
 457                  'bigbluebuttonbn_recordings_imported_default',
 458                  get_string('config_recordings_imported_default', 'bigbluebuttonbn'),
 459                  get_string('config_recordings_imported_default_description', 'bigbluebuttonbn'),
 460                  0
 461              );
 462              $this->add_conditional_element(
 463                  'recordings_imported_default',
 464                  $item,
 465                  $showrecordingsettings
 466              );
 467              $item = new admin_setting_configcheckbox(
 468                  'bigbluebuttonbn_recordings_imported_editable',
 469                  get_string('config_recordings_imported_editable', 'bigbluebuttonbn'),
 470                  get_string('config_recordings_imported_editable_description', 'bigbluebuttonbn'),
 471                  1
 472              );
 473              $this->add_conditional_element(
 474                  'recordings_imported_editable',
 475                  $item,
 476                  $showrecordingsettings
 477              );
 478              $item = new admin_setting_configcheckbox(
 479                  'bigbluebuttonbn_recordings_preview_default',
 480                  get_string('config_recordings_preview_default', 'bigbluebuttonbn'),
 481                  get_string('config_recordings_preview_default_description', 'bigbluebuttonbn'),
 482                  1
 483              );
 484              $this->add_conditional_element(
 485                  'recordings_preview_default',
 486                  $item,
 487                  $showrecordingsettings
 488              );
 489              $item = new admin_setting_configcheckbox(
 490                  'bigbluebuttonbn_recordings_preview_editable',
 491                  get_string('config_recordings_preview_editable', 'bigbluebuttonbn'),
 492                  get_string('config_recordings_preview_editable_description', 'bigbluebuttonbn'),
 493                  0
 494              );
 495              $this->add_conditional_element(
 496                  'recordings_preview_editable',
 497                  $item,
 498                  $showrecordingsettings
 499              );
 500              $item = new admin_setting_configcheckbox(
 501                  'bigbluebuttonbn_recordings_asc_sort',
 502                  get_string('config_recordings_asc_sort', 'bigbluebuttonbn'),
 503                  get_string('config_recordings_asc_sort_description', 'bigbluebuttonbn'),
 504                  0
 505              );
 506              $this->add_conditional_element(
 507                  'recordings_asc_sort',
 508                  $item,
 509                  $showrecordingsettings
 510              );
 511              $item = new admin_setting_configcheckbox(
 512                  'bigbluebuttonbn_recording_protect_editable',
 513                  get_string('config_recording_protect_editable', 'bigbluebuttonbn'),
 514                  get_string('config_recording_protect_editable_description', 'bigbluebuttonbn'),
 515                  1
 516              );
 517              $this->add_conditional_element(
 518                  'recording_protect_editable',
 519                  $item,
 520                  $showrecordingsettings
 521              );
 522          }
 523          $this->admin->add($this->parent, $showrecordingsettings);
 524      }
 525  
 526      /**
 527       * Helper function renders wait for moderator settings if the feature is enabled.
 528       */
 529      protected function add_waitmoderator_settings(): void {
 530          // Configuration for wait for moderator feature.
 531          $waitmoderatorsettings = new admin_settingpage(
 532              "{$this->sectionnameprefix}_waitformoderator",
 533              get_string('config_waitformoderator', 'bigbluebuttonbn'),
 534              'moodle/site:config',
 535              !((boolean) setting_validator::section_wait_moderator_shown()) && ($this->moduleenabled)
 536          );
 537  
 538          if ($this->admin->fulltree) {
 539              $item = new admin_setting_heading(
 540                  'bigbluebuttonbn_config_waitformoderator',
 541                  '',
 542                  get_string('config_waitformoderator_description', 'bigbluebuttonbn')
 543              );
 544              $waitmoderatorsettings->add($item);
 545              $item = new admin_setting_configcheckbox(
 546                  'bigbluebuttonbn_waitformoderator_default',
 547                  get_string('config_waitformoderator_default', 'bigbluebuttonbn'),
 548                  get_string('config_waitformoderator_default_description', 'bigbluebuttonbn'),
 549                  0
 550              );
 551              $this->add_conditional_element(
 552                  'waitformoderator_default',
 553                  $item,
 554                  $waitmoderatorsettings
 555              );
 556              $item = new admin_setting_configcheckbox(
 557                  'bigbluebuttonbn_waitformoderator_editable',
 558                  get_string('config_waitformoderator_editable', 'bigbluebuttonbn'),
 559                  get_string('config_waitformoderator_editable_description', 'bigbluebuttonbn'),
 560                  1
 561              );
 562              $this->add_conditional_element(
 563                  'waitformoderator_editable',
 564                  $item,
 565                  $waitmoderatorsettings
 566              );
 567              $item = new admin_setting_configtext(
 568                  'bigbluebuttonbn_waitformoderator_ping_interval',
 569                  get_string('config_waitformoderator_ping_interval', 'bigbluebuttonbn'),
 570                  get_string('config_waitformoderator_ping_interval_description', 'bigbluebuttonbn'),
 571                  10,
 572                  PARAM_INT
 573              );
 574              $this->add_conditional_element(
 575                  'waitformoderator_ping_interval',
 576                  $item,
 577                  $waitmoderatorsettings
 578              );
 579              $item = new admin_setting_configtext(
 580                  'bigbluebuttonbn_waitformoderator_cache_ttl',
 581                  get_string('config_waitformoderator_cache_ttl', 'bigbluebuttonbn'),
 582                  get_string('config_waitformoderator_cache_ttl_description', 'bigbluebuttonbn'),
 583                  60,
 584                  PARAM_INT
 585              );
 586              $this->add_conditional_element(
 587                  'waitformoderator_cache_ttl',
 588                  $item,
 589                  $waitmoderatorsettings
 590              );
 591          }
 592          $this->admin->add($this->parent, $waitmoderatorsettings);
 593      }
 594  
 595      /**
 596       * Helper function renders static voice bridge settings if the feature is enabled.
 597       */
 598      protected function add_voicebridge_settings(): void {
 599          // Configuration for "static voice bridge" feature.
 600          $voicebridgesettings = new admin_settingpage(
 601              "{$this->sectionnameprefix}_voicebridge",
 602              get_string('config_voicebridge', 'bigbluebuttonbn'),
 603              'moodle/site:config',
 604              !((boolean) setting_validator::section_static_voice_bridge_shown()) && ($this->moduleenabled)
 605          );
 606  
 607          if ($this->admin->fulltree) {
 608              $item = new admin_setting_heading(
 609                  'bigbluebuttonbn_config_voicebridge',
 610                  '',
 611                  get_string('config_voicebridge_description', 'bigbluebuttonbn')
 612              );
 613              $voicebridgesettings->add($item);
 614              $item = new admin_setting_configcheckbox(
 615                  'bigbluebuttonbn_voicebridge_editable',
 616                  get_string('config_voicebridge_editable', 'bigbluebuttonbn'),
 617                  get_string('config_voicebridge_editable_description', 'bigbluebuttonbn'),
 618                  0
 619              );
 620              $this->add_conditional_element(
 621                  'voicebridge_editable',
 622                  $item,
 623                  $voicebridgesettings
 624              );
 625          }
 626          $this->admin->add($this->parent, $voicebridgesettings);
 627      }
 628  
 629      /**
 630       * Helper function renders preuploaded presentation settings if the feature is enabled.
 631       */
 632      protected function add_preupload_settings(): void {
 633          // Configuration for "preupload presentation" feature.
 634          $preuploadsettings = new admin_settingpage(
 635              "{$this->sectionnameprefix}_preupload",
 636              get_string('config_preuploadpresentation', 'bigbluebuttonbn'),
 637              'moodle/site:config',
 638              !((boolean) setting_validator::section_preupload_presentation_shown()) && ($this->moduleenabled)
 639          );
 640  
 641          if ($this->admin->fulltree) {
 642              // This feature only works if curl is installed (but it is as now required by Moodle). The checks have been removed.
 643              $item = new admin_setting_heading(
 644                  'bigbluebuttonbn_config_preuploadpresentation',
 645                  '',
 646                  get_string('config_preuploadpresentation_description', 'bigbluebuttonbn')
 647              );
 648              $preuploadsettings->add($item);
 649  
 650              $item = new admin_setting_configcheckbox(
 651                  'bigbluebuttonbn_preuploadpresentation_editable',
 652                  get_string('config_preuploadpresentation_editable', 'bigbluebuttonbn'),
 653                  get_string('config_preuploadpresentation_editable_description', 'bigbluebuttonbn'),
 654                  0
 655              );
 656              $this->add_conditional_element(
 657                  'preuploadpresentation_editable',
 658                  $item,
 659                  $preuploadsettings
 660              );
 661              // Note: checks on curl library have been removed as it is a requirement from Moodle.
 662              $filemanageroptions = [];
 663              $filemanageroptions['accepted_types'] = '*';
 664              $filemanageroptions['maxbytes'] = 0;
 665              $filemanageroptions['subdirs'] = 0;
 666              $filemanageroptions['maxfiles'] = 1;
 667              $filemanageroptions['mainfile'] = true;
 668  
 669              $filemanager = new admin_setting_configstoredfile(
 670                  'mod_bigbluebuttonbn/presentationdefault',
 671                  get_string('config_presentation_default', 'bigbluebuttonbn'),
 672                  get_string('config_presentation_default_description', 'bigbluebuttonbn'),
 673                  'presentationdefault',
 674                  0,
 675                  $filemanageroptions
 676              );
 677  
 678              $preuploadsettings->add($filemanager);
 679          }
 680          $this->admin->add($this->parent, $preuploadsettings);
 681      }
 682  
 683      /**
 684       * Helper function renders userlimit settings if the feature is enabled.
 685       */
 686      protected function add_userlimit_settings(): void {
 687          $userlimitsettings = new admin_settingpage(
 688              "{$this->sectionnameprefix}_userlimit",
 689              get_string('config_userlimit', 'bigbluebuttonbn'),
 690              'moodle/site:config',
 691              !((boolean) setting_validator::section_user_limit_shown()) && ($this->moduleenabled)
 692          );
 693  
 694          if ($this->admin->fulltree) {
 695              // Configuration for "user limit" feature.
 696              $item = new admin_setting_heading(
 697                  'bigbluebuttonbn_config_userlimit',
 698                  '',
 699                  get_string('config_userlimit_description', 'bigbluebuttonbn')
 700              );
 701              $userlimitsettings->add($item);
 702              $item = new admin_setting_configtext(
 703                  'bigbluebuttonbn_userlimit_default',
 704                  get_string('config_userlimit_default', 'bigbluebuttonbn'),
 705                  get_string('config_userlimit_default_description', 'bigbluebuttonbn'),
 706                  0,
 707                  PARAM_INT
 708              );
 709              $this->add_conditional_element(
 710                  'userlimit_default',
 711                  $item,
 712                  $userlimitsettings
 713              );
 714              $item = new admin_setting_configcheckbox(
 715                  'bigbluebuttonbn_userlimit_editable',
 716                  get_string('config_userlimit_editable', 'bigbluebuttonbn'),
 717                  get_string('config_userlimit_editable_description', 'bigbluebuttonbn'),
 718                  0
 719              );
 720              $this->add_conditional_element(
 721                  'userlimit_editable',
 722                  $item,
 723                  $userlimitsettings
 724              );
 725          }
 726          $this->admin->add($this->parent, $userlimitsettings);
 727      }
 728  
 729      /**
 730       * Helper function renders participant settings if the feature is enabled.
 731       */
 732      protected function add_participants_settings(): void {
 733          // Configuration for defining the default role/user that will be moderator on new activities.
 734          $participantsettings = new admin_settingpage(
 735              "{$this->sectionnameprefix}_participant",
 736              get_string('config_participant', 'bigbluebuttonbn'),
 737              'moodle/site:config',
 738              !((boolean) setting_validator::section_moderator_default_shown()) && ($this->moduleenabled)
 739          );
 740  
 741          if ($this->admin->fulltree) {
 742              $item = new admin_setting_heading(
 743                  'bigbluebuttonbn_config_participant',
 744                  '',
 745                  get_string('config_participant_description', 'bigbluebuttonbn')
 746              );
 747              $participantsettings->add($item);
 748  
 749              // UI for 'participants' feature.
 750              $roles = roles::get_roles(null, false);
 751              $owner = [
 752                  '0' => get_string('mod_form_field_participant_list_type_owner', 'bigbluebuttonbn')
 753              ];
 754              $item = new admin_setting_configmultiselect(
 755                  'bigbluebuttonbn_participant_moderator_default',
 756                  get_string('config_participant_moderator_default', 'bigbluebuttonbn'),
 757                  get_string('config_participant_moderator_default_description', 'bigbluebuttonbn'),
 758                  array_keys($owner),
 759                  $owner + $roles
 760              );
 761              $this->add_conditional_element(
 762                  'participant_moderator_default',
 763                  $item,
 764                  $participantsettings
 765              );
 766          }
 767          $this->admin->add($this->parent, $participantsettings);
 768      }
 769  
 770      /**
 771       * Helper function renders general settings if the feature is enabled.
 772       */
 773      protected function add_muteonstart_settings(): void {
 774          // Configuration for BigBlueButton.
 775          $muteonstartsetting = new admin_settingpage(
 776              "{$this->sectionnameprefix}_muteonstart",
 777              get_string('config_muteonstart', 'bigbluebuttonbn'),
 778              'moodle/site:config',
 779              !((boolean) setting_validator::section_muteonstart_shown()) && ($this->moduleenabled)
 780          );
 781  
 782          if ($this->admin->fulltree) {
 783              $item = new admin_setting_heading(
 784                  'bigbluebuttonbn_config_muteonstart',
 785                  '',
 786                  get_string('config_muteonstart_description', 'bigbluebuttonbn')
 787              );
 788              $muteonstartsetting->add($item);
 789              $item = new admin_setting_configcheckbox(
 790                  'bigbluebuttonbn_muteonstart_default',
 791                  get_string('config_muteonstart_default', 'bigbluebuttonbn'),
 792                  get_string('config_muteonstart_default_description', 'bigbluebuttonbn'),
 793                  0
 794              );
 795              $this->add_conditional_element(
 796                  'muteonstart_default',
 797                  $item,
 798                  $muteonstartsetting
 799              );
 800              $item = new admin_setting_configcheckbox(
 801                  'bigbluebuttonbn_muteonstart_editable',
 802                  get_string('config_muteonstart_editable', 'bigbluebuttonbn'),
 803                  get_string('config_muteonstart_editable_description', 'bigbluebuttonbn'),
 804                  0
 805              );
 806              $this->add_conditional_element(
 807                  'muteonstart_editable',
 808                  $item,
 809                  $muteonstartsetting
 810              );
 811          }
 812          $this->admin->add($this->parent, $muteonstartsetting);
 813      }
 814  
 815      /**
 816       * Helper function to render lock settings.
 817       */
 818      protected function add_lock_settings(): void {
 819          $lockingsetting = new admin_settingpage(
 820              "{$this->sectionnameprefix}_locksettings",
 821              get_string('config_locksettings', 'bigbluebuttonbn'),
 822              'moodle/site:config',
 823              !((boolean) setting_validator::section_lock_shown()) && ($this->moduleenabled)
 824          );
 825          // Configuration for various lock settings for meetings.
 826          if ($this->admin->fulltree) {
 827              $this->add_lock_setting_from_name('disablecam', $lockingsetting);
 828              $this->add_lock_setting_from_name('disablemic', $lockingsetting);
 829              $this->add_lock_setting_from_name('disableprivatechat', $lockingsetting);
 830              $this->add_lock_setting_from_name('disablepublicchat', $lockingsetting);
 831              $this->add_lock_setting_from_name('disablenote', $lockingsetting);
 832              $this->add_lock_setting_from_name('hideuserlist', $lockingsetting);
 833          }
 834          $this->admin->add($this->parent, $lockingsetting);
 835      }
 836  
 837      /**
 838       * Helper function renders setting if the feature is enabled.
 839       *
 840       * @param string $settingname
 841       * @param admin_settingpage $lockingsetting The parent settingpage to add to
 842       */
 843      protected function add_lock_setting_from_name(string $settingname, admin_settingpage $lockingsetting): void {
 844          $validatorname = "section_{$settingname}_shown";
 845          if ((boolean) setting_validator::$validatorname()) {
 846              // Configuration for BigBlueButton.
 847              $item = new admin_setting_configcheckbox(
 848                      'bigbluebuttonbn_' . $settingname . '_default',
 849                      get_string('config_' . $settingname . '_default', 'bigbluebuttonbn'),
 850                      get_string('config_' . $settingname . '_default_description', 'bigbluebuttonbn'),
 851                      config::defaultvalue($settingname . '_default')
 852              );
 853              $this->add_conditional_element(
 854                      $settingname . '_default',
 855                      $item,
 856                      $lockingsetting
 857              );
 858              $item = new admin_setting_configcheckbox(
 859                      'bigbluebuttonbn_' . $settingname . '_editable',
 860                      get_string('config_' . $settingname . '_editable', 'bigbluebuttonbn'),
 861                      get_string('config_' . $settingname . '_editable_description', 'bigbluebuttonbn'),
 862                      config::defaultvalue($settingname . '_editable')
 863              );
 864              $this->add_conditional_element(
 865                      $settingname . '_editable',
 866                      $item,
 867                      $lockingsetting
 868              );
 869          }
 870      }
 871  
 872      /**
 873       * Helper function renders extended settings if any of the features there is enabled.
 874       */
 875      protected function add_extended_settings(): void {
 876          // Configuration for extended capabilities.
 877          $extendedcapabilitiessetting = new admin_settingpage(
 878              "{$this->sectionnameprefix}_extendedcapabilities",
 879              get_string('config_extended_capabilities', 'bigbluebuttonbn'),
 880              'moodle/site:config',
 881              !((boolean) setting_validator::section_settings_extended_shown()) && ($this->moduleenabled)
 882          );
 883  
 884          if ($this->admin->fulltree) {
 885              $item = new admin_setting_heading(
 886                  'bigbluebuttonbn_config_extended_capabilities',
 887                  '',
 888                  get_string('config_extended_capabilities_description', 'bigbluebuttonbn')
 889              );
 890              $extendedcapabilitiessetting->add($item);
 891              // UI for 'notify users when recording ready' feature.
 892              $item = new admin_setting_configcheckbox(
 893                  'bigbluebuttonbn_recordingready_enabled',
 894                  get_string('config_recordingready_enabled', 'bigbluebuttonbn'),
 895                  get_string('config_recordingready_enabled_description', 'bigbluebuttonbn'),
 896                  0
 897              );
 898              $this->add_conditional_element(
 899                  'recordingready_enabled',
 900                  $item,
 901                  $extendedcapabilitiessetting
 902              );
 903          }
 904          $this->admin->add($this->parent, $extendedcapabilitiessetting);
 905          // Configuration for extended BN capabilities should go here.
 906      }
 907  
 908      /**
 909       * Helper function renders experimental settings if any of the features there is enabled.
 910       */
 911      protected function add_experimental_settings(): void {
 912          // Configuration for experimental features should go here.
 913          $experimentalfeaturessetting = new admin_settingpage(
 914              "{$this->sectionnameprefix}_experimentalfeatures",
 915              get_string('config_experimental_features', 'bigbluebuttonbn'),
 916              'moodle/site:config',
 917              !((boolean) setting_validator::section_settings_extended_shown()) && ($this->moduleenabled)
 918          );
 919  
 920          if ($this->admin->fulltree) {
 921              $item = new admin_setting_heading(
 922                  'bigbluebuttonbn_config_experimental_features',
 923                  '',
 924                  get_string('config_experimental_features_description', 'bigbluebuttonbn')
 925              );
 926              $experimentalfeaturessetting->add($item);
 927              // UI for 'register meeting events' feature.
 928              $item = new admin_setting_configcheckbox(
 929                  'bigbluebuttonbn_meetingevents_enabled',
 930                  get_string('config_meetingevents_enabled', 'bigbluebuttonbn'),
 931                  get_string('config_meetingevents_enabled_description', 'bigbluebuttonbn'),
 932                  0
 933              );
 934              $this->add_conditional_element(
 935                  'meetingevents_enabled',
 936                  $item,
 937                  $experimentalfeaturessetting
 938              );
 939              // UI for 'register meeting events' feature.
 940              $item = new admin_setting_configcheckbox(
 941                  'bigbluebuttonbn_guestaccess_enabled',
 942                  get_string('config_guestaccess_enabled', 'bigbluebuttonbn'),
 943                  get_string('config_guestaccess_enabled_description', 'bigbluebuttonbn'),
 944                  0
 945              );
 946              $this->add_conditional_element(
 947                  'guestaccess_enabled',
 948                  $item,
 949                  $experimentalfeaturessetting
 950              );
 951          }
 952          $this->admin->add($this->parent, $experimentalfeaturessetting);
 953      }
 954  
 955      /**
 956       * Process reset cache.
 957       */
 958      protected function reset_cache() {
 959          // Reset serverinfo cache.
 960          cache_helper::purge_by_event('mod_bigbluebuttonbn/serversettingschanged');
 961      }
 962  }