2006-08-18 07:25:17 +00:00
|
|
|
<?php // $Id$
|
|
|
|
|
|
|
|
require_once('../config.php');
|
2006-09-02 13:14:57 +00:00
|
|
|
require_once($CFG->libdir.'/adminlib.php');
|
2006-09-02 23:55:56 +00:00
|
|
|
require_once($CFG->libdir.'/blocklib.php');
|
|
|
|
require_once($CFG->dirroot.'/'.$CFG->admin.'/pagelib.php');
|
2006-08-19 01:37:38 +00:00
|
|
|
|
2007-05-09 14:39:13 +00:00
|
|
|
if (!empty($THEME->customcorners)) {
|
|
|
|
require_once($CFG->dirroot.'/lib/custom_corners_lib.php');
|
|
|
|
}
|
|
|
|
|
2006-08-19 01:37:38 +00:00
|
|
|
if ($site = get_site()) {
|
|
|
|
require_login();
|
2006-09-20 21:00:45 +00:00
|
|
|
}
|
2006-08-19 01:37:38 +00:00
|
|
|
|
2006-08-18 07:25:17 +00:00
|
|
|
|
2006-09-02 23:55:56 +00:00
|
|
|
page_map_class(PAGE_ADMIN, 'page_admin');
|
2006-08-18 07:25:17 +00:00
|
|
|
|
2006-09-03 17:46:27 +00:00
|
|
|
$PAGE = page_create_object(PAGE_ADMIN, 0); // there must be any constant id number
|
2006-08-19 01:37:38 +00:00
|
|
|
|
2006-08-21 04:06:58 +00:00
|
|
|
$section = optional_param('section', '', PARAM_ALPHAEXT);
|
|
|
|
|
2006-09-02 23:55:56 +00:00
|
|
|
$PAGE->init_extra($section); // hack alert!
|
2006-08-19 01:37:38 +00:00
|
|
|
|
|
|
|
$adminediting = optional_param('adminedit', -1, PARAM_BOOL);
|
2006-09-02 15:29:52 +00:00
|
|
|
$return = optional_param('return','', PARAM_ALPHA);
|
2006-09-20 21:00:45 +00:00
|
|
|
|
2006-08-18 22:00:37 +00:00
|
|
|
if (!isset($USER->adminediting)) {
|
2006-08-28 01:31:37 +00:00
|
|
|
$USER->adminediting = false;
|
2006-08-18 22:00:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if ($PAGE->user_allowed_editing()) {
|
2006-08-19 01:37:38 +00:00
|
|
|
if ($adminediting == 1) {
|
2006-08-18 22:00:37 +00:00
|
|
|
$USER->adminediting = true;
|
2006-08-19 01:37:38 +00:00
|
|
|
} elseif ($adminediting == 0) {
|
2006-08-18 22:00:37 +00:00
|
|
|
$USER->adminediting = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-09-02 13:14:57 +00:00
|
|
|
$adminroot = admin_get_root();
|
2006-08-18 07:25:17 +00:00
|
|
|
|
2006-09-02 13:14:57 +00:00
|
|
|
$root = $adminroot->locate($PAGE->section);
|
2006-08-18 07:25:17 +00:00
|
|
|
|
2006-08-19 01:37:38 +00:00
|
|
|
if (!is_a($root, 'admin_settingpage')) {
|
|
|
|
error(get_string('sectionerror', 'admin'));
|
2006-08-21 04:06:58 +00:00
|
|
|
die;
|
2006-08-19 01:37:38 +00:00
|
|
|
}
|
2006-08-18 07:25:17 +00:00
|
|
|
|
2006-08-19 01:37:38 +00:00
|
|
|
if (!($root->check_access())) {
|
|
|
|
error(get_string('accessdenied', 'admin'));
|
2006-08-21 04:06:58 +00:00
|
|
|
die;
|
2006-08-19 01:37:38 +00:00
|
|
|
}
|
2006-08-18 07:25:17 +00:00
|
|
|
|
2006-09-04 08:33:57 +00:00
|
|
|
$CFG->pagepath = 'admin/setting/'.$section;
|
|
|
|
|
2006-10-12 03:31:48 +00:00
|
|
|
|
|
|
|
|
2006-10-16 06:52:01 +00:00
|
|
|
/// WRITING SUBMITTED DATA (IF ANY) -------------------------------------------------------------------------------
|
2006-10-12 03:31:48 +00:00
|
|
|
|
2006-10-16 06:52:01 +00:00
|
|
|
$statusmsg = '';
|
2006-08-18 07:25:17 +00:00
|
|
|
|
|
|
|
if ($data = data_submitted()) {
|
|
|
|
if (confirm_sesskey()) {
|
2006-09-10 11:15:31 +00:00
|
|
|
$olddbsessions = !empty($CFG->dbsessions);
|
2006-11-30 20:37:14 +00:00
|
|
|
$unslashed = (array)stripslashes_recursive($data);
|
2006-11-27 08:44:38 +00:00
|
|
|
$errors = $root->write_settings($unslashed);
|
2006-09-10 11:15:31 +00:00
|
|
|
//force logout if dbsession setting changes
|
|
|
|
if ($olddbsessions != !empty($CFG->dbsessions)) {
|
|
|
|
require_logout();
|
|
|
|
}
|
2006-08-18 07:25:17 +00:00
|
|
|
if (empty($errors)) {
|
2006-09-02 15:29:52 +00:00
|
|
|
switch ($return) {
|
|
|
|
case 'site':
|
2006-09-11 18:56:41 +00:00
|
|
|
redirect("$CFG->wwwroot/");
|
2006-09-02 15:29:52 +00:00
|
|
|
case 'admin':
|
2006-09-26 21:10:14 +00:00
|
|
|
redirect("$CFG->wwwroot/$CFG->admin/");
|
2006-09-02 15:29:52 +00:00
|
|
|
default:
|
2006-10-16 06:52:01 +00:00
|
|
|
$statusmsg = get_string('changessaved');
|
2006-09-02 15:29:52 +00:00
|
|
|
}
|
2006-08-21 04:06:58 +00:00
|
|
|
} else {
|
2006-10-16 06:52:01 +00:00
|
|
|
$statusmsg = get_string('errorwithsettings', 'admin') . ' <br />' . $errors;
|
2006-08-21 04:06:58 +00:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
error(get_string('confirmsesskeybad', 'error'));
|
|
|
|
}
|
2006-10-16 08:54:37 +00:00
|
|
|
// now update $SITE - it might have been changed
|
|
|
|
$SITE = get_record('course', 'id', $SITE->id);
|
2006-10-16 07:37:41 +00:00
|
|
|
$COURSE = clone($SITE);
|
2006-08-18 07:25:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-10-16 06:52:01 +00:00
|
|
|
/// print header stuff ------------------------------------------------------------
|
|
|
|
// header must be printed after the redirects and require_logout
|
2007-02-06 22:23:08 +00:00
|
|
|
|
|
|
|
if (empty($SITE->fullname)) {
|
2007-02-23 04:08:55 +00:00
|
|
|
print_header($root->visiblename, $root->visiblename);
|
2007-02-06 22:23:08 +00:00
|
|
|
print_simple_box(get_string('configintrosite', 'admin'), 'center', '50%');
|
|
|
|
|
|
|
|
if ($statusmsg != '') {
|
|
|
|
notify ($statusmsg);
|
|
|
|
}
|
|
|
|
|
|
|
|
// ---------------------------------------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
echo '<form action="settings.php" method="post" id="adminsettings">';
|
2007-07-18 15:53:07 +00:00
|
|
|
echo '<div class="settingsform clearfix">';
|
2007-02-06 22:23:08 +00:00
|
|
|
echo '<input type="hidden" name="section" value="' . $PAGE->section . '" />';
|
|
|
|
echo '<input type="hidden" name="sesskey" value="' . $USER->sesskey . '" />';
|
|
|
|
echo '<input type="hidden" name="return" value="' . $return . '" />';
|
|
|
|
|
|
|
|
echo $root->output_html();
|
|
|
|
|
|
|
|
echo '<div class="form-buttons"><input class="form-submit" type="submit" value="' . get_string('savechanges','admin') . '" /></div>';
|
|
|
|
|
|
|
|
echo '</div>';
|
|
|
|
echo '</form>';
|
|
|
|
}
|
|
|
|
|
2006-10-16 06:52:01 +00:00
|
|
|
if (!empty($SITE->fullname)) {
|
|
|
|
$pageblocks = blocks_setup($PAGE);
|
|
|
|
|
|
|
|
$preferred_width_left = bounded_number(BLOCK_L_MIN_WIDTH, blocks_preferred_width($pageblocks[BLOCK_POS_LEFT]),
|
|
|
|
BLOCK_L_MAX_WIDTH);
|
|
|
|
$preferred_width_right = bounded_number(BLOCK_R_MIN_WIDTH, blocks_preferred_width($pageblocks[BLOCK_POS_RIGHT]),
|
|
|
|
BLOCK_R_MAX_WIDTH);
|
2006-08-18 07:25:17 +00:00
|
|
|
|
2006-10-16 06:52:01 +00:00
|
|
|
$PAGE->print_header();
|
|
|
|
|
|
|
|
echo '<table id="layout-table"><tr>';
|
2007-02-06 22:23:08 +00:00
|
|
|
$lt = (empty($THEME->layouttable)) ? array('left', 'middle', 'right') : $THEME->layouttable;
|
|
|
|
foreach ($lt as $column) {
|
|
|
|
switch ($column) {
|
|
|
|
case 'left':
|
2006-10-16 06:52:01 +00:00
|
|
|
echo '<td style="width: ' . $preferred_width_left . 'px;" id="left-column">';
|
2007-05-09 14:39:13 +00:00
|
|
|
if (!empty($THEME->customcorners)) print_custom_corners_start();
|
2006-10-16 06:52:01 +00:00
|
|
|
blocks_print_group($PAGE, $pageblocks, BLOCK_POS_LEFT);
|
2007-05-09 14:39:13 +00:00
|
|
|
if (!empty($THEME->customcorners)) print_custom_corners_end();
|
2006-10-16 06:52:01 +00:00
|
|
|
echo '</td>';
|
2007-02-06 22:23:08 +00:00
|
|
|
break;
|
|
|
|
case 'middle':
|
|
|
|
echo '<td id="middle-column">';
|
2007-05-09 14:39:13 +00:00
|
|
|
if (!empty($THEME->customcorners)) print_custom_corners_start();
|
2007-02-06 22:23:08 +00:00
|
|
|
echo '<a name="startofcontent"></a>';
|
2006-10-16 06:52:01 +00:00
|
|
|
|
2007-02-06 22:23:08 +00:00
|
|
|
if ($statusmsg != '') {
|
|
|
|
notify ($statusmsg);
|
|
|
|
}
|
2006-10-16 06:52:01 +00:00
|
|
|
|
2007-02-06 22:23:08 +00:00
|
|
|
// ---------------------------------------------------------------------------------------------------------------
|
2006-08-18 07:25:17 +00:00
|
|
|
|
2007-02-06 22:23:08 +00:00
|
|
|
echo '<form action="settings.php" method="post" id="adminsettings">';
|
2007-07-18 15:53:07 +00:00
|
|
|
echo '<div class="settingsform clearfix">';
|
2007-02-06 22:23:08 +00:00
|
|
|
echo '<input type="hidden" name="section" value="' . $PAGE->section . '" />';
|
|
|
|
echo '<input type="hidden" name="sesskey" value="' . $USER->sesskey . '" />';
|
|
|
|
echo '<input type="hidden" name="return" value="' . $return . '" />';
|
|
|
|
print_heading($root->visiblename);
|
2006-08-18 07:25:17 +00:00
|
|
|
|
2007-02-06 22:23:08 +00:00
|
|
|
echo $root->output_html();
|
2006-08-18 07:25:17 +00:00
|
|
|
|
2007-02-06 22:23:08 +00:00
|
|
|
echo '<div class="form-buttons"><input class="form-submit" type="submit" value="' . get_string('savechanges','admin') . '" /></div>';
|
2006-09-25 07:55:10 +00:00
|
|
|
|
2007-02-06 22:23:08 +00:00
|
|
|
echo '</div>';
|
|
|
|
echo '</form>';
|
2006-09-12 09:22:27 +00:00
|
|
|
|
2007-05-09 14:39:13 +00:00
|
|
|
if (!empty($THEME->customcorners)) print_custom_corners_end();
|
2006-09-12 09:22:27 +00:00
|
|
|
echo '</td>';
|
2007-02-06 22:23:08 +00:00
|
|
|
break;
|
|
|
|
case 'right':
|
2007-02-13 01:54:25 +00:00
|
|
|
if (blocks_have_content($pageblocks, BLOCK_POS_RIGHT)) {
|
2007-02-07 08:22:20 +00:00
|
|
|
echo '<td style="width: ' . $preferred_width_right . 'px;" id="right-column">';
|
2007-05-09 14:39:13 +00:00
|
|
|
if (!empty($THEME->customcorners)) print_custom_corners_start();
|
2007-02-07 08:22:20 +00:00
|
|
|
blocks_print_group($PAGE, $pageblocks, BLOCK_POS_RIGHT);
|
2007-05-09 14:39:13 +00:00
|
|
|
if (!empty($THEME->customcorners)) print_custom_corners_end();
|
2007-02-07 08:22:20 +00:00
|
|
|
echo '</td>';
|
2007-02-06 22:23:08 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
echo '</tr></table>';
|
2006-09-12 09:22:27 +00:00
|
|
|
}
|
2006-08-18 07:25:17 +00:00
|
|
|
|
2006-09-25 07:55:10 +00:00
|
|
|
if (!empty($CFG->adminusehtmleditor)) {
|
|
|
|
use_html_editor();
|
|
|
|
}
|
|
|
|
|
2006-08-19 01:37:38 +00:00
|
|
|
print_footer();
|
2006-08-18 07:25:17 +00:00
|
|
|
|
2006-09-03 14:45:57 +00:00
|
|
|
?>
|