The handlers now throw moodle1_convert_exception instead of convert_exception
[moodle.git] / admin / settings / frontpage.php
blob4180579032ab8cca9306cb11b37a91651b06e0ee
1 <?php
3 // This file defines everything related to frontpage
5 if (!during_initial_install()) { //do not use during installation
6 $frontpagecontext = get_context_instance(CONTEXT_COURSE, SITEID);
8 if ($hassiteconfig or has_any_capability(array(
9 'moodle/course:update',
10 'moodle/role:assign',
11 'moodle/restore:restorecourse',
12 'moodle/backup:backupcourse',
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)) {
22 // "frontpage" settingpage
23 $temp = new admin_settingpage('frontpagesettings', get_string('frontpagesettings','admin'), 'moodle/course:update', false, $frontpagecontext);
24 $temp->add(new admin_setting_sitesettext('fullname', get_string('fullsitename'), '', NULL)); // no default
25 $temp->add(new admin_setting_sitesettext('shortname', get_string('shortsitename'), '', NULL)); // no default
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
30 $options = array();
31 $options[] = get_string('unlimited');
32 for ($i=1; $i<100; $i++) {
33 $options[$i] = $i;
35 $temp->add(new admin_setting_configselect('maxcategorydepth', get_string('configsitemaxcategorydepth','admin'), get_string('configsitemaxcategorydepthhelp','admin'), 0, $options));
37 $temp->add(new admin_setting_sitesetcheckbox('numsections', get_string('sitesection'), get_string('sitesectionhelp','admin'), 1));
38 $temp->add(new admin_setting_sitesetselect('newsitems', get_string('newsitemsnumber'), '', 3,
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')));
50 $temp->add(new admin_setting_configtext('commentsperpage', get_string('commentsperpage', 'admin'), '', 15, PARAM_INT));
52 $temp->add(new admin_setting_configtext('coursesperpage', get_string('coursesperpage', 'admin'), get_string('configcoursesperpage', 'admin'), 20, PARAM_INT));
54 // front page default role
55 $options = array(0=>get_string('none')); // roles to choose from
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;
65 if ($defaultfrontpageroleid and (!isset($CFG->defaultfrontpageroleid) or $CFG->defaultfrontpageroleid)) {
66 //frotpage role may not exist in old upgraded sites
67 unset($options[0]);
69 $temp->add(new admin_setting_configselect('defaultfrontpageroleid', get_string('frontpagedefaultrole', 'admin'), '', $defaultfrontpageroleid, $options));
72 $ADMIN->add('frontpage', $temp);
74 $ADMIN->add('frontpage', new admin_externalpage('frontpageroles', get_string('frontpageroles', 'admin'), "$CFG->wwwroot/$CFG->admin/roles/assign.php?contextid=" . $frontpagecontext->id, 'moodle/role:assign', false, $frontpagecontext));
76 $ADMIN->add('frontpage', new admin_externalpage('frontpagefilters', get_string('frontpagefilters', 'admin'), "$CFG->wwwroot/filter/manage.php?contextid=" . $frontpagecontext->id, 'moodle/filter:manage', false, $frontpagecontext));
78 $ADMIN->add('frontpage', new admin_externalpage('frontpagebackup', get_string('frontpagebackup', 'admin'), $CFG->wwwroot.'/backup/backup.php?id='.SITEID, 'moodle/backup:backupcourse', false, $frontpagecontext));
80 $ADMIN->add('frontpage', new admin_externalpage('frontpagerestore', get_string('frontpagerestore', 'admin'), $CFG->wwwroot.'/files/index.php?id='.SITEID.'&amp;wdir=/backupdata', 'moodle/restore:restorecourse', false, $frontpagecontext));
82 $questioncapabilities = array(
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');
90 $ADMIN->add('frontpage', new admin_externalpage('frontpagequestions', get_string('frontpagequestions', 'admin'), $CFG->wwwroot.'/question/edit.php?courseid='.SITEID, $questioncapabilities, false, $frontpagecontext));
92 if (!empty($SITE->legacyfiles) and $SITE->legacyfiles === 2) {
93 $ADMIN->add('frontpage', new admin_externalpage('sitefiles', get_string('sitelegacyfiles'), $CFG->wwwroot . '/files/index.php?id=' . SITEID, 'moodle/course:managefiles', false, $frontpagecontext));