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 (!empty($THEME->customcorners
)) {
9 require_once($CFG->dirroot
.'/lib/custom_corners_lib.php');
12 if ($site = get_site()) {
17 page_map_class(PAGE_ADMIN
, 'page_admin');
19 $PAGE = page_create_object(PAGE_ADMIN
, 0); // there must be any constant id number
21 $section = optional_param('section', '', PARAM_ALPHAEXT
);
23 $PAGE->init_extra($section); // hack alert!
25 $adminediting = optional_param('adminedit', -1, PARAM_BOOL
);
26 $return = optional_param('return','', PARAM_ALPHA
);
28 if (!isset($USER->adminediting
)) {
29 $USER->adminediting
= false;
32 if ($PAGE->user_allowed_editing()) {
33 if ($adminediting == 1) {
34 $USER->adminediting
= true;
35 } elseif ($adminediting == 0) {
36 $USER->adminediting
= false;
40 $adminroot = admin_get_root();
42 $root = $adminroot->locate($PAGE->section
);
44 if (!is_a($root, 'admin_settingpage')) {
45 error(get_string('sectionerror', 'admin'));
49 if (!($root->check_access())) {
50 error(get_string('accessdenied', 'admin'));
54 $CFG->pagepath
= 'admin/setting/'.$section;
58 /// WRITING SUBMITTED DATA (IF ANY) -------------------------------------------------------------------------------
62 if ($data = data_submitted()) {
63 if (confirm_sesskey()) {
64 $olddbsessions = !empty($CFG->dbsessions
);
65 $unslashed = (array)stripslashes_recursive($data);
66 $errors = $root->write_settings($unslashed);
67 //force logout if dbsession setting changes
68 if ($olddbsessions != !empty($CFG->dbsessions
)) {
74 redirect("$CFG->wwwroot/");
76 redirect("$CFG->wwwroot/$CFG->admin/");
78 $statusmsg = get_string('changessaved');
81 $statusmsg = get_string('errorwithsettings', 'admin') . ' <br />' . $errors;
84 error(get_string('confirmsesskeybad', 'error'));
86 // now update $SITE - it might have been changed
87 $SITE = get_record('course', 'id', $SITE->id
);
88 $COURSE = clone($SITE);
92 /// print header stuff ------------------------------------------------------------
93 // header must be printed after the redirects and require_logout
95 if (empty($SITE->fullname
)) {
96 print_header($root->visiblename
, $root->visiblename
);
97 print_simple_box(get_string('configintrosite', 'admin'), 'center', '50%');
99 if ($statusmsg != '') {
103 // ---------------------------------------------------------------------------------------------------------------
105 echo '<form action="settings.php" method="post" id="adminsettings">';
106 echo '<div class="settingsform">';
107 echo '<input type="hidden" name="section" value="' . $PAGE->section
. '" />';
108 echo '<input type="hidden" name="sesskey" value="' . $USER->sesskey
. '" />';
109 echo '<input type="hidden" name="return" value="' . $return . '" />';
111 echo $root->output_html();
113 echo '<div class="form-buttons"><input class="form-submit" type="submit" value="' . get_string('savechanges','admin') . '" /></div>';
119 if (!empty($SITE->fullname
)) {
120 $pageblocks = blocks_setup($PAGE);
122 $preferred_width_left = bounded_number(BLOCK_L_MIN_WIDTH
, blocks_preferred_width($pageblocks[BLOCK_POS_LEFT
]),
124 $preferred_width_right = bounded_number(BLOCK_R_MIN_WIDTH
, blocks_preferred_width($pageblocks[BLOCK_POS_RIGHT
]),
127 $PAGE->print_header();
129 echo '<table id="layout-table"><tr>';
130 $lt = (empty($THEME->layouttable
)) ?
array('left', 'middle', 'right') : $THEME->layouttable
;
131 foreach ($lt as $column) {
134 echo '<td style="width: ' . $preferred_width_left . 'px;" id="left-column">';
135 if (!empty($THEME->customcorners
)) print_custom_corners_start();
136 blocks_print_group($PAGE, $pageblocks, BLOCK_POS_LEFT
);
137 if (!empty($THEME->customcorners
)) print_custom_corners_end();
141 echo '<td id="middle-column">';
142 if (!empty($THEME->customcorners
)) print_custom_corners_start();
143 echo '<a name="startofcontent"></a>';
145 if ($statusmsg != '') {
149 // ---------------------------------------------------------------------------------------------------------------
151 echo '<form action="settings.php" method="post" id="adminsettings">';
152 echo '<div class="settingsform">';
153 echo '<input type="hidden" name="section" value="' . $PAGE->section
. '" />';
154 echo '<input type="hidden" name="sesskey" value="' . $USER->sesskey
. '" />';
155 echo '<input type="hidden" name="return" value="' . $return . '" />';
156 print_heading($root->visiblename
);
158 echo $root->output_html();
160 echo '<div class="form-buttons"><input class="form-submit" type="submit" value="' . get_string('savechanges','admin') . '" /></div>';
165 if (!empty($THEME->customcorners
)) print_custom_corners_end();
169 if (blocks_have_content($pageblocks, BLOCK_POS_RIGHT
)) {
170 echo '<td style="width: ' . $preferred_width_right . 'px;" id="right-column">';
171 if (!empty($THEME->customcorners
)) print_custom_corners_start();
172 blocks_print_group($PAGE, $pageblocks, BLOCK_POS_RIGHT
);
173 if (!empty($THEME->customcorners
)) print_custom_corners_end();
179 echo '</tr></table>';
182 if (!empty($CFG->adminusehtmleditor
)) {