MDL-27800 admin: make front page restore link consistent
[moodle.git] / admin / settings / frontpage.php
CommitLineData
11b749ca 1<?php
84c8ede0 2
3// This file defines everything related to frontpage
4
d628171f 5if (!during_initial_install()) { //do not use during installation
01e85af9 6 $frontpagecontext = get_context_instance(CONTEXT_COURSE, SITEID);
84c8ede0 7
3fc3ebf2 8 if ($hassiteconfig or has_any_capability(array(
9 'moodle/course:update',
10 'moodle/role:assign',
d2940003
EL
11 'moodle/restore:restorecourse',
12 'moodle/backup:backupcourse',
3fc3ebf2 13 'moodle/course:managefiles',
14 'moodle/question:add',
15 'moodle/question:editmine',
16 'moodle/question:editall',
17 'moodle/question:viewmine',
18 'moodle/question:viewall',
19 'moodle/question:movemine',
20 'moodle/question:moveall'), $frontpagecontext)) {
a559f630 21
8e5da17a 22 // "frontpage" settingpage
e106013f
SH
23 $temp = new admin_settingpage('frontpagesettings', new lang_string('frontpagesettings','admin'), 'moodle/course:update', false, $frontpagecontext);
24 $temp->add(new admin_setting_sitesettext('fullname', new lang_string('fullsitename'), '', NULL)); // no default
25 $temp->add(new admin_setting_sitesettext('shortname', new lang_string('shortsitename'), '', NULL)); // no default
8e5da17a 26 $temp->add(new admin_setting_special_frontpagedesc());
27 $temp->add(new admin_setting_courselist_frontpage(false)); // non-loggedin version of the setting (that's what the parameter is for :) )
28 $temp->add(new admin_setting_courselist_frontpage(true)); // loggedin version of the setting
11b749ca 29
6bfc7fd5 30 $options = array();
e106013f 31 $options[] = new lang_string('unlimited');
6bfc7fd5 32 for ($i=1; $i<100; $i++) {
33 $options[$i] = $i;
34 }
e106013f 35 $temp->add(new admin_setting_configselect('maxcategorydepth', new lang_string('configsitemaxcategorydepth','admin'), new lang_string('configsitemaxcategorydepthhelp','admin'), 0, $options));
11b749ca 36
e106013f
SH
37 $temp->add(new admin_setting_sitesetcheckbox('numsections', new lang_string('sitesection'), new lang_string('sitesectionhelp','admin'), 1));
38 $temp->add(new admin_setting_sitesetselect('newsitems', new lang_string('newsitemsnumber'), '', 3,
8e5da17a 39 array('0' => '0',
40 '1' => '1',
41 '2' => '2',
42 '3' => '3',
43 '4' => '4',
44 '5' => '5',
45 '6' => '6',
46 '7' => '7',
47 '8' => '8',
48 '9' => '9',
49 '10' => '10')));
e106013f 50 $temp->add(new admin_setting_configtext('commentsperpage', new lang_string('commentsperpage', 'admin'), '', 15, PARAM_INT));
cf456fbf 51
e106013f 52 $temp->add(new admin_setting_configtext('coursesperpage', new lang_string('coursesperpage', 'admin'), new lang_string('configcoursesperpage', 'admin'), 20, PARAM_INT));
8e5da17a 53
54 // front page default role
e106013f 55 $options = array(0=>new lang_string('none')); // roles to choose from
82053cb1
PS
56 $defaultfrontpageroleid = 0;
57 foreach (get_all_roles() as $role) {
58 if (empty($role->archetype) or $role->archetype === 'guest' or $role->archetype === 'frontpage' or $role->archetype === 'student') {
59 $options[$role->id] = strip_tags(format_string($role->name)) . ' ('. $role->shortname . ')';
60 if ($role->archetype === 'frontpage') {
61 $defaultfrontpageroleid = $role->id;
62 }
8e5da17a 63 }
8e5da17a 64 }
82053cb1
PS
65 if ($defaultfrontpageroleid and (!isset($CFG->defaultfrontpageroleid) or $CFG->defaultfrontpageroleid)) {
66 //frotpage role may not exist in old upgraded sites
67 unset($options[0]);
68 }
e106013f 69 $temp->add(new admin_setting_configselect('defaultfrontpageroleid', new lang_string('frontpagedefaultrole', 'admin'), '', $defaultfrontpageroleid, $options));
82053cb1 70
8e5da17a 71
72 $ADMIN->add('frontpage', $temp);
73
e106013f 74 $ADMIN->add('frontpage', new admin_externalpage('frontpageroles', new lang_string('frontpageroles', 'admin'), "$CFG->wwwroot/$CFG->admin/roles/assign.php?contextid=" . $frontpagecontext->id, 'moodle/role:assign', false, $frontpagecontext));
8e5da17a 75
e106013f 76 $ADMIN->add('frontpage', new admin_externalpage('frontpagefilters', new lang_string('frontpagefilters', 'admin'), "$CFG->wwwroot/filter/manage.php?contextid=" . $frontpagecontext->id, 'moodle/filter:manage', false, $frontpagecontext));
0f74bb01 77
e106013f 78 $ADMIN->add('frontpage', new admin_externalpage('frontpagebackup', new lang_string('frontpagebackup', 'admin'), $CFG->wwwroot.'/backup/backup.php?id='.SITEID, 'moodle/backup:backupcourse', false, $frontpagecontext));
8e5da17a 79
d563d486 80 $ADMIN->add('frontpage', new admin_externalpage('frontpagerestore', new lang_string('frontpagerestore', 'admin'), $CFG->wwwroot.'/backup/restorefile.php?contextid='.$frontpagecontext->id, 'moodle/restore:restorecourse', false, $frontpagecontext));
8e5da17a 81
eab8ed9f 82 $questioncapabilities = array(
60ff0c54 83 'moodle/question:add',
84 'moodle/question:editmine',
85 'moodle/question:editall',
86 'moodle/question:viewmine',
87 'moodle/question:viewall',
88 'moodle/question:movemine',
89 'moodle/question:moveall');
e106013f 90 $ADMIN->add('frontpage', new admin_externalpage('frontpagequestions', new lang_string('frontpagequestions', 'admin'), $CFG->wwwroot.'/question/edit.php?courseid='.SITEID, $questioncapabilities, false, $frontpagecontext));
60ff0c54 91
69816a5c 92 if (!empty($SITE->legacyfiles) and $SITE->legacyfiles === 2) {
e106013f 93 $ADMIN->add('frontpage', new admin_externalpage('sitefiles', new lang_string('sitelegacyfiles'), $CFG->wwwroot . '/files/index.php?id=' . SITEID, 'moodle/course:managefiles', false, $frontpagecontext));
69816a5c 94 }
4e1fe7d1 95 }
96}