Differences Between: [Versions 310 and 402] [Versions 311 and 402] [Versions 39 and 402] [Versions 400 and 402] [Versions 401 and 402] [Versions 402 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 /** 18 * This file defines settingpages and externalpages under the "courses" category 19 * 20 * @package core 21 * @copyright 2002 onwards Martin Dougiamas (http://dougiamas.com) 22 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 23 */ 24 25 defined('MOODLE_INTERNAL') || die(); 26 27 require_once($CFG->libdir . '/pdflib.php'); 28 29 use core_admin\local\settings\filesize; 30 31 $capabilities = array( 32 'moodle/backup:backupcourse', 33 'moodle/category:manage', 34 'moodle/course:create', 35 'moodle/site:approvecourse', 36 'moodle/restore:restorecourse' 37 ); 38 if ($hassiteconfig or has_any_capability($capabilities, $systemcontext)) { 39 // Speedup for non-admins, add all caps used on this page. 40 $ADMIN->add('courses', 41 new admin_externalpage('coursemgmt', new lang_string('coursemgmt', 'admin'), 42 $CFG->wwwroot . '/course/management.php', 43 array('moodle/category:manage', 'moodle/course:create') 44 ) 45 ); 46 $ADMIN->add('courses', 47 new admin_externalpage('course_customfield', new lang_string('course_customfield', 'admin'), 48 $CFG->wwwroot . '/course/customfield.php', 49 array('moodle/course:configurecustomfields') 50 ) 51 ); 52 $ADMIN->add('courses', 53 new admin_externalpage('addcategory', new lang_string('addcategory', 'admin'), 54 new moodle_url('/course/editcategory.php', array('parent' => 0)), 55 array('moodle/category:manage') 56 ) 57 ); 58 $ADMIN->add('courses', 59 new admin_externalpage('addnewcourse', new lang_string('addnewcourse'), 60 new moodle_url('/course/edit.php', array('category' => 0)), 61 array('moodle/category:manage') 62 ) 63 ); 64 $ADMIN->add('courses', 65 new admin_externalpage('restorecourse', new lang_string('restorecourse', 'admin'), 66 new moodle_url('/backup/restorefile.php', array('contextid' => context_system::instance()->id)), 67 array('moodle/restore:restorecourse') 68 ) 69 ); 70 71 // Course Default Settings Page. 72 // NOTE: these settings must be applied after all other settings because they depend on them. 73 74 // Main course settings. 75 $temp = new admin_settingpage('coursesettings', new lang_string('coursesettings')); 76 require_once($CFG->dirroot.'/course/lib.php'); 77 78 $choices = array(); 79 $choices['0'] = new lang_string('hide'); 80 $choices['1'] = new lang_string('show'); 81 $temp->add(new admin_setting_configselect('moodlecourse/visible', new lang_string('visible'), new lang_string('visible_help'), 82 1, $choices)); 83 84 // Enable/disable download course content. 85 $choices = [ 86 DOWNLOAD_COURSE_CONTENT_DISABLED => new lang_string('no'), 87 DOWNLOAD_COURSE_CONTENT_ENABLED => new lang_string('yes'), 88 ]; 89 $downloadcontentsitedefault = new admin_setting_configselect('moodlecourse/downloadcontentsitedefault', 90 new lang_string('enabledownloadcoursecontent', 'course'), 91 new lang_string('downloadcoursecontent_help', 'course'), 0, $choices); 92 $downloadcontentsitedefault->add_dependent_on('downloadcoursecontentallowed'); 93 $temp->add($downloadcontentsitedefault); 94 95 $temp->add( 96 new admin_setting_configtext( 97 'moodlecourse/participantsperpage', 98 new lang_string('participants:perpage', 'course'), 99 new lang_string('participants:perpage_help', 'course'), 100 20 101 ) 102 ); 103 104 // Course format. 105 $temp->add(new admin_setting_heading('courseformathdr', new lang_string('type_format', 'plugin'), '')); 106 107 $courseformats = get_sorted_course_formats(true); 108 $formcourseformats = array(); 109 foreach ($courseformats as $courseformat) { 110 $formcourseformats[$courseformat] = new lang_string('pluginname', "format_$courseformat"); 111 } 112 $temp->add(new admin_setting_configselect('moodlecourse/format', new lang_string('format'), new lang_string('coursehelpformat'), 113 'topics', $formcourseformats)); 114 115 $temp->add(new admin_setting_configtext('moodlecourse/maxsections', new lang_string('maxnumberweeks'), 116 new lang_string('maxnumberweeks_desc'), 52)); 117 118 $temp->add(new admin_settings_num_course_sections('moodlecourse/numsections', new lang_string('numberweeks'), 119 new lang_string('coursehelpnumberweeks'), 4)); 120 121 $choices = array(); 122 $choices['0'] = new lang_string('hiddensectionscollapsed'); 123 $choices['1'] = new lang_string('hiddensectionsinvisible'); 124 $temp->add(new admin_setting_configselect('moodlecourse/hiddensections', new lang_string('hiddensections'), 125 new lang_string('coursehelphiddensections'), 1, $choices)); 126 127 $choices = array(); 128 $choices[COURSE_DISPLAY_SINGLEPAGE] = new lang_string('coursedisplay_single'); 129 $choices[COURSE_DISPLAY_MULTIPAGE] = new lang_string('coursedisplay_multi'); 130 $temp->add(new admin_setting_configselect('moodlecourse/coursedisplay', new lang_string('coursedisplay'), 131 new lang_string('coursedisplay_help'), COURSE_DISPLAY_SINGLEPAGE, $choices)); 132 133 $temp->add(new admin_setting_configcheckbox('moodlecourse/courseenddateenabled', get_string('courseenddateenabled'), 134 get_string('courseenddateenabled_desc'), 1)); 135 136 $temp->add(new admin_setting_configduration('moodlecourse/courseduration', get_string('courseduration'), 137 get_string('courseduration_desc'), YEARSECS)); 138 139 // Appearance. 140 $temp->add(new admin_setting_heading('appearancehdr', new lang_string('appearance'), '')); 141 142 $languages = array(); 143 $languages[''] = new lang_string('forceno'); 144 $languages += get_string_manager()->get_list_of_translations(); 145 $temp->add(new admin_setting_configselect('moodlecourse/lang', new lang_string('forcelanguage'), '', key($languages), 146 $languages)); 147 148 $options = range(0, 10); 149 $temp->add(new admin_setting_configselect('moodlecourse/newsitems', new lang_string('newsitemsnumber'), 150 new lang_string('coursehelpnewsitemsnumber'), 5, $options)); 151 $temp->add(new admin_setting_configselect('moodlecourse/showgrades', new lang_string('showgrades'), 152 new lang_string('coursehelpshowgrades'), 1, array(0 => new lang_string('no'), 1 => new lang_string('yes')))); 153 $temp->add(new admin_setting_configselect('moodlecourse/showreports', new lang_string('showreports'), '', 0, 154 array(0 => new lang_string('no'), 1 => new lang_string('yes')))); 155 $temp->add(new admin_setting_configselect('moodlecourse/showactivitydates', 156 new lang_string('showactivitydates'), 157 new lang_string('showactivitydates_help'), 1, [ 158 0 => new lang_string('no'), 159 1 => new lang_string('yes') 160 ] 161 )); 162 163 // Files and uploads. 164 $temp->add(new admin_setting_heading('filesanduploadshdr', new lang_string('filesanduploads'), '')); 165 166 if (!empty($CFG->legacyfilesinnewcourses)) { 167 $choices = array('0'=>new lang_string('no'), '2'=>new lang_string('yes')); 168 $temp->add(new admin_setting_configselect('moodlecourse/legacyfiles', new lang_string('courselegacyfiles'), 169 new lang_string('courselegacyfiles_help'), key($choices), $choices)); 170 } 171 172 $currentmaxbytes = get_config('moodlecourse', 'maxbytes'); 173 if (isset($CFG->maxbytes)) { 174 $choices = get_max_upload_sizes($CFG->maxbytes, 0, 0, $currentmaxbytes); 175 } else { 176 $choices = get_max_upload_sizes(0, 0, 0, $currentmaxbytes); 177 } 178 $temp->add(new admin_setting_configselect('moodlecourse/maxbytes', new lang_string('maximumupload'), 179 new lang_string('coursehelpmaximumupload'), key($choices), $choices)); 180 181 if (!empty($CFG->enablepdfexportfont)) { 182 $pdf = new \pdf; 183 $fontlist = $pdf->get_export_fontlist(); 184 // Show the option if the font is defined more than one. 185 if (count($fontlist) > 1) { 186 $temp->add(new admin_setting_configselect('moodlecourse/pdfexportfont', 187 new lang_string('pdfexportfont', 'course'), 188 new lang_string('pdfexportfont_help', 'course'), 189 'freesans', $fontlist 190 )); 191 } 192 } 193 194 // Completion tracking. 195 $temp->add(new admin_setting_heading('progress', new lang_string('completion','completion'), '')); 196 $temp->add(new admin_setting_configselect('moodlecourse/enablecompletion', new lang_string('completion', 'completion'), 197 new lang_string('enablecompletion_help', 'completion'), 1, array(0 => new lang_string('no'), 1 => new lang_string('yes')))); 198 199 // Display completion conditions. 200 $temp->add(new admin_setting_configselect('moodlecourse/showcompletionconditions', 201 new lang_string('showcompletionconditions', 'completion'), 202 new lang_string('showcompletionconditions_help', 'completion'), 1, [ 203 0 => new lang_string('no'), 204 1 => new lang_string('yes') 205 ] 206 )); 207 208 // Groups. 209 $temp->add(new admin_setting_heading('groups', new lang_string('groups', 'group'), '')); 210 $choices = array(); 211 $choices[NOGROUPS] = new lang_string('groupsnone', 'group'); 212 $choices[SEPARATEGROUPS] = new lang_string('groupsseparate', 'group'); 213 $choices[VISIBLEGROUPS] = new lang_string('groupsvisible', 'group'); 214 $temp->add(new admin_setting_configselect('moodlecourse/groupmode', new lang_string('groupmode'), '', key($choices),$choices)); 215 $temp->add(new admin_setting_configselect('moodlecourse/groupmodeforce', new lang_string('force'), new lang_string('coursehelpforce'), 0,array(0 => new lang_string('no'), 1 => new lang_string('yes')))); 216 217 $ADMIN->add('courses', $temp); 218 219 // Download course content. 220 $downloadcoursedefaulturl = new moodle_url('/admin/settings.php', ['section' => 'coursesettings']); 221 $temp = new admin_settingpage('downloadcoursecontent', new lang_string('downloadcoursecontent', 'course')); 222 $temp->add(new admin_setting_configcheckbox('downloadcoursecontentallowed', 223 new lang_string('downloadcoursecontentallowed', 'admin'), 224 new lang_string('downloadcoursecontentallowed_desc', 'admin', $downloadcoursedefaulturl->out()), 0)); 225 226 // 50MB default maximum size per file when downloading course content. 227 $defaultmaxdownloadsize = 50 * filesize::UNIT_MB; 228 $temp->add(new filesize('maxsizeperdownloadcoursefile', new lang_string('maxsizeperdownloadcoursefile', 'admin'), 229 new lang_string('maxsizeperdownloadcoursefile_desc', 'admin'), $defaultmaxdownloadsize, filesize::UNIT_MB)); 230 $temp->hide_if('maxsizeperdownloadcoursefile', 'downloadcoursecontentallowed'); 231 232 $ADMIN->add('courses', $temp); 233 234 // "courserequests" settingpage. 235 $temp = new admin_settingpage('courserequest', new lang_string('courserequest')); 236 $temp->add(new admin_setting_configcheckbox('enablecourserequests', 237 new lang_string('enablecourserequests', 'admin'), 238 new lang_string('configenablecourserequests', 'admin'), 1)); 239 $temp->add(new admin_settings_coursecat_select('defaultrequestcategory', 240 new lang_string('defaultrequestcategory', 'admin'), 241 new lang_string('configdefaultrequestcategory', 'admin'), 1)); 242 $temp->add(new admin_setting_configcheckbox('lockrequestcategory', 243 new lang_string('lockrequestcategory', 'admin'), 244 new lang_string('configlockrequestcategory', 'admin'), 0)); 245 $temp->add(new admin_setting_users_with_capability('courserequestnotify', new lang_string('courserequestnotify', 'admin'), new lang_string('configcourserequestnotify2', 'admin'), array(), 'moodle/site:approvecourse')); 246 $ADMIN->add('courses', $temp); 247 248 // Pending course requests. 249 if (!empty($CFG->enablecourserequests)) { 250 $ADMIN->add('courses', new admin_externalpage('coursespending', new lang_string('pendingrequests'), 251 $CFG->wwwroot . '/course/pending.php', array('moodle/site:approvecourse'))); 252 } 253 254 // Add a category for the Activity Chooser. 255 $ADMIN->add('courses', new admin_category('activitychooser', new lang_string('activitychoosercategory', 'course'))); 256 $temp = new admin_settingpage('activitychoosersettings', new lang_string('activitychoosersettings', 'course')); 257 // Tab mode for the activity chooser. 258 $temp->add( 259 new admin_setting_configselect( 260 'activitychoosertabmode', 261 new lang_string('activitychoosertabmode', 'course'), 262 new lang_string('activitychoosertabmode_desc', 'course'), 263 3, 264 [ 265 3 => new lang_string('activitychoosertabmodefour', 'course'), 266 4 => new lang_string('activitychoosertabmodefive', 'course'), 267 5 => new lang_string('activitychoosertabmodesix', 'course'), 268 0 => new lang_string('activitychoosertabmodeone', 'course'), 269 1 => new lang_string('activitychoosertabmodetwo', 'course'), 270 2 => new lang_string('activitychoosertabmodethree', 'course'), 271 ] 272 ) 273 ); 274 275 // Build a list of plugins that use the footer callback. 276 $pluginswithfunction = get_plugins_with_function('custom_chooser_footer', 'lib.php'); 277 $pluginsoptions = []; 278 $pluginsoptions[COURSE_CHOOSER_FOOTER_NONE] = get_string('activitychooserhidefooter', 'course'); 279 if ($pluginswithfunction) { 280 foreach ($pluginswithfunction as $plugintype => $plugins) { 281 foreach ($plugins as $pluginname => $pluginfunction) { 282 $plugin = $plugintype.'_'.$pluginname; 283 $pluginsoptions[$plugin] = get_string('pluginname', $plugin); 284 } 285 } 286 } 287 288 // Select what plugin to show in the footer. 289 $temp->add( 290 new admin_setting_configselect( 291 'activitychooseractivefooter', 292 new lang_string('activitychooseractivefooter', 'course'), 293 new lang_string('activitychooseractivefooter_desc', 'course'), 294 COURSE_CHOOSER_FOOTER_NONE, 295 $pluginsoptions 296 ) 297 ); 298 299 $ADMIN->add('activitychooser', $temp); 300 $ADMIN->add('activitychooser', 301 new admin_externalpage('activitychooserrecommended', new lang_string('activitychooserrecommendations', 'course'), 302 new moodle_url('/course/recommendations.php'), 303 array('moodle/course:recommendactivity') 304 ) 305 ); 306 307 // Add a category for backups. 308 $ADMIN->add('courses', new admin_category('backups', new lang_string('backups','admin'))); 309 310 // Create a page for general backups configuration and defaults. 311 $temp = new admin_settingpage('backupgeneralsettings', new lang_string('generalbackdefaults', 'backup'), 'moodle/backup:backupcourse'); 312 313 // General configuration section. 314 $temp->add(new admin_setting_configselect('backup/loglifetime', new lang_string('loglifetime', 'backup'), new lang_string('configloglifetime', 'backup'), 30, array( 315 1 => new lang_string('numdays', '', 1), 316 2 => new lang_string('numdays', '', 2), 317 3 => new lang_string('numdays', '', 3), 318 5 => new lang_string('numdays', '', 5), 319 7 => new lang_string('numdays', '', 7), 320 10 => new lang_string('numdays', '', 10), 321 14 => new lang_string('numdays', '', 14), 322 20 => new lang_string('numdays', '', 20), 323 30 => new lang_string('numdays', '', 30), 324 60 => new lang_string('numdays', '', 60), 325 90 => new lang_string('numdays', '', 90), 326 120 => new lang_string('numdays', '', 120), 327 180 => new lang_string('numdays', '', 180), 328 365 => new lang_string('numdays', '', 365) 329 ))); 330 331 // General defaults section. 332 $temp->add(new admin_setting_heading('generalsettings', new lang_string('generalsettings', 'backup'), '')); 333 $temp->add(new admin_setting_configcheckbox_with_lock('backup/backup_general_users', new lang_string('generalusers','backup'), new lang_string('configgeneralusers','backup'), array('value'=>1, 'locked'=>0))); 334 $temp->add(new admin_setting_configcheckbox_with_lock('backup/backup_general_anonymize', new lang_string('generalanonymize','backup'), new lang_string('configgeneralanonymize','backup'), array('value'=>0, 'locked'=>0))); 335 $temp->add(new admin_setting_configcheckbox_with_lock('backup/backup_general_role_assignments', new lang_string('generalroleassignments','backup'), new lang_string('configgeneralroleassignments','backup'), array('value'=>1, 'locked'=>0))); 336 $temp->add(new admin_setting_configcheckbox_with_lock('backup/backup_general_activities', new lang_string('generalactivities','backup'), new lang_string('configgeneralactivities','backup'), array('value'=>1, 'locked'=>0))); 337 $temp->add(new admin_setting_configcheckbox_with_lock('backup/backup_general_blocks', new lang_string('generalblocks','backup'), new lang_string('configgeneralblocks','backup'), array('value'=>1, 'locked'=>0))); 338 $temp->add(new admin_setting_configcheckbox_with_lock( 339 'backup/backup_general_files', 340 new lang_string('generalfiles', 'backup'), 341 new lang_string('configgeneralfiles', 'backup'), 342 array('value' => '1', 'locked' => 0))); 343 $temp->add(new admin_setting_configcheckbox_with_lock('backup/backup_general_filters', new lang_string('generalfilters','backup'), new lang_string('configgeneralfilters','backup'), array('value'=>1, 'locked'=>0))); 344 $temp->add(new admin_setting_configcheckbox_with_lock('backup/backup_general_comments', new lang_string('generalcomments','backup'), new lang_string('configgeneralcomments','backup'), array('value'=>1, 'locked'=>0))); 345 $temp->add(new admin_setting_configcheckbox_with_lock('backup/backup_general_badges', new lang_string('generalbadges','backup'), new lang_string('configgeneralbadges','backup'), array('value'=>1,'locked'=>0))); 346 $temp->add(new admin_setting_configcheckbox_with_lock('backup/backup_general_calendarevents', new lang_string('generalcalendarevents','backup'), new lang_string('configgeneralcalendarevents','backup'), array('value'=>1, 'locked'=>0))); 347 $temp->add(new admin_setting_configcheckbox_with_lock('backup/backup_general_userscompletion', new lang_string('generaluserscompletion','backup'), new lang_string('configgeneraluserscompletion','backup'), array('value'=>1, 'locked'=>0))); 348 $temp->add(new admin_setting_configcheckbox_with_lock('backup/backup_general_logs', new lang_string('generallogs','backup'), new lang_string('configgenerallogs','backup'), array('value'=>0, 'locked'=>0))); 349 $temp->add(new admin_setting_configcheckbox_with_lock('backup/backup_general_histories', new lang_string('generalhistories','backup'), new lang_string('configgeneralhistories','backup'), array('value'=>0, 'locked'=>0))); 350 $temp->add(new admin_setting_configcheckbox_with_lock('backup/backup_general_questionbank', new lang_string('generalquestionbank','backup'), new lang_string('configgeneralquestionbank','backup'), array('value'=>1, 'locked'=>0))); 351 $temp->add(new admin_setting_configcheckbox_with_lock('backup/backup_general_groups', 352 new lang_string('generalgroups', 'backup'), new lang_string('configgeneralgroups', 'backup'), 353 array('value' => 1, 'locked' => 0))); 354 $temp->add(new admin_setting_configcheckbox_with_lock('backup/backup_general_competencies', new lang_string('generalcompetencies','backup'), new lang_string('configgeneralcompetencies','backup'), array('value'=>1, 'locked'=>0))); 355 $temp->add(new admin_setting_configcheckbox_with_lock('backup/backup_general_contentbankcontent', 356 new lang_string('generalcontentbankcontent', 'backup'), 357 new lang_string('configgeneralcontentbankcontent', 'backup'), 358 ['value' => 1, 'locked' => 0]) 359 ); 360 $temp->add(new admin_setting_configcheckbox_with_lock('backup/backup_general_xapistate', 361 new lang_string('generalxapistate', 'backup'), 362 new lang_string('configgeneralxapistate', 'backup'), 363 ['value' => 1, 'locked' => 0]) 364 ); 365 366 367 $temp->add(new admin_setting_configcheckbox_with_lock('backup/backup_general_legacyfiles', 368 new lang_string('generallegacyfiles', 'backup'), 369 new lang_string('configlegacyfiles', 'backup'), array('value' => 1, 'locked' => 0))); 370 $ADMIN->add('backups', $temp); 371 372 // Create a page for general import configuration and defaults. 373 $temp = new admin_settingpage('importgeneralsettings', new lang_string('importgeneralsettings', 'backup'), 'moodle/backup:backupcourse'); 374 $temp->add(new admin_setting_configtext('backup/import_general_maxresults', new lang_string('importgeneralmaxresults', 'backup'), new lang_string('importgeneralmaxresults_desc', 'backup'), 10)); 375 $temp->add(new admin_setting_configcheckbox('backup/import_general_duplicate_admin_allowed', 376 new lang_string('importgeneralduplicateadminallowed', 'backup'), 377 new lang_string('importgeneralduplicateadminallowed_desc', 'backup'), 0)); 378 379 // Import defaults section. 380 $temp->add(new admin_setting_heading('importsettings', new lang_string('importsettings', 'backup'), '')); 381 $temp->add(new admin_setting_configcheckbox_with_lock( 382 'backup/backup_import_permissions', 383 new lang_string('generalpermissions', 'backup'), 384 new lang_string('configgeneralpermissions', 'backup'), 385 array('value' => 0, 'locked' => 0))); 386 $temp->add(new admin_setting_configcheckbox_with_lock('backup/backup_import_activities', new lang_string('generalactivities','backup'), new lang_string('configgeneralactivities','backup'), array('value'=>1, 'locked'=>0))); 387 $temp->add(new admin_setting_configcheckbox_with_lock('backup/backup_import_blocks', new lang_string('generalblocks','backup'), new lang_string('configgeneralblocks','backup'), array('value'=>1, 'locked'=>0))); 388 $temp->add(new admin_setting_configcheckbox_with_lock('backup/backup_import_filters', new lang_string('generalfilters','backup'), new lang_string('configgeneralfilters','backup'), array('value'=>1, 'locked'=>0))); 389 $temp->add(new admin_setting_configcheckbox_with_lock('backup/backup_import_calendarevents', new lang_string('generalcalendarevents','backup'), new lang_string('configgeneralcalendarevents','backup'), array('value'=>1, 'locked'=>0))); 390 $temp->add(new admin_setting_configcheckbox_with_lock('backup/backup_import_questionbank', new lang_string('generalquestionbank','backup'), new lang_string('configgeneralquestionbank','backup'), array('value'=>1, 'locked'=>0))); 391 $temp->add(new admin_setting_configcheckbox_with_lock('backup/backup_import_groups', 392 new lang_string('generalgroups', 'backup'), new lang_string('configgeneralgroups', 'backup'), 393 array('value' => 1, 'locked' => 0))); 394 $temp->add(new admin_setting_configcheckbox_with_lock('backup/backup_import_competencies', new lang_string('generalcompetencies','backup'), new lang_string('configgeneralcompetencies','backup'), array('value'=>1, 'locked'=>0))); 395 $temp->add(new admin_setting_configcheckbox_with_lock( 396 'backup/backup_import_contentbankcontent', 397 new lang_string('generalcontentbankcontent', 'backup'), 398 new lang_string('configgeneralcontentbankcontent', 'backup'), 399 ['value' => 1, 'locked' => 0]) 400 ); 401 $temp->add(new admin_setting_configcheckbox_with_lock('backup/backup_import_legacyfiles', 402 new lang_string('generallegacyfiles', 'backup'), 403 new lang_string('configlegacyfiles', 'backup'), array('value' => 1, 'locked' => 0))); 404 405 $ADMIN->add('backups', $temp); 406 407 // Create a page for automated backups configuration and defaults. 408 $temp = new admin_settingpage('automated', new lang_string('automatedsetup','backup'), 'moodle/backup:backupcourse'); 409 410 // Automated configuration section. 411 $temp->add(new admin_setting_configselect('backup/backup_auto_active', new lang_string('active'), new lang_string('autoactivedescription', 'backup'), 0, array( 412 0 => new lang_string('autoactivedisabled', 'backup'), 413 1 => new lang_string('autoactiveenabled', 'backup'), 414 2 => new lang_string('autoactivemanual', 'backup') 415 ))); 416 $temp->add(new admin_setting_special_backupdays()); 417 $temp->add(new admin_setting_configtime('backup/backup_auto_hour', 'backup_auto_minute', new lang_string('executeat'), 418 new lang_string('backupexecuteathelp'), array('h' => 0, 'm' => 0))); 419 $storageoptions = array( 420 0 => new lang_string('storagecourseonly', 'backup'), 421 1 => new lang_string('storageexternalonly', 'backup'), 422 2 => new lang_string('storagecourseandexternal', 'backup') 423 ); 424 $temp->add(new admin_setting_configselect('backup/backup_auto_storage', new lang_string('automatedstorage', 'backup'), new lang_string('automatedstoragehelp', 'backup'), 0, $storageoptions)); 425 $temp->add(new admin_setting_special_backup_auto_destination()); 426 427 $maxkeptoptions = array( 428 0 => new lang_string('all'), 1 => '1', 429 2 => '2', 430 3 => '3', 431 4 => '4', 432 5 => '5', 433 10 => '10', 434 20 => '20', 435 30 => '30', 436 40 => '40', 437 50 => '50', 438 100 => '100', 439 200 => '200', 440 300 => '300', 441 400 => '400', 442 500 => '500'); 443 $temp->add(new admin_setting_configselect('backup/backup_auto_max_kept', new lang_string('automatedmaxkept', 'backup'), 444 new lang_string('automatedmaxkepthelp', 'backup'), 1, $maxkeptoptions)); 445 446 $automateddeletedaysoptions = array( 447 0 => new lang_string('never'), 448 1000 => new lang_string('numdays', '', 1000), 449 365 => new lang_string('numdays', '', 365), 450 180 => new lang_string('numdays', '', 180), 451 150 => new lang_string('numdays', '', 150), 452 120 => new lang_string('numdays', '', 120), 453 90 => new lang_string('numdays', '', 90), 454 60 => new lang_string('numdays', '', 60), 455 35 => new lang_string('numdays', '', 35), 456 10 => new lang_string('numdays', '', 10), 457 5 => new lang_string('numdays', '', 5), 458 2 => new lang_string('numdays', '', 2) 459 ); 460 $temp->add(new admin_setting_configselect('backup/backup_auto_delete_days', new lang_string('automateddeletedays', 'backup'), 461 '', 0, $automateddeletedaysoptions)); 462 463 $minkeptoptions = array( 464 0 => new lang_string('none'), 465 1 => '1', 466 2 => '2', 467 5 => '5', 468 10 => '10', 469 20 => '20', 470 30 => '30', 471 40 => '40', 472 50 => '50', 473 100 => '100', 474 200 => '200', 475 300 => '300', 476 400 => '400' 477 ); 478 $temp->add(new admin_setting_configselect('backup/backup_auto_min_kept', new lang_string('automatedminkept', 'backup'), 479 new lang_string('automatedminkepthelp', 'backup'), 0, $minkeptoptions)); 480 481 $temp->add(new admin_setting_configcheckbox('backup/backup_shortname', new lang_string('backup_shortname', 'admin'), new lang_string('backup_shortnamehelp', 'admin'), 0)); 482 $temp->add(new admin_setting_configcheckbox('backup/backup_auto_skip_hidden', new lang_string('skiphidden', 'backup'), new lang_string('skiphiddenhelp', 'backup'), 1)); 483 $temp->add(new admin_setting_configselect('backup/backup_auto_skip_modif_days', new lang_string('skipmodifdays', 'backup'), new lang_string('skipmodifdayshelp', 'backup'), 30, array( 484 0 => new lang_string('never'), 485 1 => new lang_string('numdays', '', 1), 486 2 => new lang_string('numdays', '', 2), 487 3 => new lang_string('numdays', '', 3), 488 5 => new lang_string('numdays', '', 5), 489 7 => new lang_string('numdays', '', 7), 490 10 => new lang_string('numdays', '', 10), 491 14 => new lang_string('numdays', '', 14), 492 20 => new lang_string('numdays', '', 20), 493 30 => new lang_string('numdays', '', 30), 494 60 => new lang_string('numdays', '', 60), 495 90 => new lang_string('numdays', '', 90), 496 120 => new lang_string('numdays', '', 120), 497 180 => new lang_string('numdays', '', 180), 498 365 => new lang_string('numdays', '', 365) 499 ))); 500 $temp->add(new admin_setting_configcheckbox('backup/backup_auto_skip_modif_prev', new lang_string('skipmodifprev', 'backup'), new lang_string('skipmodifprevhelp', 'backup'), 0)); 501 502 // Automated defaults section. 503 $temp->add(new admin_setting_heading('automatedsettings', new lang_string('automatedsettings','backup'), new lang_string('recyclebin_desc', 'backup'))); 504 $temp->add(new admin_setting_configcheckbox('backup/backup_auto_users', new lang_string('generalusers', 'backup'), new lang_string('configgeneralusers', 'backup'), 1)); 505 $temp->add(new admin_setting_configcheckbox('backup/backup_auto_role_assignments', new lang_string('generalroleassignments','backup'), new lang_string('configgeneralroleassignments','backup'), 1)); 506 $temp->add(new admin_setting_configcheckbox('backup/backup_auto_activities', new lang_string('generalactivities', 'backup'), 507 new lang_string('backupautoactivitiesdescription', 'backup'), 1)); 508 $temp->add(new admin_setting_configcheckbox('backup/backup_auto_blocks', new lang_string('generalblocks','backup'), new lang_string('configgeneralblocks','backup'), 1)); 509 $temp->add(new admin_setting_configcheckbox( 510 'backup/backup_auto_files', 511 new lang_string('generalfiles', 'backup'), 512 new lang_string('configgeneralfiles', 'backup'), '1')); 513 $temp->add(new admin_setting_configcheckbox('backup/backup_auto_filters', new lang_string('generalfilters','backup'), new lang_string('configgeneralfilters','backup'), 1)); 514 $temp->add(new admin_setting_configcheckbox('backup/backup_auto_comments', new lang_string('generalcomments','backup'), new lang_string('configgeneralcomments','backup'), 1)); 515 $temp->add(new admin_setting_configcheckbox('backup/backup_auto_badges', new lang_string('generalbadges','backup'), new lang_string('configgeneralbadges','backup'), 1)); 516 $temp->add(new admin_setting_configcheckbox('backup/backup_auto_calendarevents', new lang_string('generalcalendarevents','backup'), new lang_string('configgeneralcalendarevents','backup'), 1)); 517 $temp->add(new admin_setting_configcheckbox('backup/backup_auto_userscompletion', new lang_string('generaluserscompletion','backup'), new lang_string('configgeneraluserscompletion','backup'), 1)); 518 $temp->add(new admin_setting_configcheckbox('backup/backup_auto_logs', new lang_string('generallogs', 'backup'), new lang_string('configgenerallogs', 'backup'), 0)); 519 $temp->add(new admin_setting_configcheckbox('backup/backup_auto_histories', new lang_string('generalhistories','backup'), new lang_string('configgeneralhistories','backup'), 0)); 520 $temp->add(new admin_setting_configcheckbox('backup/backup_auto_questionbank', new lang_string('generalquestionbank','backup'), new lang_string('configgeneralquestionbank','backup'), 1)); 521 $temp->add(new admin_setting_configcheckbox('backup/backup_auto_groups', new lang_string('generalgroups', 'backup'), 522 new lang_string('configgeneralgroups', 'backup'), 1)); 523 $temp->add(new admin_setting_configcheckbox('backup/backup_auto_competencies', new lang_string('generalcompetencies','backup'), new lang_string('configgeneralcompetencies','backup'), 1)); 524 $temp->add(new admin_setting_configcheckbox( 525 'backup/backup_auto_contentbankcontent', 526 new lang_string('generalcontentbankcontent', 'backup'), 527 new lang_string('configgeneralcontentbankcontent', 'backup'), 528 1) 529 ); 530 $temp->add(new admin_setting_configcheckbox( 531 'backup/backup_auto_xapistate', 532 new lang_string('generalxapistate', 'backup'), 533 new lang_string('configgeneralxapistate', 'backup'), 534 1) 535 ); 536 537 $temp->add(new admin_setting_configcheckbox('backup/backup_auto_legacyfiles', 538 new lang_string('generallegacyfiles', 'backup'), 539 new lang_string('configlegacyfiles', 'backup'), 1)); 540 541 //$temp->add(new admin_setting_configcheckbox('backup/backup_auto_messages', new lang_string('messages', 'message'), new lang_string('backupmessageshelp','message'), 0)); 542 //$temp->add(new admin_setting_configcheckbox('backup/backup_auto_blogs', new lang_string('blogs', 'blog'), new lang_string('backupblogshelp','blog'), 0)); 543 544 $ADMIN->add('backups', $temp); 545 546 // Create a page for general restore configuration and defaults. 547 $temp = new admin_settingpage('restoregeneralsettings', new lang_string('generalrestoredefaults', 'backup')); 548 549 // General restore defaults. 550 $temp->add(new admin_setting_heading('generalsettings', new lang_string('generalrestoresettings', 'backup'), '')); 551 552 $temp->add(new admin_setting_configcheckbox_with_lock('restore/restore_general_users', 553 new lang_string('generalusers', 'backup'), new lang_string('configrestoreusers', 'backup'), 554 array('value' => 1, 'locked' => 0))); 555 // Can not use actual constants here because we'd need to include 100 of backup/restore files. 556 $options = [ 557 0/*backup::ENROL_NEVER*/ => get_string('rootsettingenrolments_never', 'backup'), 558 1/*backup::ENROL_WITHUSERS*/ => get_string('rootsettingenrolments_withusers', 'backup'), 559 2/*backup::ENROL_ALWAYS*/ => get_string('rootsettingenrolments_always', 'backup'), 560 ]; 561 $temp->add(new admin_setting_configselect_with_lock('restore/restore_general_enrolments', 562 new lang_string('generalenrolments', 'backup'), new lang_string('configrestoreenrolments', 'backup'), 563 array('value' => 1/*backup::ENROL_WITHUSERS*/, 'locked' => 0), $options)); 564 $temp->add(new admin_setting_configcheckbox_with_lock('restore/restore_general_role_assignments', 565 new lang_string('generalroleassignments', 'backup'), 566 new lang_string('configrestoreroleassignments', 'backup'), array('value' => 1, 'locked' => 0))); 567 $temp->add(new admin_setting_configcheckbox_with_lock('restore/restore_general_permissions', 568 new lang_string('generalpermissions', 'backup'), 569 new lang_string('configrestorepermissions', 'backup'), array('value' => 1, 'locked' => 0))); 570 $temp->add(new admin_setting_configcheckbox_with_lock('restore/restore_general_activities', 571 new lang_string('generalactivities', 'backup'), 572 new lang_string('configrestoreactivities', 'backup'), array('value' => 1, 'locked' => 0))); 573 $temp->add(new admin_setting_configcheckbox_with_lock('restore/restore_general_blocks', 574 new lang_string('generalblocks', 'backup'), 575 new lang_string('configrestoreblocks', 'backup'), array('value' => 1, 'locked' => 0))); 576 $temp->add(new admin_setting_configcheckbox_with_lock('restore/restore_general_filters', 577 new lang_string('generalfilters', 'backup'), 578 new lang_string('configrestorefilters', 'backup'), array('value' => 1, 'locked' => 0))); 579 $temp->add(new admin_setting_configcheckbox_with_lock('restore/restore_general_comments', 580 new lang_string('generalcomments', 'backup'), 581 new lang_string('configrestorecomments', 'backup'), array('value' => 1, 'locked' => 0))); 582 $temp->add(new admin_setting_configcheckbox_with_lock('restore/restore_general_badges', 583 new lang_string('generalbadges', 'backup'), 584 new lang_string('configrestorebadges', 'backup'), array('value' => 1, 'locked' => 0))); 585 $temp->add(new admin_setting_configcheckbox_with_lock('restore/restore_general_calendarevents', 586 new lang_string('generalcalendarevents', 'backup'), 587 new lang_string('configrestorecalendarevents', 'backup'), array('value' => 1, 'locked' => 0))); 588 $temp->add(new admin_setting_configcheckbox_with_lock('restore/restore_general_userscompletion', 589 new lang_string('generaluserscompletion', 'backup'), 590 new lang_string('configrestoreuserscompletion', 'backup'), array('value' => 1, 'locked' => 0))); 591 $temp->add(new admin_setting_configcheckbox_with_lock('restore/restore_general_logs', 592 new lang_string('generallogs', 'backup'), 593 new lang_string('configrestorelogs', 'backup'), array('value' => 1, 'locked' => 0))); 594 $temp->add(new admin_setting_configcheckbox_with_lock('restore/restore_general_histories', 595 new lang_string('generalhistories', 'backup'), 596 new lang_string('configrestorehistories', 'backup'), array('value' => 1, 'locked' => 0))); 597 $temp->add(new admin_setting_configcheckbox_with_lock('restore/restore_general_groups', 598 new lang_string('generalgroups', 'backup'), new lang_string('configrestoregroups', 'backup'), 599 array('value' => 1, 'locked' => 0))); 600 $temp->add(new admin_setting_configcheckbox_with_lock('restore/restore_general_competencies', 601 new lang_string('generalcompetencies', 'backup'), 602 new lang_string('configrestorecompetencies', 'backup'), array('value' => 1, 'locked' => 0))); 603 $temp->add(new admin_setting_configcheckbox_with_lock('restore/restore_general_contentbankcontent', 604 new lang_string('generalcontentbankcontent', 'backup'), 605 new lang_string('configrestorecontentbankcontent', 'backup'), array('value' => 1, 'locked' => 0))); 606 $temp->add(new admin_setting_configcheckbox_with_lock('restore/restore_general_xapistate', 607 new lang_string('generalxapistate', 'backup'), 608 new lang_string('configrestorexapistate', 'backup'), array('value' => 1, 'locked' => 0))); 609 $temp->add(new admin_setting_configcheckbox_with_lock('restore/restore_general_legacyfiles', 610 new lang_string('generallegacyfiles', 'backup'), 611 new lang_string('configlegacyfiles', 'backup'), array('value' => 1, 'locked' => 0))); 612 613 // Restore defaults when merging into another course. 614 $temp->add(new admin_setting_heading('mergerestoredefaults', new lang_string('mergerestoredefaults', 'backup'), '')); 615 616 $temp->add(new admin_setting_configcheckbox_with_lock('restore/restore_merge_overwrite_conf', 617 new lang_string('setting_overwrite_conf', 'backup'), 618 new lang_string('config_overwrite_conf', 'backup'), array('value' => 0, 'locked' => 0))); 619 620 $temp->add(new admin_setting_configcheckbox_with_lock('restore/restore_merge_course_fullname', 621 new lang_string('setting_overwrite_course_fullname', 'backup'), 622 new lang_string('config_overwrite_course_fullname', 'backup'), array('value' => 1, 'locked' => 0))); 623 $temp->add(new admin_setting_configcheckbox_with_lock('restore/restore_merge_course_shortname', 624 new lang_string('setting_overwrite_course_shortname', 'backup'), 625 new lang_string('config_overwrite_course_shortname', 'backup'), array('value' => 1, 'locked' => 0))); 626 $temp->add(new admin_setting_configcheckbox_with_lock('restore/restore_merge_course_startdate', 627 new lang_string('setting_overwrite_course_startdate', 'backup'), 628 new lang_string('config_overwrite_course_startdate', 'backup'), array('value' => 1, 'locked' => 0))); 629 630 // Restore defaults when replacing course contents. 631 $temp->add(new admin_setting_heading('replacerestoredefaults', new lang_string('replacerestoredefaults', 'backup'), '')); 632 633 $temp->add(new admin_setting_configcheckbox_with_lock('restore/restore_replace_overwrite_conf', 634 new lang_string('setting_overwrite_conf', 'backup'), 635 new lang_string('config_overwrite_conf', 'backup'), array('value' => 0, 'locked' => 0))); 636 637 $temp->add(new admin_setting_configcheckbox_with_lock('restore/restore_replace_course_fullname', 638 new lang_string('setting_overwrite_course_fullname', 'backup'), 639 new lang_string('config_overwrite_course_fullname', 'backup'), array('value' => 1, 'locked' => 0))); 640 $temp->add(new admin_setting_configcheckbox_with_lock('restore/restore_replace_course_shortname', 641 new lang_string('setting_overwrite_course_shortname', 'backup'), 642 new lang_string('config_overwrite_course_shortname', 'backup'), array('value' => 1, 'locked' => 0))); 643 $temp->add(new admin_setting_configcheckbox_with_lock('restore/restore_replace_course_startdate', 644 new lang_string('setting_overwrite_course_startdate', 'backup'), 645 new lang_string('config_overwrite_course_startdate', 'backup'), array('value' => 1, 'locked' => 0))); 646 647 $temp->add(new admin_setting_configselect_with_lock('restore/restore_replace_keep_roles_and_enrolments', 648 new lang_string('setting_keep_roles_and_enrolments', 'backup'), 649 new lang_string('config_keep_roles_and_enrolments', 'backup'), array('value' => 0, 'locked' => 0), 650 array(1 => get_string('yes'), 0 => get_string('no')))); 651 $temp->add(new admin_setting_configselect_with_lock('restore/restore_replace_keep_groups_and_groupings', 652 new lang_string('setting_keep_groups_and_groupings', 'backup'), 653 new lang_string('config_keep_groups_and_groupings', 'backup'), array('value' => 0, 'locked' => 0), 654 array(1 => get_string('yes'), 0 => get_string('no')))); 655 656 $ADMIN->add('backups', $temp); 657 658 // Create a page for asynchronous backup and restore configuration and defaults. 659 $temp = new admin_settingpage('asyncgeneralsettings', new lang_string('asyncgeneralsettings', 'backup')); 660 661 $temp->add(new admin_setting_configcheckbox('enableasyncbackup', new lang_string('enableasyncbackup', 'backup'), 662 new lang_string('enableasyncbackup_help', 'backup'), 0, 1, 0)); 663 664 $temp->add(new admin_setting_configcheckbox( 665 'backup/backup_async_message_users', 666 new lang_string('asyncemailenable', 'backup'), 667 new lang_string('asyncemailenabledetail', 'backup'), 0)); 668 $temp->hide_if('backup/backup_async_message_users', 'enableasyncbackup'); 669 670 $temp->add(new admin_setting_configtext( 671 'backup/backup_async_message_subject', 672 new lang_string('asyncmessagesubject', 'backup'), 673 new lang_string('asyncmessagesubjectdetail', 'backup'), 674 new lang_string('asyncmessagesubjectdefault', 'backup'))); 675 $temp->hide_if('backup/backup_async_message_subject', 'backup/backup_async_message_users'); 676 677 $temp->add(new admin_setting_confightmleditor( 678 'backup/backup_async_message', 679 new lang_string('asyncmessagebody', 'backup'), 680 new lang_string('asyncmessagebodydetail', 'backup'), 681 new lang_string('asyncmessagebodydefault', 'backup'))); 682 $temp->hide_if('backup/backup_async_message', 'backup/backup_async_message_users'); 683 684 $ADMIN->add('backups', $temp); 685 686 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body