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