3 require_once('../config.php');
4 require_once($CFG->libdir
.'/adminlib.php');
6 $section = required_param('section', PARAM_SAFEDIR
);
7 $return = optional_param('return','', PARAM_ALPHA
);
8 $adminediting = optional_param('adminedit', -1, PARAM_BOOL
);
10 /// no guest autologin
11 require_login(0, false);
12 $PAGE->set_context(get_context_instance(CONTEXT_SYSTEM
));
13 $PAGE->set_url('/admin/settings.php', array('section' => $section));
14 $PAGE->set_pagetype('admin-setting-' . $section);
15 $PAGE->set_pagelayout('admin');
16 $PAGE->navigation
->clear_cache();
18 $adminroot = admin_get_root(); // need all settings
19 $settingspage = $adminroot->locate($section, true);
21 if (empty($settingspage) or !($settingspage instanceof admin_settingpage
)) {
22 print_error('sectionerror', 'admin', "$CFG->wwwroot/$CFG->admin/");
26 if (!($settingspage->check_access())) {
27 print_error('accessdenied', 'admin');
31 /// WRITING SUBMITTED DATA (IF ANY) -------------------------------------------------------------------------------
36 if ($data = data_submitted() and confirm_sesskey()) {
37 if (admin_write_settings($data)) {
38 $statusmsg = get_string('changessaved');
41 if (empty($adminroot->errors
)) {
43 case 'site': redirect("$CFG->wwwroot/");
44 case 'admin': redirect("$CFG->wwwroot/$CFG->admin/");
47 $errormsg = get_string('errorwithsettings', 'admin');
48 $firsterror = reset($adminroot->errors
);
50 $adminroot = admin_get_root(true); //reload tree
51 $settingspage = $adminroot->locate($section, true);
54 if ($PAGE->user_allowed_editing() && $adminediting != -1) {
55 $USER->editing
= $adminediting;
58 /// print header stuff ------------------------------------------------------------
59 if (empty($SITE->fullname
)) {
60 $PAGE->set_title($settingspage->visiblename
);
61 $PAGE->set_heading($settingspage->visiblename
);
63 echo $OUTPUT->header();
64 echo $OUTPUT->box(get_string('configintrosite', 'admin'));
66 if ($errormsg !== '') {
67 echo $OUTPUT->notification($errormsg);
69 } else if ($statusmsg !== '') {
70 echo $OUTPUT->notification($statusmsg, 'notifysuccess');
73 // ---------------------------------------------------------------------------------------------------------------
75 echo '<form action="settings.php" method="post" id="adminsettings">';
76 echo '<div class="settingsform clearfix">';
77 echo html_writer
::input_hidden_params($PAGE->url
);
78 echo '<input type="hidden" name="sesskey" value="'.sesskey().'" />';
79 echo '<input type="hidden" name="return" value="'.$return.'" />';
81 echo $settingspage->output_html();
83 echo '<div class="form-buttons"><input class="form-submit" type="submit" value="'.get_string('savechanges','admin').'" /></div>';
89 if ($PAGE->user_allowed_editing()) {
90 $url = clone($PAGE->url
);
91 if ($PAGE->user_is_editing()) {
92 $caption = get_string('blockseditoff');
93 $url->param('adminedit', 'off');
95 $caption = get_string('blocksediton');
96 $url->param('adminedit', 'on');
98 $buttons = $OUTPUT->single_button($url, $caption, 'get');
99 $PAGE->set_button($buttons);
102 $visiblepathtosection = array_reverse($settingspage->visiblepath
);
104 $PAGE->set_title("$SITE->shortname: " . implode(": ",$visiblepathtosection));
105 $PAGE->set_heading($SITE->fullname
);
106 echo $OUTPUT->header();
108 if ($errormsg !== '') {
109 echo $OUTPUT->notification($errormsg);
111 } else if ($statusmsg !== '') {
112 echo $OUTPUT->notification($statusmsg, 'notifysuccess');
115 // ---------------------------------------------------------------------------------------------------------------
117 echo '<form action="settings.php" method="post" id="adminsettings">';
118 echo '<div class="settingsform clearfix">';
119 echo html_writer
::input_hidden_params($PAGE->url
);
120 echo '<input type="hidden" name="sesskey" value="'.sesskey().'" />';
121 echo '<input type="hidden" name="return" value="'.$return.'" />';
122 echo $OUTPUT->heading($settingspage->visiblename
);
124 echo $settingspage->output_html();
126 if ($settingspage->show_save()) {
127 echo '<div class="form-buttons"><input class="form-submit" type="submit" value="'.get_string('savechanges','admin').'" /></div>';
134 echo $OUTPUT->footer();