MDL-67262 core_course: Added the ability to recommend activities.
[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
25$capabilities = array(
26 'moodle/backup:backupcourse',
27 'moodle/category:manage',
28 'moodle/course:create',
39bd07f7
SH
29 'moodle/site:approvecourse',
30 'moodle/restore:restorecourse'
5dc361e1
SH
31);
32if ($hassiteconfig or has_any_capability($capabilities, $systemcontext)) {
33 // Speedup for non-admins, add all caps used on this page.
34 $ADMIN->add('courses',
35 new admin_externalpage('coursemgmt', new lang_string('coursemgmt', 'admin'),
36 $CFG->wwwroot . '/course/management.php',
37 array('moodle/category:manage', 'moodle/course:create')
38 )
39 );
7a0162f1
DM
40 $ADMIN->add('courses',
41 new admin_externalpage('course_customfield', new lang_string('course_customfield', 'admin'),
42 $CFG->wwwroot . '/course/customfield.php',
43 array('moodle/course:configurecustomfields')
44 )
45 );
5dc361e1
SH
46 $ADMIN->add('courses',
47 new admin_externalpage('addcategory', new lang_string('addcategory', 'admin'),
48 new moodle_url('/course/editcategory.php', array('parent' => 0)),
49 array('moodle/category:manage')
50 )
51 );
28af88f3
DNA
52 $ADMIN->add('courses',
53 new admin_externalpage('addnewcourse', new lang_string('addnewcourse'),
54 new moodle_url('/course/edit.php', array('category' => 0)),
55 array('moodle/category:manage')
56 )
57 );
39bd07f7
SH
58 $ADMIN->add('courses',
59 new admin_externalpage('restorecourse', new lang_string('restorecourse', 'admin'),
60 new moodle_url('/backup/restorefile.php', array('contextid' => context_system::instance()->id)),
2d3fcda8 61 array('moodle/restore:restorecourse')
39bd07f7
SH
62 )
63 );
cd09777d
AG
64 $ADMIN->add('courses',
65 new admin_externalpage('activitychooser', new lang_string('activitychooser', 'course'),
66 new moodle_url('/course/recommendations.php'),
67 array('moodle/course:recommendactivity')
68 )
69 );
220a90c5 70
e1586141
FM
71 // Course Default Settings Page.
72 // NOTE: these settings must be applied after all other settings because they depend on them.
73
e1586141 74 // Main course settings.
e106013f 75 $temp = new admin_settingpage('coursesettings', new lang_string('coursesettings'));
3776335c 76 require_once($CFG->dirroot.'/course/lib.php');
e1586141
FM
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
e1586141
FM
84 // Course format.
85 $temp->add(new admin_setting_heading('courseformathdr', new lang_string('type_format', 'plugin'), ''));
86
3776335c 87 $courseformats = get_sorted_course_formats(true);
1caea91e 88 $formcourseformats = array();
3776335c 89 foreach ($courseformats as $courseformat) {
e106013f 90 $formcourseformats[$courseformat] = new lang_string('pluginname', "format_$courseformat");
1caea91e 91 }
e1586141 92 $temp->add(new admin_setting_configselect('moodlecourse/format', new lang_string('format'), new lang_string('coursehelpformat'),
78c2c3bb 93 'topics', $formcourseformats));
c141b05f 94
e1586141
FM
95 $temp->add(new admin_setting_configtext('moodlecourse/maxsections', new lang_string('maxnumberweeks'),
96 new lang_string('maxnumberweeks_desc'), 52));
c141b05f 97
e1586141 98 $temp->add(new admin_settings_num_course_sections('moodlecourse/numsections', new lang_string('numberweeks'),
78c2c3bb 99 new lang_string('coursehelpnumberweeks'), 4));
c141b05f 100
1caea91e 101 $choices = array();
e106013f
SH
102 $choices['0'] = new lang_string('hiddensectionscollapsed');
103 $choices['1'] = new lang_string('hiddensectionsinvisible');
e1586141
FM
104 $temp->add(new admin_setting_configselect('moodlecourse/hiddensections', new lang_string('hiddensections'),
105 new lang_string('coursehelphiddensections'), 0, $choices));
106
107 $choices = array();
108 $choices[COURSE_DISPLAY_SINGLEPAGE] = new lang_string('coursedisplay_single');
109 $choices[COURSE_DISPLAY_MULTIPAGE] = new lang_string('coursedisplay_multi');
110 $temp->add(new admin_setting_configselect('moodlecourse/coursedisplay', new lang_string('coursedisplay'),
111 new lang_string('coursedisplay_help'), COURSE_DISPLAY_SINGLEPAGE, $choices));
112
33a3ec7c
AB
113 $temp->add(new admin_setting_configcheckbox('moodlecourse/courseenddateenabled', get_string('courseenddateenabled'),
114 get_string('courseenddateenabled_desc'), 1));
115
8643c576
DM
116 $temp->add(new admin_setting_configduration('moodlecourse/courseduration', get_string('courseduration'),
117 get_string('courseduration_desc'), YEARSECS));
118
e1586141
FM
119 // Appearance.
120 $temp->add(new admin_setting_heading('appearancehdr', new lang_string('appearance'), ''));
121
122 $languages = array();
123 $languages[''] = new lang_string('forceno');
124 $languages += get_string_manager()->get_list_of_translations();
125 $temp->add(new admin_setting_configselect('moodlecourse/lang', new lang_string('forcelanguage'), '', key($languages),
126 $languages));
127
1caea91e 128 $options = range(0, 10);
e1586141
FM
129 $temp->add(new admin_setting_configselect('moodlecourse/newsitems', new lang_string('newsitemsnumber'),
130 new lang_string('coursehelpnewsitemsnumber'), 5, $options));
131 $temp->add(new admin_setting_configselect('moodlecourse/showgrades', new lang_string('showgrades'),
132 new lang_string('coursehelpshowgrades'), 1, array(0 => new lang_string('no'), 1 => new lang_string('yes'))));
133 $temp->add(new admin_setting_configselect('moodlecourse/showreports', new lang_string('showreports'), '', 0,
134 array(0 => new lang_string('no'), 1 => new lang_string('yes'))));
135
e1586141
FM
136 // Files and uploads.
137 $temp->add(new admin_setting_heading('filesanduploadshdr', new lang_string('filesanduploads'), ''));
138
139 if (!empty($CFG->legacyfilesinnewcourses)) {
140 $choices = array('0'=>new lang_string('no'), '2'=>new lang_string('yes'));
141 $temp->add(new admin_setting_configselect('moodlecourse/legacyfiles', new lang_string('courselegacyfiles'),
142 new lang_string('courselegacyfiles_help'), key($choices), $choices));
143 }
c141b05f 144
732c25ad 145 $currentmaxbytes = get_config('moodlecourse', 'maxbytes');
1caea91e 146 if (isset($CFG->maxbytes)) {
732c25ad 147 $choices = get_max_upload_sizes($CFG->maxbytes, 0, 0, $currentmaxbytes);
1caea91e 148 } else {
732c25ad 149 $choices = get_max_upload_sizes(0, 0, 0, $currentmaxbytes);
1caea91e 150 }
e1586141
FM
151 $temp->add(new admin_setting_configselect('moodlecourse/maxbytes', new lang_string('maximumupload'),
152 new lang_string('coursehelpmaximumupload'), key($choices), $choices));
1caea91e 153
e1586141
FM
154 // Completion tracking.
155 $temp->add(new admin_setting_heading('progress', new lang_string('completion','completion'), ''));
156 $temp->add(new admin_setting_configselect('moodlecourse/enablecompletion', new lang_string('completion', 'completion'),
f8ffd1f2 157 new lang_string('enablecompletion_help', 'completion'), 1, array(0 => new lang_string('no'), 1 => new lang_string('yes'))));
e1586141 158
e1586141 159 // Groups.
e106013f 160 $temp->add(new admin_setting_heading('groups', new lang_string('groups', 'group'), ''));
1caea91e 161 $choices = array();
e106013f
SH
162 $choices[NOGROUPS] = new lang_string('groupsnone', 'group');
163 $choices[SEPARATEGROUPS] = new lang_string('groupsseparate', 'group');
164 $choices[VISIBLEGROUPS] = new lang_string('groupsvisible', 'group');
165 $temp->add(new admin_setting_configselect('moodlecourse/groupmode', new lang_string('groupmode'), '', key($choices),$choices));
166 $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 167
1caea91e 168 $ADMIN->add('courses', $temp);
eb1b9597 169
e1586141 170 // "courserequests" settingpage.
e106013f 171 $temp = new admin_settingpage('courserequest', new lang_string('courserequest'));
959e4f0e
MG
172 $temp->add(new admin_setting_configcheckbox('enablecourserequests',
173 new lang_string('enablecourserequests', 'admin'),
174 new lang_string('configenablecourserequests', 'admin'), 1));
175 $temp->add(new admin_settings_coursecat_select('defaultrequestcategory',
176 new lang_string('defaultrequestcategory', 'admin'),
177 new lang_string('configdefaultrequestcategory', 'admin'), 1));
178 $temp->add(new admin_setting_configcheckbox('lockrequestcategory',
179 new lang_string('lockrequestcategory', 'admin'),
180 new lang_string('configlockrequestcategory', 'admin'), 0));
e106013f 181 $temp->add(new admin_setting_users_with_capability('courserequestnotify', new lang_string('courserequestnotify', 'admin'), new lang_string('configcourserequestnotify2', 'admin'), array(), 'moodle/site:approvecourse'));
220a90c5 182 $ADMIN->add('courses', $temp);
183
5dc361e1 184 // Pending course requests.
77eddcd5 185 if (!empty($CFG->enablecourserequests)) {
e106013f 186 $ADMIN->add('courses', new admin_externalpage('coursespending', new lang_string('pendingrequests'),
77eddcd5 187 $CFG->wwwroot . '/course/pending.php', array('moodle/site:approvecourse')));
188 }
189
5dc361e1 190 // Add a category for backups.
e106013f 191 $ADMIN->add('courses', new admin_category('backups', new lang_string('backups','admin')));
61ebef8f 192
14e2704a 193 // Create a page for general backups configuration and defaults.
e106013f 194 $temp = new admin_settingpage('backupgeneralsettings', new lang_string('generalbackdefaults', 'backup'), 'moodle/backup:backupcourse');
14e2704a
EL
195
196 // General configuration section.
197 $temp->add(new admin_setting_configselect('backup/loglifetime', new lang_string('loglifetime', 'backup'), new lang_string('configloglifetime', 'backup'), 30, array(
198 1 => new lang_string('numdays', '', 1),
199 2 => new lang_string('numdays', '', 2),
200 3 => new lang_string('numdays', '', 3),
201 5 => new lang_string('numdays', '', 5),
202 7 => new lang_string('numdays', '', 7),
203 10 => new lang_string('numdays', '', 10),
204 14 => new lang_string('numdays', '', 14),
205 20 => new lang_string('numdays', '', 20),
206 30 => new lang_string('numdays', '', 30),
207 60 => new lang_string('numdays', '', 60),
208 90 => new lang_string('numdays', '', 90),
209 120 => new lang_string('numdays', '', 120),
210 180 => new lang_string('numdays', '', 180),
211 365 => new lang_string('numdays', '', 365)
212 )));
213
214 // General defaults section.
215 $temp->add(new admin_setting_heading('generalsettings', new lang_string('generalsettings', 'backup'), ''));
e106013f
SH
216 $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)));
217 $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)));
218 $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
219 $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)));
220 $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
221 $temp->add(new admin_setting_configcheckbox_with_lock(
222 'backup/backup_general_files',
223 new lang_string('generalfiles', 'backup'),
224 new lang_string('configgeneralfiles', 'backup'),
225 array('value' => '1', 'locked' => 0)));
e106013f
SH
226 $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)));
227 $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 228 $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 229 $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
230 $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)));
231 $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)));
232 $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 233 $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
234 $temp->add(new admin_setting_configcheckbox_with_lock('backup/backup_general_groups',
235 new lang_string('generalgroups', 'backup'), new lang_string('configgeneralgroups', 'backup'),
236 array('value' => 1, 'locked' => 0)));
4151ed98 237 $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)));
868b086c 238
61ebef8f
SH
239 $ADMIN->add('backups', $temp);
240
c4dbfb2c
RL
241 // Create a page for general import configuration and defaults.
242 $temp = new admin_settingpage('importgeneralsettings', new lang_string('importgeneralsettings', 'backup'), 'moodle/backup:backupcourse');
243 $temp->add(new admin_setting_configtext('backup/import_general_maxresults', new lang_string('importgeneralmaxresults', 'backup'), new lang_string('importgeneralmaxresults_desc', 'backup'), 10));
088d6086
CB
244 $temp->add(new admin_setting_configcheckbox('backup/import_general_duplicate_admin_allowed',
245 new lang_string('importgeneralduplicateadminallowed', 'backup'),
246 new lang_string('importgeneralduplicateadminallowed_desc', 'backup'), 0));
4151ed98
HB
247
248 // Import defaults section.
249 $temp->add(new admin_setting_heading('importsettings', new lang_string('importsettings', 'backup'), ''));
250 $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)));
251 $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)));
252 $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)));
253 $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)));
254 $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)));
255 $temp->add(new admin_setting_configcheckbox_with_lock('backup/backup_import_groups',
256 new lang_string('generalgroups', 'backup'), new lang_string('configgeneralgroups', 'backup'),
257 array('value' => 1, 'locked' => 0)));
258 $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)));
259
c4dbfb2c
RL
260 $ADMIN->add('backups', $temp);
261
14e2704a 262 // Create a page for automated backups configuration and defaults.
e106013f 263 $temp = new admin_settingpage('automated', new lang_string('automatedsetup','backup'), 'moodle/backup:backupcourse');
14e2704a
EL
264
265 // Automated configuration section.
e106013f
SH
266 $temp->add(new admin_setting_configselect('backup/backup_auto_active', new lang_string('active'), new lang_string('autoactivedescription', 'backup'), 0, array(
267 0 => new lang_string('autoactivedisabled', 'backup'),
268 1 => new lang_string('autoactiveenabled', 'backup'),
269 2 => new lang_string('autoactivemanual', 'backup')
081c914b 270 )));
bac233d3 271 $temp->add(new admin_setting_special_backupdays());
e106013f
SH
272 $temp->add(new admin_setting_configtime('backup/backup_auto_hour', 'backup_auto_minute', new lang_string('executeat'),
273 new lang_string('backupexecuteathelp'), array('h' => 0, 'm' => 0)));
bac233d3 274 $storageoptions = array(
e106013f
SH
275 0 => new lang_string('storagecourseonly', 'backup'),
276 1 => new lang_string('storageexternalonly', 'backup'),
277 2 => new lang_string('storagecourseandexternal', 'backup')
bac233d3 278 );
e106013f 279 $temp->add(new admin_setting_configselect('backup/backup_auto_storage', new lang_string('automatedstorage', 'backup'), new lang_string('automatedstoragehelp', 'backup'), 0, $storageoptions));
9fdf16a0 280 $temp->add(new admin_setting_special_backup_auto_destination());
2b7c85da
JPG
281
282 $maxkeptoptions = array(
e106013f 283 0 => new lang_string('all'), 1 => '1',
f1953d38 284 2 => '2',
07870553 285 3 => '3',
286 4 => '4',
f1953d38 287 5 => '5',
288 10 => '10',
289 20 => '20',
290 30 => '30',
291 40 => '40',
292 50 => '50',
293 100 => '100',
294 200 => '200',
295 300 => '300',
296 400 => '400',
297 500 => '500');
2b7c85da
JPG
298 $temp->add(new admin_setting_configselect('backup/backup_auto_max_kept', new lang_string('automatedmaxkept', 'backup'),
299 new lang_string('automatedmaxkepthelp', 'backup'), 1, $maxkeptoptions));
6e9cd669 300
2b7c85da 301 $automateddeletedaysoptions = array(
694f195d
SG
302 0 => new lang_string('never'),
303 1000 => new lang_string('numdays', '', 1000),
304 365 => new lang_string('numdays', '', 365),
305 180 => new lang_string('numdays', '', 180),
306 150 => new lang_string('numdays', '', 150),
307 120 => new lang_string('numdays', '', 120),
308 90 => new lang_string('numdays', '', 90),
309 60 => new lang_string('numdays', '', 60),
310 35 => new lang_string('numdays', '', 35),
311 10 => new lang_string('numdays', '', 10),
312 5 => new lang_string('numdays', '', 5),
313 2 => new lang_string('numdays', '', 2)
2b7c85da
JPG
314 );
315 $temp->add(new admin_setting_configselect('backup/backup_auto_delete_days', new lang_string('automateddeletedays', 'backup'),
316 '', 0, $automateddeletedaysoptions));
694f195d 317
2b7c85da 318 $minkeptoptions = array(
694f195d
SG
319 0 => new lang_string('none'),
320 1 => '1',
321 2 => '2',
322 5 => '5',
323 10 => '10',
324 20 => '20',
325 30 => '30',
326 40 => '40',
327 50 => '50',
328 100 => '100',
329 200 => '200',
330 300 => '300',
2b7c85da
JPG
331 400 => '400'
332 );
333 $temp->add(new admin_setting_configselect('backup/backup_auto_min_kept', new lang_string('automatedminkept', 'backup'),
334 new lang_string('automatedminkepthelp', 'backup'), 0, $minkeptoptions));
335
336 $temp->add(new admin_setting_configcheckbox('backup/backup_shortname', new lang_string('backup_shortname', 'admin'), new lang_string('backup_shortnamehelp', 'admin'), 0));
337 $temp->add(new admin_setting_configcheckbox('backup/backup_auto_skip_hidden', new lang_string('skiphidden', 'backup'), new lang_string('skiphiddenhelp', 'backup'), 1));
338 $temp->add(new admin_setting_configselect('backup/backup_auto_skip_modif_days', new lang_string('skipmodifdays', 'backup'), new lang_string('skipmodifdayshelp', 'backup'), 30, array(
339 0 => new lang_string('never'),
340 1 => new lang_string('numdays', '', 1),
341 2 => new lang_string('numdays', '', 2),
342 3 => new lang_string('numdays', '', 3),
343 5 => new lang_string('numdays', '', 5),
344 7 => new lang_string('numdays', '', 7),
345 10 => new lang_string('numdays', '', 10),
346 14 => new lang_string('numdays', '', 14),
347 20 => new lang_string('numdays', '', 20),
348 30 => new lang_string('numdays', '', 30),
349 60 => new lang_string('numdays', '', 60),
350 90 => new lang_string('numdays', '', 90),
351 120 => new lang_string('numdays', '', 120),
352 180 => new lang_string('numdays', '', 180),
353 365 => new lang_string('numdays', '', 365)
694f195d 354 )));
2b7c85da 355 $temp->add(new admin_setting_configcheckbox('backup/backup_auto_skip_modif_prev', new lang_string('skipmodifprev', 'backup'), new lang_string('skipmodifprevhelp', 'backup'), 0));
694f195d 356
14e2704a 357 // Automated defaults section.
a99ef60c 358 $temp->add(new admin_setting_heading('automatedsettings', new lang_string('automatedsettings','backup'), new lang_string('recyclebin_desc', 'backup')));
e106013f
SH
359 $temp->add(new admin_setting_configcheckbox('backup/backup_auto_users', new lang_string('generalusers', 'backup'), new lang_string('configgeneralusers', 'backup'), 1));
360 $temp->add(new admin_setting_configcheckbox('backup/backup_auto_role_assignments', new lang_string('generalroleassignments','backup'), new lang_string('configgeneralroleassignments','backup'), 1));
e106013f
SH
361 $temp->add(new admin_setting_configcheckbox('backup/backup_auto_activities', new lang_string('generalactivities','backup'), new lang_string('configgeneralactivities','backup'), 1));
362 $temp->add(new admin_setting_configcheckbox('backup/backup_auto_blocks', new lang_string('generalblocks','backup'), new lang_string('configgeneralblocks','backup'), 1));
d7e4481e
MP
363 $temp->add(new admin_setting_configcheckbox(
364 'backup/backup_auto_files',
365 new lang_string('generalfiles', 'backup'),
366 new lang_string('configgeneralfiles', 'backup'), '1'));
8490a4ab 367 $temp->add(new admin_setting_configcheckbox('backup/backup_auto_filters', new lang_string('generalfilters','backup'), new lang_string('configgeneralfilters','backup'), 1));
e106013f 368 $temp->add(new admin_setting_configcheckbox('backup/backup_auto_comments', new lang_string('generalcomments','backup'), new lang_string('configgeneralcomments','backup'), 1));
2832093f 369 $temp->add(new admin_setting_configcheckbox('backup/backup_auto_badges', new lang_string('generalbadges','backup'), new lang_string('configgeneralbadges','backup'), 1));
4151ed98 370 $temp->add(new admin_setting_configcheckbox('backup/backup_auto_calendarevents', new lang_string('generalcalendarevents','backup'), new lang_string('configgeneralcalendarevents','backup'), 1));
e106013f
SH
371 $temp->add(new admin_setting_configcheckbox('backup/backup_auto_userscompletion', new lang_string('generaluserscompletion','backup'), new lang_string('configgeneraluserscompletion','backup'), 1));
372 $temp->add(new admin_setting_configcheckbox('backup/backup_auto_logs', new lang_string('generallogs', 'backup'), new lang_string('configgenerallogs', 'backup'), 0));
373 $temp->add(new admin_setting_configcheckbox('backup/backup_auto_histories', new lang_string('generalhistories','backup'), new lang_string('configgeneralhistories','backup'), 0));
6507aaea 374 $temp->add(new admin_setting_configcheckbox('backup/backup_auto_questionbank', new lang_string('generalquestionbank','backup'), new lang_string('configgeneralquestionbank','backup'), 1));
d7891c83
TP
375 $temp->add(new admin_setting_configcheckbox('backup/backup_auto_groups', new lang_string('generalgroups', 'backup'),
376 new lang_string('configgeneralgroups', 'backup'), 1));
4151ed98 377 $temp->add(new admin_setting_configcheckbox('backup/backup_auto_competencies', new lang_string('generalcompetencies','backup'), new lang_string('configgeneralcompetencies','backup'), 1));
6e9cd669 378
e106013f
SH
379 //$temp->add(new admin_setting_configcheckbox('backup/backup_auto_messages', new lang_string('messages', 'message'), new lang_string('backupmessageshelp','message'), 0));
380 //$temp->add(new admin_setting_configcheckbox('backup/backup_auto_blogs', new lang_string('blogs', 'blog'), new lang_string('backupblogshelp','blog'), 0));
7fb0303d 381
61ebef8f 382 $ADMIN->add('backups', $temp);
44e86fb3
MG
383
384 // Create a page for general restore configuration and defaults.
385 $temp = new admin_settingpage('restoregeneralsettings', new lang_string('generalrestoredefaults', 'backup'));
386
387 // General restore defaults.
388 $temp->add(new admin_setting_heading('generalsettings', new lang_string('generalrestoresettings', 'backup'), ''));
389
390 $temp->add(new admin_setting_configcheckbox_with_lock('restore/restore_general_users',
391 new lang_string('generalusers', 'backup'), new lang_string('configrestoreusers', 'backup'),
392 array('value' => 1, 'locked' => 0)));
393 // Can not use actual constants here because we'd need to include 100 of backup/restore files.
394 $options = [
395 0/*backup::ENROL_NEVER*/ => get_string('rootsettingenrolments_never', 'backup'),
396 1/*backup::ENROL_WITHUSERS*/ => get_string('rootsettingenrolments_withusers', 'backup'),
397 2/*backup::ENROL_ALWAYS*/ => get_string('rootsettingenrolments_always', 'backup'),
398 ];
399 $temp->add(new admin_setting_configselect_with_lock('restore/restore_general_enrolments',
400 new lang_string('generalenrolments', 'backup'), new lang_string('configrestoreenrolments', 'backup'),
401 array('value' => 1/*backup::ENROL_WITHUSERS*/, 'locked' => 0), $options));
402 $temp->add(new admin_setting_configcheckbox_with_lock('restore/restore_general_role_assignments',
403 new lang_string('generalroleassignments', 'backup'),
404 new lang_string('configrestoreroleassignments', 'backup'), array('value' => 1, 'locked' => 0)));
405 $temp->add(new admin_setting_configcheckbox_with_lock('restore/restore_general_activities',
406 new lang_string('generalactivities', 'backup'),
407 new lang_string('configrestoreactivities', 'backup'), array('value' => 1, 'locked' => 0)));
408 $temp->add(new admin_setting_configcheckbox_with_lock('restore/restore_general_blocks',
409 new lang_string('generalblocks', 'backup'),
410 new lang_string('configrestoreblocks', 'backup'), array('value' => 1, 'locked' => 0)));
411 $temp->add(new admin_setting_configcheckbox_with_lock('restore/restore_general_filters',
412 new lang_string('generalfilters', 'backup'),
413 new lang_string('configrestorefilters', 'backup'), array('value' => 1, 'locked' => 0)));
414 $temp->add(new admin_setting_configcheckbox_with_lock('restore/restore_general_comments',
415 new lang_string('generalcomments', 'backup'),
416 new lang_string('configrestorecomments', 'backup'), array('value' => 1, 'locked' => 0)));
417 $temp->add(new admin_setting_configcheckbox_with_lock('restore/restore_general_badges',
418 new lang_string('generalbadges', 'backup'),
419 new lang_string('configrestorebadges', 'backup'), array('value' => 1, 'locked' => 0)));
420 $temp->add(new admin_setting_configcheckbox_with_lock('restore/restore_general_calendarevents',
421 new lang_string('generalcalendarevents', 'backup'),
422 new lang_string('configrestorecalendarevents', 'backup'), array('value' => 1, 'locked' => 0)));
423 $temp->add(new admin_setting_configcheckbox_with_lock('restore/restore_general_userscompletion',
424 new lang_string('generaluserscompletion', 'backup'),
425 new lang_string('configrestoreuserscompletion', 'backup'), array('value' => 1, 'locked' => 0)));
426 $temp->add(new admin_setting_configcheckbox_with_lock('restore/restore_general_logs',
427 new lang_string('generallogs', 'backup'),
428 new lang_string('configrestorelogs', 'backup'), array('value' => 1, 'locked' => 0)));
429 $temp->add(new admin_setting_configcheckbox_with_lock('restore/restore_general_histories',
430 new lang_string('generalhistories', 'backup'),
431 new lang_string('configrestorehistories', 'backup'), array('value' => 1, 'locked' => 0)));
432 $temp->add(new admin_setting_configcheckbox_with_lock('restore/restore_general_groups',
433 new lang_string('generalgroups', 'backup'), new lang_string('configrestoregroups', 'backup'),
434 array('value' => 1, 'locked' => 0)));
435 $temp->add(new admin_setting_configcheckbox_with_lock('restore/restore_general_competencies',
436 new lang_string('generalcompetencies', 'backup'),
437 new lang_string('configrestorecompetencies', 'backup'), array('value' => 1, 'locked' => 0)));
438
439 // Restore defaults when merging into another course.
440 $temp->add(new admin_setting_heading('mergerestoredefaults', new lang_string('mergerestoredefaults', 'backup'), ''));
441
442 $temp->add(new admin_setting_configcheckbox_with_lock('restore/restore_merge_overwrite_conf',
443 new lang_string('setting_overwrite_conf', 'backup'),
444 new lang_string('config_overwrite_conf', 'backup'), array('value' => 0, 'locked' => 0)));
445
446 $temp->add(new admin_setting_configcheckbox_with_lock('restore/restore_merge_course_fullname',
447 new lang_string('setting_overwrite_course_fullname', 'backup'),
448 new lang_string('config_overwrite_course_fullname', 'backup'), array('value' => 1, 'locked' => 0)));
449 $temp->add(new admin_setting_configcheckbox_with_lock('restore/restore_merge_course_shortname',
450 new lang_string('setting_overwrite_course_shortname', 'backup'),
451 new lang_string('config_overwrite_course_shortname', 'backup'), array('value' => 1, 'locked' => 0)));
452 $temp->add(new admin_setting_configcheckbox_with_lock('restore/restore_merge_course_startdate',
453 new lang_string('setting_overwrite_course_startdate', 'backup'),
454 new lang_string('config_overwrite_course_startdate', 'backup'), array('value' => 1, 'locked' => 0)));
455
456 // Restore defaults when replacing course contents.
457 $temp->add(new admin_setting_heading('replacerestoredefaults', new lang_string('replacerestoredefaults', 'backup'), ''));
458
459 $temp->add(new admin_setting_configcheckbox_with_lock('restore/restore_replace_overwrite_conf',
460 new lang_string('setting_overwrite_conf', 'backup'),
461 new lang_string('config_overwrite_conf', 'backup'), array('value' => 0, 'locked' => 0)));
462
463 $temp->add(new admin_setting_configcheckbox_with_lock('restore/restore_replace_course_fullname',
464 new lang_string('setting_overwrite_course_fullname', 'backup'),
465 new lang_string('config_overwrite_course_fullname', 'backup'), array('value' => 1, 'locked' => 0)));
466 $temp->add(new admin_setting_configcheckbox_with_lock('restore/restore_replace_course_shortname',
467 new lang_string('setting_overwrite_course_shortname', 'backup'),
468 new lang_string('config_overwrite_course_shortname', 'backup'), array('value' => 1, 'locked' => 0)));
469 $temp->add(new admin_setting_configcheckbox_with_lock('restore/restore_replace_course_startdate',
470 new lang_string('setting_overwrite_course_startdate', 'backup'),
471 new lang_string('config_overwrite_course_startdate', 'backup'), array('value' => 1, 'locked' => 0)));
472
473 $temp->add(new admin_setting_configselect_with_lock('restore/restore_replace_keep_roles_and_enrolments',
474 new lang_string('setting_keep_roles_and_enrolments', 'backup'),
475 new lang_string('config_keep_roles_and_enrolments', 'backup'), array('value' => 0, 'locked' => 0),
476 array(1 => get_string('yes'), 0 => get_string('no'))));
477 $temp->add(new admin_setting_configselect_with_lock('restore/restore_replace_keep_groups_and_groupings',
478 new lang_string('setting_keep_groups_and_groupings', 'backup'),
479 new lang_string('config_keep_groups_and_groupings', 'backup'), array('value' => 0, 'locked' => 0),
480 array(1 => get_string('yes'), 0 => get_string('no'))));
481
482 $ADMIN->add('backups', $temp);
483
2cd901a4 484 // Create a page for asynchronous backup and restore configuration and defaults.
3ef9c2dc
AG
485 $temp = new admin_settingpage('asyncgeneralsettings', new lang_string('asyncgeneralsettings', 'backup'));
486
487 $temp->add(new admin_setting_configcheckbox('enableasyncbackup', new lang_string('enableasyncbackup', 'backup'),
488 new lang_string('enableasyncbackup_help', 'backup'), 0, 1, 0));
489
490 $temp->add(new admin_setting_configcheckbox(
491 'backup/backup_async_message_users',
492 new lang_string('asyncemailenable', 'backup'),
493 new lang_string('asyncemailenabledetail', 'backup'), 0));
494 $temp->hide_if('backup/backup_async_message_users', 'enableasyncbackup');
495
496 $temp->add(new admin_setting_configtext(
497 'backup/backup_async_message_subject',
498 new lang_string('asyncmessagesubject', 'backup'),
499 new lang_string('asyncmessagesubjectdetail', 'backup'),
500 new lang_string('asyncmessagesubjectdefault', 'backup')));
501 $temp->hide_if('backup/backup_async_message_subject', 'backup/backup_async_message_users');
502
503 $temp->add(new admin_setting_confightmleditor(
504 'backup/backup_async_message',
505 new lang_string('asyncmessagebody', 'backup'),
506 new lang_string('asyncmessagebodydetail', 'backup'),
507 new lang_string('asyncmessagebodydefault', 'backup')));
508 $temp->hide_if('backup/backup_async_message', 'backup/backup_async_message_users');
509
510 $ADMIN->add('backups', $temp);
2cd901a4 511
5dc361e1 512}