Merge branch 'MDL-31510_group_activities' of git://github.com/andyjdavis/moodle
[moodle.git] / blocks / admin_bookmarks / create.php
blobecb4c3e6bdf300cd578355969ecfd9c59e351d64
1 <?php
3 require('../../config.php');
5 require_once($CFG->libdir.'/adminlib.php');
6 require_login();
7 $context = get_context_instance(CONTEXT_SYSTEM);
8 $PAGE->set_context($context);
9 $adminroot = admin_get_root(false, false); // settings not required - only pages
11 if ($section = optional_param('section', '', PARAM_SAFEDIR) and confirm_sesskey()) {
13 if (get_user_preferences('admin_bookmarks')) {
14 $bookmarks = explode(',', get_user_preferences('admin_bookmarks'));
16 if (in_array($section, $bookmarks)) {
17 print_error('bookmarkalreadyexists','admin');
18 die;
21 } else {
22 $bookmarks = array();
25 $temp = $adminroot->locate($section);
27 if ($temp instanceof admin_settingpage || $temp instanceof admin_externalpage) {
28 $bookmarks[] = $section;
29 $bookmarks = implode(',', $bookmarks);
30 set_user_preference('admin_bookmarks', $bookmarks);
32 } else {
33 print_error('invalidsection','admin');
34 die;
37 if ($temp instanceof admin_settingpage) {
38 redirect($CFG->wwwroot . '/' . $CFG->admin . '/settings.php?section=' . $section);
40 } elseif ($temp instanceof admin_externalpage) {
41 redirect($temp->url);
44 } else {
45 print_error('invalidsection','admin');
46 die;