MDL-11278 Admin settings page completed, implementation of settings in the gradebook...
[moodle-pu.git] / blocks / admin_bookmarks / create.php
blobcf44ab0f89cab577eef727b277907b94fb85b80e
1 <?php // $Id$
3 require('../../config.php');
5 require_once($CFG->libdir.'/adminlib.php');
6 $adminroot = admin_get_root();
7 require_login();
9 if ($section = optional_param('section', '', PARAM_ALPHAEXT) and confirm_sesskey()) {
11 if (get_user_preferences('admin_bookmarks')) {
12 $bookmarks = explode(',',get_user_preferences('admin_bookmarks'));
14 if (in_array($section, $bookmarks)) {
15 error(get_string('bookmarkalreadyexists','admin'));
16 die;
19 } else {
20 $bookmarks = array();
23 $temp = $adminroot->locate($section);
25 if (is_a($temp, 'admin_settingpage') || is_a($temp, 'admin_externalpage')) {
27 $bookmarks[] = $section;
29 $bookmarks = implode(',',$bookmarks);
31 set_user_preference('admin_bookmarks', $bookmarks);
33 } else {
35 error(get_string('invaludsection','admin'));
36 die;
40 if (is_a($temp, 'admin_settingpage')) {
42 redirect($CFG->wwwroot . '/' . $CFG->admin . '/settings.php?section=' . $section);
44 } elseif (is_a($temp, 'admin_externalpage')) {
46 redirect($temp->url);
50 } else {
51 error(get_string('invalidsection','admin'));
52 die;