Merge commit 'catalyst/MOODLE_19_STABLE' into mdl19-linuxchix
[moodle-linuxchix.git] / blocks / admin_bookmarks / delete.php
blobcc06f0600d0ce96cec23f65839b4c94cafffdc18
1 <?php // $Id$
3 require('../../config.php');
5 require_once($CFG->libdir.'/adminlib.php');
7 require_login();
8 $adminroot =& admin_get_root(false, false); // settings not required - only pages
10 if ($section = optional_param('section', '', PARAM_SAFEDIR) and confirm_sesskey()) {
12 if (get_user_preferences('admin_bookmarks')) {
14 $bookmarks = explode(',', get_user_preferences('admin_bookmarks'));
16 $key = array_search($section, $bookmarks);
18 if ($key === false) {
19 print_error('nonexistentbookmark','admin');
20 die;
23 unset($bookmarks[$key]);
24 $bookmarks = implode(',', $bookmarks);
25 set_user_preference('admin_bookmarks', $bookmarks);
27 $temp = $adminroot->locate($section);
29 if (is_a($temp, 'admin_externalpage')) {
30 redirect($temp->url, get_string('bookmarkdeleted','admin'));
31 } elseif (is_a($temp, 'admin_settingpage')) {
32 redirect($CFG->wwwroot . '/' . $CFG->admin . '/settings.php?section=' . $section);
33 } else {
34 redirect($CFG->wwwroot);
36 die;
41 print_error('nobookmarksforuser','admin');
42 die;
44 } else {
45 print_error('invalidsection', 'admin');
46 die;