MDL-9628 Fixed sorting
[moodle-pu.git] / blocks / admin_bookmarks / delete.php
bloba73a39aee1a99d1227932a9bbf1eb7d000d45989
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')) {
13 $bookmarks = explode(',', get_user_preferences('admin_bookmarks'));
15 $key = array_search($section, $bookmarks);
17 if ($key === false) {
18 error(get_string('nonexistentbookmark','admin'));
19 die;
22 unset($bookmarks[$key]);
23 $bookmarks = implode(',',$bookmarks);
24 set_user_preference('admin_bookmarks', $bookmarks);
26 $temp = $adminroot->locate($section);
28 if (is_a($temp, 'admin_externalpage')) {
29 redirect($temp->url, get_string('bookmarkdeleted','admin'));
30 } elseif (is_a($temp, 'admin_settingpage')) {
31 redirect($CFG->wwwroot . '/' . $CFG->admin . '/settings.php?section=' . $section);
32 } else {
33 redirect($CFG->wwwroot);
35 die;
40 error(get_string('nobookmarksforuser','admin'));
41 die;
43 } else {
44 error(get_string('invalidsection', 'admin'));
45 die;