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
91 if (empty($SITE->fullname
)) {
92 print_header($root->visiblename
, $root->visiblename
);
93 print_simple_box(get_string('configintrosite', 'admin'), 'center', '50%');
95 if ($statusmsg != '') {
99 // ---------------------------------------------------------------------------------------------------------------
101 echo '<form action="settings.php" method="post" id="adminsettings">';
102 echo '<div class="settingsform">';
103 echo '<input type="hidden" name="section" value="' . $PAGE->section
. '" />';
104 echo '<input type="hidden" name="sesskey" value="' . $USER->sesskey
. '" />';
105 echo '<input type="hidden" name="return" value="' . $return . '" />';
107 echo $root->output_html();
109 echo '<div class="form-buttons"><input class="form-submit" type="submit" value="' . get_string('savechanges','admin') . '" /></div>';
115 if (!empty($SITE->fullname
)) {
116 $pageblocks = blocks_setup($PAGE);
118 $preferred_width_left = bounded_number(BLOCK_L_MIN_WIDTH
, blocks_preferred_width($pageblocks[BLOCK_POS_LEFT
]),
120 $preferred_width_right = bounded_number(BLOCK_R_MIN_WIDTH
, blocks_preferred_width($pageblocks[BLOCK_POS_RIGHT
]),
123 $PAGE->print_header();
125 echo '<table id="layout-table"><tr>';
126 $lt = (empty($THEME->layouttable
)) ?
array('left', 'middle', 'right') : $THEME->layouttable
;
127 foreach ($lt as $column) {
130 echo '<td style="width: ' . $preferred_width_left . 'px;" id="left-column">';
131 if (!empty($THEME->roundcorners
)) {
132 echo '<div class="bt"><div></div></div>';
133 echo '<div class="i1"><div class="i2"><div class="i3">';
135 blocks_print_group($PAGE, $pageblocks, BLOCK_POS_LEFT
);
136 if (!empty($THEME->roundcorners
)) {
137 echo '</div></div></div>';
138 echo '<div class="bb"><div></div></div>';
143 echo '<td id="middle-column">';
144 if (!empty($THEME->roundcorners
)) {
145 echo '<div class="bt"><div></div></div>';
146 echo '<div class="i1"><div class="i2"><div class="i3">';
148 echo '<a name="startofcontent"></a>';
150 if ($statusmsg != '') {
154 // ---------------------------------------------------------------------------------------------------------------
156 echo '<form action="settings.php" method="post" id="adminsettings">';
157 echo '<div class="settingsform">';
158 echo '<input type="hidden" name="section" value="' . $PAGE->section
. '" />';
159 echo '<input type="hidden" name="sesskey" value="' . $USER->sesskey
. '" />';
160 echo '<input type="hidden" name="return" value="' . $return . '" />';
161 print_heading($root->visiblename
);
163 echo $root->output_html();
165 echo '<div class="form-buttons"><input class="form-submit" type="submit" value="' . get_string('savechanges','admin') . '" /></div>';
170 if (!empty($THEME->roundcorners
)) {
171 echo '</div></div></div>';
172 echo '<div class="bb"><div></div></div>';
177 if (blocks_have_content($pageblocks, BLOCK_POS_RIGHT
)) {
178 echo '<td style="width: ' . $preferred_width_right . 'px;" id="right-column">';
179 if (!empty($THEME->roundcorners
)) {
180 echo '<div class="bt"><div></div></div>';
181 echo '<div class="i1"><div class="i2"><div class="i3">';
183 blocks_print_group($PAGE, $pageblocks, BLOCK_POS_RIGHT
);
184 if (!empty($THEME->roundcorners
)) {
185 echo '</div></div></div>';
186 echo '<div class="bb"><div></div></div>';
193 echo '</tr></table>';
196 if (!empty($CFG->adminusehtmleditor
)) {