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()) {
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'));
45 if (!($root->check_access())) {
46 error(get_string('accessdenied', 'admin'));
50 $CFG->pagepath
= 'admin/setting/'.$section;
54 /// WRITING SUBMITTED DATA (IF ANY) -------------------------------------------------------------------------------
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
)) {
70 redirect("$CFG->wwwroot/");
72 redirect("$CFG->wwwroot/$CFG->admin/");
74 $statusmsg = get_string('changessaved');
77 $statusmsg = get_string('errorwithsettings', 'admin') . ' <br />' . $errors;
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
]),
95 $preferred_width_right = bounded_number(BLOCK_R_MIN_WIDTH
, blocks_preferred_width($pageblocks[BLOCK_POS_RIGHT
]),
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
);
104 echo '<td id="middle-column"><a name="startofcontent"></a>';
108 print_simple_box(get_string('configintrosite', 'admin'), 'center', '50%');
112 if ($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>';
132 if (!empty($SITE->fullname
)) {
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
)) {