90a73bb3 |
1 | <?php // $Id$ |
2 | |
3 | require_once('../config.php'); |
63aafc9e |
4 | require_once($CFG->dirroot . '/' . $CFG->admin . '/adminlib.php'); |
90a73bb3 |
5 | require_once($CFG->libdir . '/blocklib.php'); //d |
63aafc9e |
6 | require_once($CFG->dirroot . '/' . $CFG->admin . '/pagelib.php'); //d |
7 | |
8 | if ($site = get_site()) { |
9 | require_login(); |
10 | } |
11 | |
12 | define('TEMPORARY_ADMIN_PAGE_ID',26); |
13 | |
14 | define('BLOCK_L_MIN_WIDTH',160); |
15 | define('BLOCK_L_MAX_WIDTH',210); |
90a73bb3 |
16 | |
63aafc9e |
17 | $pagetype = PAGE_ADMIN; |
18 | $pageclass = 'page_admin'; |
19 | page_map_class($pagetype, $pageclass); |
90a73bb3 |
20 | |
63aafc9e |
21 | $PAGE = page_create_object($pagetype,TEMPORARY_ADMIN_PAGE_ID); |
22 | |
23 | $PAGE->init_full(); |
24 | |
25 | $adminediting = optional_param('adminedit', -1, PARAM_BOOL); |
3d8ef99d |
26 | |
27 | if (!isset($USER->adminediting)) { |
28 | $USER->adminediting = true; |
29 | } |
30 | |
31 | if ($PAGE->user_allowed_editing()) { |
63aafc9e |
32 | if ($adminediting == 1) { |
3d8ef99d |
33 | $USER->adminediting = true; |
63aafc9e |
34 | } elseif ($adminediting == 0) { |
3d8ef99d |
35 | $USER->adminediting = false; |
36 | } |
37 | } |
38 | |
63aafc9e |
39 | unset($root); |
90a73bb3 |
40 | |
63aafc9e |
41 | $root = $ADMIN->locate($PAGE->section); |
90a73bb3 |
42 | |
63aafc9e |
43 | if (!is_a($root, 'admin_settingpage')) { |
44 | error(get_string('sectionerror', 'admin')); |
45 | die; |
46 | } |
90a73bb3 |
47 | |
63aafc9e |
48 | if (!($root->check_access())) { |
49 | error(get_string('accessdenied', 'admin')); |
50 | die; |
51 | } |
90a73bb3 |
52 | |
53 | // WRITING SUBMITTED DATA (IF ANY) ------------------------------------------------------------------------------- |
54 | |
55 | if ($data = data_submitted()) { |
56 | if (confirm_sesskey()) { |
57 | $errors = $root->write_settings((array)$data); |
58 | if (empty($errors)) { |
59 | redirect("$CFG->wwwroot/admin/settings.php?section=" . $PAGE->section, get_string('changessaved'),1); |
60 | } else { |
63aafc9e |
61 | error(get_string('errorwithsettings', 'admin') . ' <br />' . $errors); |
90a73bb3 |
62 | } |
63 | } else { |
64 | error(get_string('confirmsesskeybad', 'error')); |
65 | die; |
66 | } |
67 | } |
68 | |
69 | // --------------------------------------------------------------------------------------------------------------- |
70 | |
71 | $pageblocks = blocks_setup($PAGE); |
72 | |
73 | $preferred_width_left = bounded_number(BLOCK_L_MIN_WIDTH, blocks_preferred_width($pageblocks[BLOCK_POS_LEFT]), BLOCK_L_MAX_WIDTH); |
74 | |
75 | // print header stuff |
76 | $PAGE->print_header(); |
77 | echo '<table id="layout-table"><tr>'; |
78 | echo '<td style="width: ' . $preferred_width_left . 'px;" id="left-column">'; |
79 | blocks_print_group($PAGE, $pageblocks, BLOCK_POS_LEFT); |
80 | echo '</td>'; |
81 | echo '<td id="middle-column" width="*">'; |
82 | echo '<form action="settings.php" method="post" name="mainform">'; |
83 | echo '<input type="hidden" name="section" value="' . $PAGE->section . '" />'; |
84 | echo '<input type="hidden" name="sesskey" value="' . $USER->sesskey . '" />'; |
85 | print_simple_box_start('','100%','',5,'generalbox',''); |
86 | |
87 | echo $root->output_html(); |
88 | |
89 | echo '<center><input type="submit" value="Save Changes" /></center>'; |
90 | echo '</form>'; |
91 | print_simple_box_end(); |
63aafc9e |
92 | echo '</td></tr></table>'; |
90a73bb3 |
93 | |
63aafc9e |
94 | print_footer(); |
90a73bb3 |
95 | |
96 | ?> |