90a73bb3 |
1 | <?php // $Id$ |
2 | |
3 | require_once('../config.php'); |
4 | require_once($CFG->dirroot . '/admin/adminlib.php'); |
5 | |
6 | // for external pages, most of this code is duplicated in the admin_externalpage_print_header() |
7 | // and admin_externalpage_print_footer() functions... just include adminlib.php! |
8 | // |
9 | // lines marked //d at the end are handled (for other pages) by admin_externalpage_print_header() |
10 | // and admin_externalpage_print_footer() |
11 | require_once($CFG->libdir . '/blocklib.php'); //d |
12 | require_once($CFG->dirroot . '/admin/pagelib.php'); //d |
13 | |
14 | if ($site = get_site()) { //d |
15 | require_login(); //d |
16 | } //d |
17 | |
18 | // Question: what pageid should be used for this? |
19 | |
20 | define('TEMPORARY_ADMIN_PAGE_ID',26); //d |
21 | |
22 | define('BLOCK_L_MIN_WIDTH',160); //d |
23 | define('BLOCK_L_MAX_WIDTH',210); //d |
24 | |
25 | $pagetype = PAGE_ADMIN; //d |
26 | $pageclass = 'page_admin'; //d |
27 | page_map_class($pagetype, $pageclass); //d |
28 | |
29 | $PAGE = page_create_object($pagetype,TEMPORARY_ADMIN_PAGE_ID); //d |
30 | |
31 | $PAGE->init_full(); //d |
32 | |
33 | unset($root); //d |
34 | |
35 | $root = $ADMIN->locate($PAGE->section); //d |
36 | |
37 | if (!($root instanceof admin_settingpage)) { //d |
38 | error('Section does not exist, is invalid, or should not be accessed via this URL.'); //d |
39 | die; //d |
40 | } //d |
41 | |
42 | if (!($root->check_access())) { //d |
43 | error('Access denied.'); //d |
44 | die; //d |
45 | } //d |
46 | |
47 | // WRITING SUBMITTED DATA (IF ANY) ------------------------------------------------------------------------------- |
48 | |
49 | if ($data = data_submitted()) { |
50 | if (confirm_sesskey()) { |
51 | $errors = $root->write_settings((array)$data); |
52 | if (empty($errors)) { |
53 | redirect("$CFG->wwwroot/admin/settings.php?section=" . $PAGE->section, get_string('changessaved'),1); |
54 | } else { |
55 | error('The following errors occurred when trying to save settings: <br />' . $errors); |
56 | } |
57 | } else { |
58 | error(get_string('confirmsesskeybad', 'error')); |
59 | die; |
60 | } |
61 | } |
62 | |
63 | // --------------------------------------------------------------------------------------------------------------- |
64 | |
65 | $pageblocks = blocks_setup($PAGE); |
66 | |
67 | $preferred_width_left = bounded_number(BLOCK_L_MIN_WIDTH, blocks_preferred_width($pageblocks[BLOCK_POS_LEFT]), BLOCK_L_MAX_WIDTH); |
68 | |
69 | // print header stuff |
70 | $PAGE->print_header(); |
71 | echo '<table id="layout-table"><tr>'; |
72 | echo '<td style="width: ' . $preferred_width_left . 'px;" id="left-column">'; |
73 | blocks_print_group($PAGE, $pageblocks, BLOCK_POS_LEFT); |
74 | echo '</td>'; |
75 | echo '<td id="middle-column" width="*">'; |
76 | echo '<form action="settings.php" method="post" name="mainform">'; |
77 | echo '<input type="hidden" name="section" value="' . $PAGE->section . '" />'; |
78 | echo '<input type="hidden" name="sesskey" value="' . $USER->sesskey . '" />'; |
79 | print_simple_box_start('','100%','',5,'generalbox',''); |
80 | |
81 | echo $root->output_html(); |
82 | |
83 | echo '<center><input type="submit" value="Save Changes" /></center>'; |
84 | echo '</form>'; |
85 | print_simple_box_end(); |
86 | echo '</td></tr></table>'; //d |
87 | |
88 | print_footer(); //d |
89 | |
90 | ?> |