Automatic installer.php lang files by installer_builder (20061016)
[moodle.git] / admin / settings.php
CommitLineData
90a73bb3 1<?php // $Id$
2
3require_once('../config.php');
6e4dc10f 4require_once($CFG->libdir.'/adminlib.php');
02cc05a7 5require_once($CFG->libdir.'/blocklib.php');
6require_once($CFG->dirroot.'/'.$CFG->admin.'/pagelib.php');
63aafc9e 7
8if ($site = get_site()) {
9 require_login();
eef868d1 10}
63aafc9e 11
90a73bb3 12
02cc05a7 13page_map_class(PAGE_ADMIN, 'page_admin');
90a73bb3 14
e9a20759 15$PAGE = page_create_object(PAGE_ADMIN, 0); // there must be any constant id number
63aafc9e 16
6fcbab99 17$section = optional_param('section', '', PARAM_ALPHAEXT);
18
02cc05a7 19$PAGE->init_extra($section); // hack alert!
63aafc9e 20
21$adminediting = optional_param('adminedit', -1, PARAM_BOOL);
e0f6e995 22$return = optional_param('return','', PARAM_ALPHA);
eef868d1 23
3d8ef99d 24if (!isset($USER->adminediting)) {
d83f27ce 25 $USER->adminediting = false;
3d8ef99d 26}
27
28if ($PAGE->user_allowed_editing()) {
63aafc9e 29 if ($adminediting == 1) {
3d8ef99d 30 $USER->adminediting = true;
63aafc9e 31 } elseif ($adminediting == 0) {
3d8ef99d 32 $USER->adminediting = false;
33 }
34}
35
6e4dc10f 36$adminroot = admin_get_root();
90a73bb3 37
6e4dc10f 38$root = $adminroot->locate($PAGE->section);
90a73bb3 39
63aafc9e 40if (!is_a($root, 'admin_settingpage')) {
41 error(get_string('sectionerror', 'admin'));
6fcbab99 42 die;
63aafc9e 43}
90a73bb3 44
63aafc9e 45if (!($root->check_access())) {
46 error(get_string('accessdenied', 'admin'));
6fcbab99 47 die;
63aafc9e 48}
90a73bb3 49
6ea5ff3a 50$CFG->pagepath = 'admin/setting/'.$section;
51
c6d33fce 52
53
54if (!empty($SITE->fullname)) {
55 $pageblocks = blocks_setup($PAGE);
56
57 $preferred_width_left = bounded_number(BLOCK_L_MIN_WIDTH, blocks_preferred_width($pageblocks[BLOCK_POS_LEFT]),
58 BLOCK_L_MAX_WIDTH);
59 $preferred_width_right = bounded_number(BLOCK_R_MIN_WIDTH, blocks_preferred_width($pageblocks[BLOCK_POS_RIGHT]),
60 BLOCK_R_MAX_WIDTH);
61
62 // print header stuff
63 $PAGE->print_header();
64
65 echo '<table id="layout-table"><tr>';
66 echo '<td style="width: ' . $preferred_width_left . 'px;" id="left-column">';
67 blocks_print_group($PAGE, $pageblocks, BLOCK_POS_LEFT);
68 echo '</td>';
69 echo '<td id="middle-column">';
70} else {
71
72 print_header();
73 print_simple_box(get_string('configintrosite', 'admin'), 'center', '50%');
74
75}
76
77
90a73bb3 78// WRITING SUBMITTED DATA (IF ANY) -------------------------------------------------------------------------------
79
80if ($data = data_submitted()) {
81 if (confirm_sesskey()) {
fefea008 82 $olddbsessions = !empty($CFG->dbsessions);
90a73bb3 83 $errors = $root->write_settings((array)$data);
fefea008 84 //force logout if dbsession setting changes
85 if ($olddbsessions != !empty($CFG->dbsessions)) {
86 require_logout();
87 }
90a73bb3 88 if (empty($errors)) {
e0f6e995 89 switch ($return) {
90 case 'site':
55f3a4db 91 redirect("$CFG->wwwroot/");
e0f6e995 92 case 'admin':
6859360c 93 redirect("$CFG->wwwroot/$CFG->admin/");
e0f6e995 94 default:
c6d33fce 95 notify(get_string('changessaved'));
e0f6e995 96 }
6fcbab99 97 } else {
c6d33fce 98 notify(get_string('errorwithsettings', 'admin') . ' <br />' . $errors);
6fcbab99 99 }
100 } else {
101 error(get_string('confirmsesskeybad', 'error'));
6fcbab99 102 }
90a73bb3 103}
104
105// ---------------------------------------------------------------------------------------------------------------
106
90a73bb3 107
90a73bb3 108
010b211f 109echo '<form action="settings.php" method="post" name="adminsettings" id="adminsettings">';
90a73bb3 110echo '<input type="hidden" name="section" value="' . $PAGE->section . '" />';
111echo '<input type="hidden" name="sesskey" value="' . $USER->sesskey . '" />';
e0f6e995 112echo '<input type="hidden" name="return" value="' . $return . '" />';
50999a0b 113print_heading($root->visiblename);
90a73bb3 114
115echo $root->output_html();
116
14f35856 117echo '<div class="form-buttons"><input class="form-submit" type="submit" value="' . get_string('savechanges','admin') . '" /></div>';
fa040029 118
d83f27ce 119echo '</form>';
b1ce7811 120
121if (!empty($SITE->fullname)) {
122 echo '</td>';
123 echo '<td style="width: ' . $preferred_width_right . 'px;" id="right-column">';
124 blocks_print_group($PAGE, $pageblocks, BLOCK_POS_RIGHT);
125 echo '</td></tr></table>';
126}
90a73bb3 127
fa040029 128if (!empty($CFG->adminusehtmleditor)) {
129 use_html_editor();
130}
131
63aafc9e 132print_footer();
90a73bb3 133
bee4702d 134?>