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-12-19 17:35:20 +00:00
|
|
|
$section = required_param('section', PARAM_SAFEDIR);
|
2006-09-02 15:29:52 +00:00
|
|
|
$return = optional_param('return','', PARAM_ALPHA);
|
2007-12-19 17:35:20 +00:00
|
|
|
$adminediting = optional_param('adminedit', -1, PARAM_BOOL);
|
2006-09-20 21:00:45 +00:00
|
|
|
|
2007-12-23 11:53:31 +00:00
|
|
|
/// no guest autologin
|
|
|
|
require_login(0, false);
|
2006-08-18 07:25:17 +00:00
|
|
|
|
2007-12-19 17:35:20 +00:00
|
|
|
$adminroot =& admin_get_root(); // need all settings
|
|
|
|
$page =& $adminroot->locate($section);
|
2006-08-18 07:25:17 +00:00
|
|
|
|
2007-12-19 17:35:20 +00:00
|
|
|
if (empty($page) or !is_a($page, 'admin_settingpage')) {
|
2008-05-30 21:36:57 +00:00
|
|
|
print_error('sectionerror', 'admin', "$CFG->wwwroot/$CFG->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
|
|
|
|
2007-12-19 17:35:20 +00:00
|
|
|
if (!($page->check_access())) {
|
2008-05-30 21:36:57 +00:00
|
|
|
print_error('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-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 = '';
|
2007-12-19 17:35:20 +00:00
|
|
|
$errormsg = '';
|
|
|
|
$focus = '';
|
2006-08-18 07:25:17 +00:00
|
|
|
|
2008-06-09 16:53:30 +00:00
|
|
|
if ($data = data_submitted() and confirm_sesskey()) {
|
2007-12-19 17:35:20 +00:00
|
|
|
if (admin_write_settings($data)) {
|
|
|
|
$statusmsg = get_string('changessaved');
|
|
|
|
}
|
|
|
|
|
|
|
|
if (empty($adminroot->errors)) {
|
|
|
|
switch ($return) {
|
|
|
|
case 'site': redirect("$CFG->wwwroot/");
|
|
|
|
case 'admin': redirect("$CFG->wwwroot/$CFG->admin/");
|
2006-08-21 04:06:58 +00:00
|
|
|
}
|
|
|
|
} else {
|
2007-12-19 17:35:20 +00:00
|
|
|
$errormsg = get_string('errorwithsettings', 'admin');
|
|
|
|
$firsterror = reset($adminroot->errors);
|
|
|
|
$focus = $firsterror->id;
|
|
|
|
}
|
|
|
|
$adminroot =& admin_get_root(true); //reload tree
|
|
|
|
$page =& $adminroot->locate($section);
|
|
|
|
}
|
|
|
|
|
|
|
|
/// very hacky page setup
|
|
|
|
page_map_class(PAGE_ADMIN, 'page_admin');
|
|
|
|
$PAGE = page_create_object(PAGE_ADMIN, 0); // there must be any constant id number
|
|
|
|
$PAGE->init_extra($section);
|
|
|
|
$CFG->pagepath = 'admin/setting/'.$section;
|
|
|
|
|
|
|
|
if (!isset($USER->adminediting)) {
|
|
|
|
$USER->adminediting = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($PAGE->user_allowed_editing()) {
|
|
|
|
if ($adminediting == 1) {
|
|
|
|
$USER->adminediting = true;
|
|
|
|
} elseif ($adminediting == 0) {
|
|
|
|
$USER->adminediting = false;
|
2006-08-21 04:06:58 +00:00
|
|
|
}
|
2006-08-18 07:25:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-10-16 06:52:01 +00:00
|
|
|
/// print header stuff ------------------------------------------------------------
|
2007-02-06 22:23:08 +00:00
|
|
|
|
|
|
|
if (empty($SITE->fullname)) {
|
2007-12-19 17:35:20 +00:00
|
|
|
print_header($page->visiblename, $page->visiblename, '', $focus);
|
2007-02-06 22:23:08 +00:00
|
|
|
print_simple_box(get_string('configintrosite', 'admin'), 'center', '50%');
|
|
|
|
|
2007-12-19 17:35:20 +00:00
|
|
|
if ($errormsg !== '') {
|
|
|
|
notify ($errormsg);
|
|
|
|
|
|
|
|
} else if ($statusmsg !== '') {
|
|
|
|
notify ($statusmsg, 'notifysuccess');
|
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-12-19 17:35:20 +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.'" />';
|
2007-02-06 22:23:08 +00:00
|
|
|
|
2007-12-19 17:35:20 +00:00
|
|
|
echo $page->output_html();
|
2007-02-06 22:23:08 +00:00
|
|
|
|
2007-12-19 17:35:20 +00:00
|
|
|
echo '<div class="form-buttons"><input class="form-submit" type="submit" value="'.get_string('savechanges','admin').'" /></div>';
|
2007-02-06 22:23:08 +00:00
|
|
|
|
|
|
|
echo '</div>';
|
|
|
|
echo '</form>';
|
|
|
|
|
2007-12-19 17:35:20 +00:00
|
|
|
} else {
|
2006-10-16 06:52:01 +00:00
|
|
|
$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
|
|
|
|
2007-12-19 17:35:20 +00:00
|
|
|
$PAGE->print_header('', $focus);
|
2006-10-16 06:52:01 +00:00
|
|
|
|
|
|
|
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':
|
2007-12-19 17:35:20 +00:00
|
|
|
echo '<td style="width: '.$preferred_width_left.'px;" id="left-column">';
|
2007-11-23 16:49:51 +00:00
|
|
|
print_container_start();
|
2006-10-16 06:52:01 +00:00
|
|
|
blocks_print_group($PAGE, $pageblocks, BLOCK_POS_LEFT);
|
2007-11-23 16:49:51 +00:00
|
|
|
print_container_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-11-23 16:49:51 +00:00
|
|
|
print_container_start();
|
2007-02-06 22:23:08 +00:00
|
|
|
echo '<a name="startofcontent"></a>';
|
2006-10-16 06:52:01 +00:00
|
|
|
|
2007-12-19 17:35:20 +00:00
|
|
|
if ($errormsg !== '') {
|
|
|
|
notify ($errormsg);
|
|
|
|
|
|
|
|
} else if ($statusmsg !== '') {
|
|
|
|
notify ($statusmsg, 'notifysuccess');
|
2007-02-06 22:23:08 +00:00
|
|
|
}
|
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-12-19 17:35:20 +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($page->visiblename);
|
2006-08-18 07:25:17 +00:00
|
|
|
|
2007-12-19 17:35:20 +00:00
|
|
|
echo $page->output_html();
|
2006-08-18 07:25:17 +00:00
|
|
|
|
2007-12-19 17:35:20 +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-11-23 16:49:51 +00:00
|
|
|
print_container_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-12-19 17:35:20 +00:00
|
|
|
echo '<td style="width: '.$preferred_width_right.'px;" id="right-column">';
|
2007-11-23 16:49:51 +00:00
|
|
|
print_container_start();
|
2007-02-07 08:22:20 +00:00
|
|
|
blocks_print_group($PAGE, $pageblocks, BLOCK_POS_RIGHT);
|
2007-11-23 16:49:51 +00:00
|
|
|
print_container_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-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
|
|
|
?>
|