Output was missing utf8 meta tag.
[moodle-linuxchix.git] / admin / settings.php
blob92b4370716403994362b279e697ec1f1b624ad51
1 <?php // $Id$
3 require_once('../config.php');
4 require_once($CFG->libdir.'/adminlib.php');
5 require_once($CFG->libdir.'/blocklib.php');
6 require_once($CFG->dirroot.'/'.$CFG->admin.'/pagelib.php');
8 if ($site = get_site()) {
9 require_login();
13 page_map_class(PAGE_ADMIN, 'page_admin');
15 $PAGE = page_create_object(PAGE_ADMIN, 0); // there must be any constant id number
17 $section = optional_param('section', '', PARAM_ALPHAEXT);
19 $PAGE->init_extra($section); // hack alert!
21 $adminediting = optional_param('adminedit', -1, PARAM_BOOL);
22 $return = optional_param('return','', PARAM_ALPHA);
24 if (!isset($USER->adminediting)) {
25 $USER->adminediting = false;
28 if ($PAGE->user_allowed_editing()) {
29 if ($adminediting == 1) {
30 $USER->adminediting = true;
31 } elseif ($adminediting == 0) {
32 $USER->adminediting = false;
36 $adminroot = admin_get_root();
38 $root = $adminroot->locate($PAGE->section);
40 if (!is_a($root, 'admin_settingpage')) {
41 error(get_string('sectionerror', 'admin'));
42 die;
45 if (!($root->check_access())) {
46 error(get_string('accessdenied', 'admin'));
47 die;
50 $CFG->pagepath = 'admin/setting/'.$section;
54 /// WRITING SUBMITTED DATA (IF ANY) -------------------------------------------------------------------------------
56 $statusmsg = '';
58 if ($data = data_submitted()) {
59 if (confirm_sesskey()) {
60 $olddbsessions = !empty($CFG->dbsessions);
61 $unslashed = (array)stripslashes_recursive($data);
62 $errors = $root->write_settings($unslashed);
63 //force logout if dbsession setting changes
64 if ($olddbsessions != !empty($CFG->dbsessions)) {
65 require_logout();
67 if (empty($errors)) {
68 switch ($return) {
69 case 'site':
70 redirect("$CFG->wwwroot/");
71 case 'admin':
72 redirect("$CFG->wwwroot/$CFG->admin/");
73 default:
74 $statusmsg = get_string('changessaved');
76 } else {
77 $statusmsg = get_string('errorwithsettings', 'admin') . ' <br />' . $errors;
79 } else {
80 error(get_string('confirmsesskeybad', 'error'));
82 // now update $SITE - it might have been changed
83 $SITE = get_record('course', 'id', $SITE->id);
84 $COURSE = clone($SITE);
88 /// print header stuff ------------------------------------------------------------
89 // header must be printed after the redirects and require_logout
90 if (!empty($SITE->fullname)) {
91 $pageblocks = blocks_setup($PAGE);
93 $preferred_width_left = bounded_number(BLOCK_L_MIN_WIDTH, blocks_preferred_width($pageblocks[BLOCK_POS_LEFT]),
94 BLOCK_L_MAX_WIDTH);
95 $preferred_width_right = bounded_number(BLOCK_R_MIN_WIDTH, blocks_preferred_width($pageblocks[BLOCK_POS_RIGHT]),
96 BLOCK_R_MAX_WIDTH);
98 $PAGE->print_header();
100 echo '<table id="layout-table"><tr>';
101 echo '<td style="width: ' . $preferred_width_left . 'px;" id="left-column">';
102 blocks_print_group($PAGE, $pageblocks, BLOCK_POS_LEFT);
103 echo '</td>';
104 echo '<td id="middle-column"><a name="startofcontent"></a>';
105 } else {
107 print_header();
108 print_simple_box(get_string('configintrosite', 'admin'), 'center', '50%');
112 if ($statusmsg != '') {
113 notify ($statusmsg);
116 // ---------------------------------------------------------------------------------------------------------------
118 echo '<form action="settings.php" method="post" id="adminsettings">';
119 echo '<div class="settingsform">';
120 echo '<input type="hidden" name="section" value="' . $PAGE->section . '" />';
121 echo '<input type="hidden" name="sesskey" value="' . $USER->sesskey . '" />';
122 echo '<input type="hidden" name="return" value="' . $return . '" />';
123 print_heading($root->visiblename);
125 echo $root->output_html();
127 echo '<div class="form-buttons"><input class="form-submit" type="submit" value="' . get_string('savechanges','admin') . '" /></div>';
129 echo '</div>';
130 echo '</form>';
132 if (!empty($SITE->fullname)) {
133 echo '</td>';
134 echo '<td style="width: ' . $preferred_width_right . 'px;" id="right-column">';
135 blocks_print_group($PAGE, $pageblocks, BLOCK_POS_RIGHT);
136 echo '</td></tr></table>';
139 if (!empty($CFG->adminusehtmleditor)) {
140 use_html_editor();
143 print_footer();