'added felxible columns and round corner code'
[moodle.git] / admin / settings.php
CommitLineData
90a73bb3 1<?php // $Id$
2
3require_once('../config.php');
6e4dc10f 4require_once($CFG->libdir.'/adminlib.php');
02cc05a7 5require_once($CFG->libdir.'/blocklib.php');
6require_once($CFG->dirroot.'/'.$CFG->admin.'/pagelib.php');
63aafc9e 7
8if ($site = get_site()) {
9 require_login();
eef868d1 10}
63aafc9e 11
90a73bb3 12
02cc05a7 13page_map_class(PAGE_ADMIN, 'page_admin');
90a73bb3 14
e9a20759 15$PAGE = page_create_object(PAGE_ADMIN, 0); // there must be any constant id number
63aafc9e 16
6fcbab99 17$section = optional_param('section', '', PARAM_ALPHAEXT);
18
02cc05a7 19$PAGE->init_extra($section); // hack alert!
63aafc9e 20
21$adminediting = optional_param('adminedit', -1, PARAM_BOOL);
e0f6e995 22$return = optional_param('return','', PARAM_ALPHA);
eef868d1 23
3d8ef99d 24if (!isset($USER->adminediting)) {
d83f27ce 25 $USER->adminediting = false;
3d8ef99d 26}
27
28if ($PAGE->user_allowed_editing()) {
63aafc9e 29 if ($adminediting == 1) {
3d8ef99d 30 $USER->adminediting = true;
63aafc9e 31 } elseif ($adminediting == 0) {
3d8ef99d 32 $USER->adminediting = false;
33 }
34}
35
6e4dc10f 36$adminroot = admin_get_root();
90a73bb3 37
6e4dc10f 38$root = $adminroot->locate($PAGE->section);
90a73bb3 39
63aafc9e 40if (!is_a($root, 'admin_settingpage')) {
41 error(get_string('sectionerror', 'admin'));
6fcbab99 42 die;
63aafc9e 43}
90a73bb3 44
63aafc9e 45if (!($root->check_access())) {
46 error(get_string('accessdenied', 'admin'));
6fcbab99 47 die;
63aafc9e 48}
90a73bb3 49
6ea5ff3a 50$CFG->pagepath = 'admin/setting/'.$section;
51
c6d33fce 52
53
e268cc4a 54/// WRITING SUBMITTED DATA (IF ANY) -------------------------------------------------------------------------------
c6d33fce 55
e268cc4a 56$statusmsg = '';
90a73bb3 57
58if ($data = data_submitted()) {
59 if (confirm_sesskey()) {
fefea008 60 $olddbsessions = !empty($CFG->dbsessions);
56909d26 61 $unslashed = (array)stripslashes_recursive($data);
9cdb766d 62 $errors = $root->write_settings($unslashed);
fefea008 63 //force logout if dbsession setting changes
64 if ($olddbsessions != !empty($CFG->dbsessions)) {
65 require_logout();
66 }
90a73bb3 67 if (empty($errors)) {
e0f6e995 68 switch ($return) {
69 case 'site':
55f3a4db 70 redirect("$CFG->wwwroot/");
e0f6e995 71 case 'admin':
6859360c 72 redirect("$CFG->wwwroot/$CFG->admin/");
e0f6e995 73 default:
e268cc4a 74 $statusmsg = get_string('changessaved');
e0f6e995 75 }
6fcbab99 76 } else {
e268cc4a 77 $statusmsg = get_string('errorwithsettings', 'admin') . ' <br />' . $errors;
6fcbab99 78 }
79 } else {
80 error(get_string('confirmsesskeybad', 'error'));
6fcbab99 81 }
23a97d83 82 // now update $SITE - it might have been changed
83 $SITE = get_record('course', 'id', $SITE->id);
b89639f9 84 $COURSE = clone($SITE);
90a73bb3 85}
86
90a73bb3 87
e268cc4a 88/// print header stuff ------------------------------------------------------------
89// header must be printed after the redirects and require_logout
90if (!empty($SITE->fullname)) {
91 $pageblocks = blocks_setup($PAGE);
92
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);
90a73bb3 97
e268cc4a 98 $PAGE->print_header();
99
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>';
fb87a619 104 echo '<td id="middle-column"><a name="startofcontent"></a>';
e268cc4a 105} else {
106
107 print_header();
108 print_simple_box(get_string('configintrosite', 'admin'), 'center', '50%');
109
110}
111
112if ($statusmsg != '') {
113 notify ($statusmsg);
114}
115
116// ---------------------------------------------------------------------------------------------------------------
90a73bb3 117
b7dc2256 118echo '<form action="settings.php" method="post" id="adminsettings">';
53add79a 119echo '<div class="settingsform">';
90a73bb3 120echo '<input type="hidden" name="section" value="' . $PAGE->section . '" />';
121echo '<input type="hidden" name="sesskey" value="' . $USER->sesskey . '" />';
e0f6e995 122echo '<input type="hidden" name="return" value="' . $return . '" />';
50999a0b 123print_heading($root->visiblename);
90a73bb3 124
125echo $root->output_html();
126
14f35856 127echo '<div class="form-buttons"><input class="form-submit" type="submit" value="' . get_string('savechanges','admin') . '" /></div>';
fa040029 128
53add79a 129echo '</div>';
d83f27ce 130echo '</form>';
b1ce7811 131
132if (!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>';
137}
90a73bb3 138
fa040029 139if (!empty($CFG->adminusehtmleditor)) {
140 use_html_editor();
141}
142
63aafc9e 143print_footer();
90a73bb3 144
bee4702d 145?>