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