Differences Between: [Versions 400 and 401] [Versions 400 and 402] [Versions 400 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\local; 18 19 use mod_bigbluebuttonbn\instance; 20 use mod_bigbluebuttonbn\recording; 21 22 /** 23 * Handles the global configuration based on config.php. 24 * 25 * @package mod_bigbluebuttonbn 26 * @copyright 2010 onwards, Blindside Networks Inc 27 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 28 * @author Jesus Federico (jesus [at] blindsidenetworks [dt] com) 29 */ 30 class config { 31 32 /** @var string Default bigbluebutton server url */ 33 public const DEFAULT_SERVER_URL = 'https://test-moodle.blindsidenetworks.com/bigbluebutton/'; 34 35 /** @var string Default bigbluebutton server shared secret */ 36 public const DEFAULT_SHARED_SECRET = '0b21fcaf34673a8c3ec8ed877d76ae34'; 37 38 /** @var string Default bigbluebutton data processing agreement url */ 39 public const DEFAULT_DPA_URL = 'https://blindsidenetworks.com/dpa-moodle-free-tier'; 40 41 /** 42 * Returns moodle version. 43 * 44 * @return string 45 */ 46 protected static function get_moodle_version_major(): string { 47 global $CFG; 48 $versionarray = explode('.', $CFG->version); 49 return $versionarray[0]; 50 } 51 52 /** 53 * Returns configuration default values. 54 * 55 * @return array 56 */ 57 protected static function defaultvalues(): array { 58 return [ 59 'server_url' => self::DEFAULT_SERVER_URL, 60 'shared_secret' => self::DEFAULT_SHARED_SECRET, 61 'voicebridge_editable' => false, 62 'importrecordings_enabled' => false, 63 'importrecordings_from_deleted_enabled' => false, 64 'waitformoderator_default' => false, 65 'waitformoderator_editable' => true, 66 'waitformoderator_ping_interval' => '10', 67 'waitformoderator_cache_ttl' => '60', 68 'userlimit_default' => '0', 69 'userlimit_editable' => false, 70 'preuploadpresentation_editable' => false, 71 'recordingready_enabled' => false, 72 'recordingstatus_enabled' => false, 73 'meetingevents_enabled' => false, 74 'participant_moderator_default' => '0', 75 'scheduled_pre_opening' => '10', 76 'recordings_enabled' => true, 77 'recordings_deleted_default' => false, 78 'recordings_deleted_editable' => false, 79 'recordings_imported_default' => false, 80 'recordings_imported_editable' => false, 81 'recordings_preview_default' => true, 82 'recordings_preview_editable' => false, 83 'recording_default' => true, 84 'recording_editable' => true, 85 'recording_refresh_period' => recording::RECORDING_REFRESH_DEFAULT_PERIOD, 86 'recording_all_from_start_default' => false, 87 'recording_all_from_start_editable' => false, 88 'recording_hide_button_default' => false, 89 'recording_hide_button_editable' => false, 90 'recording_protect_editable' => true, 91 'general_warning_message' => '', 92 'general_warning_roles' => 'editingteacher,teacher', 93 'general_warning_box_type' => 'info', 94 'general_warning_button_text' => '', 95 'general_warning_button_href' => '', 96 'general_warning_button_class' => '', 97 'muteonstart_default' => false, 98 'muteonstart_editable' => false, 99 'disablecam_default' => false, 100 'disablecam_editable' => true, 101 'disablemic_default' => false, 102 'disablemic_editable' => true, 103 'disableprivatechat_default' => false, 104 'disableprivatechat_editable' => true, 105 'disablepublicchat_default' => false, 106 'disablepublicchat_editable' => true, 107 'disablenote_default' => false, 108 'disablenote_editable' => true, 109 'hideuserlist_default' => false, 110 'hideuserlist_editable' => true, 111 'lockonjoin_default' => true, 112 'lockonjoin_editable' => false, 113 'welcome_default' => '', 114 'default_dpa_accepted' => false, 115 ]; 116 } 117 118 /** 119 * Returns default value for an specific setting. 120 * 121 * @param string $setting 122 * @return string|null 123 */ 124 public static function defaultvalue(string $setting): ?string { 125 $defaultvalues = self::defaultvalues(); 126 if (!array_key_exists($setting, $defaultvalues)) { 127 return null; 128 } 129 return $defaultvalues[$setting]; 130 } 131 132 /** 133 * Returns value for an specific setting. 134 * 135 * @param string $setting 136 * @return string 137 */ 138 public static function get(string $setting): string { 139 global $CFG; 140 if (isset($CFG->bigbluebuttonbn[$setting])) { 141 return (string) $CFG->bigbluebuttonbn[$setting]; 142 } 143 if (isset($CFG->{'bigbluebuttonbn_' . $setting})) { 144 return (string) $CFG->{'bigbluebuttonbn_' . $setting}; 145 } 146 return self::defaultvalue($setting); 147 } 148 149 /** 150 * Validates if recording settings are enabled. 151 * 152 * @return bool 153 */ 154 public static function recordings_enabled(): bool { 155 return (boolean) self::get('recordings_enabled'); 156 } 157 158 /** 159 * Validates if imported recording settings are enabled. 160 * 161 * @return bool 162 */ 163 public static function importrecordings_enabled(): bool { 164 return (boolean) self::get('importrecordings_enabled'); 165 } 166 167 /** 168 * Wraps current settings in an array. 169 * 170 * @return array 171 */ 172 public static function get_options(): array { 173 return [ 174 'version_major' => self::get_moodle_version_major(), 175 'voicebridge_editable' => self::get('voicebridge_editable'), 176 'importrecordings_enabled' => self::get('importrecordings_enabled'), 177 'importrecordings_from_deleted_enabled' => self::get('importrecordings_from_deleted_enabled'), 178 'waitformoderator_default' => self::get('waitformoderator_default'), 179 'waitformoderator_editable' => self::get('waitformoderator_editable'), 180 'userlimit_default' => self::get('userlimit_default'), 181 'userlimit_editable' => self::get('userlimit_editable'), 182 'preuploadpresentation_editable' => self::get('preuploadpresentation_editable'), 183 'recordings_enabled' => self::get('recordings_enabled'), 184 'meetingevents_enabled' => self::get('meetingevents_enabled'), 185 'recordings_deleted_default' => self::get('recordings_deleted_default'), 186 'recordings_deleted_editable' => self::get('recordings_deleted_editable'), 187 'recordings_imported_default' => self::get('recordings_imported_default'), 188 'recordings_imported_editable' => self::get('recordings_imported_editable'), 189 'recordings_preview_default' => self::get('recordings_preview_default'), 190 'recordings_preview_editable' => self::get('recordings_preview_editable'), 191 'recording_default' => self::get('recording_default'), 192 'recording_editable' => self::get('recording_editable'), 193 'recording_refresh_period' => self::get('recording_refresh_period'), 194 'recording_all_from_start_default' => self::get('recording_all_from_start_default'), 195 'recording_all_from_start_editable' => self::get('recording_all_from_start_editable'), 196 'recording_hide_button_default' => self::get('recording_hide_button_default'), 197 'recording_hide_button_editable' => self::get('recording_hide_button_editable'), 198 'recording_protect_editable' => self::get('recording_protect_editable'), 199 'general_warning_message' => self::get('general_warning_message'), 200 'general_warning_box_type' => self::get('general_warning_box_type'), 201 'general_warning_button_text' => self::get('general_warning_button_text'), 202 'general_warning_button_href' => self::get('general_warning_button_href'), 203 'general_warning_button_class' => self::get('general_warning_button_class'), 204 'muteonstart_editable' => self::get('muteonstart_editable'), 205 'muteonstart_default' => self::get('muteonstart_default'), 206 'disablecam_editable' => self::get('disablecam_editable'), 207 'disablecam_default' => self::get('disablecam_default'), 208 'disablemic_editable' => self::get('disablemic_editable'), 209 'disablemic_default' => self::get('disablemic_default'), 210 'disableprivatechat_editable' => self::get('disableprivatechat_editable'), 211 'disableprivatechat_default' => self::get('disableprivatechat_default'), 212 'disablepublicchat_editable' => self::get('disablepublicchat_editable'), 213 'disablepublicchat_default' => self::get('disablepublicchat_default'), 214 'disablenote_editable' => self::get('disablenote_editable'), 215 'disablenote_default' => self::get('disablenote_default'), 216 'hideuserlist_editable' => self::get('hideuserlist_editable'), 217 'hideuserlist_default' => self::get('hideuserlist_default'), 218 'lockonjoin_editable' => self::get('lockonjoin_editable'), 219 'lockonjoin_default' => self::get('lockonjoin_default'), 220 'welcome_default' => self::get('welcome_default'), 221 'welcome_editable' => self::get('welcome_editable'), 222 ]; 223 } 224 225 /** 226 * Helper function returns an array with enabled features for an specific profile type. 227 * 228 * @param array $typeprofiles 229 * @param string|null $type 230 * 231 * @return array 232 */ 233 public static function get_enabled_features(array $typeprofiles, ?string $type = null): array { 234 $enabledfeatures = []; 235 $features = $typeprofiles[instance::TYPE_ALL]['features']; 236 if (!is_null($type) && key_exists($type, $typeprofiles)) { 237 $features = $typeprofiles[$type]['features']; 238 } 239 $enabledfeatures['showroom'] = (in_array('all', $features) || in_array('showroom', $features)); 240 // Evaluates if recordings are enabled for the Moodle site. 241 $enabledfeatures['showrecordings'] = false; 242 if (self::recordings_enabled()) { 243 $enabledfeatures['showrecordings'] = (in_array('all', $features) || in_array('showrecordings', $features)); 244 } 245 $enabledfeatures['importrecordings'] = false; 246 if (self::importrecordings_enabled()) { 247 $enabledfeatures['importrecordings'] = (in_array('all', $features) || in_array('importrecordings', $features)); 248 } 249 return $enabledfeatures; 250 } 251 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body