[ Index ]

PHP Cross Reference of Unnamed Project

title

Body

[close]

/blocks/admin_bookmarks/ -> delete.php (source)

   1  <?php
   2  // This file is part of Moodle - http://moodle.org/
   3  //
   4  // Moodle is free software: you can redistribute it and/or modify
   5  // it under the terms of the GNU General Public License as published by
   6  // the Free Software Foundation, either version 3 of the License, or
   7  // (at your option) any later version.
   8  //
   9  // Moodle is distributed in the hope that it will be useful,
  10  // but WITHOUT ANY WARRANTY; without even the implied warranty of
  11  // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  12  // GNU General Public License for more details.
  13  //
  14  // You should have received a copy of the GNU General Public License
  15  // along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
  16  
  17  /**
  18   * Delete admin bookmarks.
  19   *
  20   * @package    block_admin_bookmarks
  21   * @copyright  2006 vinkmar
  22   * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  23   */
  24  
  25  require('../../config.php');
  26  
  27  require_once($CFG->libdir.'/adminlib.php');
  28  
  29  require_login();
  30  $context = context_system::instance();
  31  $PAGE->set_context($context);
  32  $adminroot = admin_get_root(false, false); // settings not required - only pages
  33  
  34  if ($section = optional_param('section', '', PARAM_SAFEDIR) and confirm_sesskey()) {
  35  
  36      if (get_user_preferences('admin_bookmarks')) {
  37  
  38          $bookmarks = explode(',', get_user_preferences('admin_bookmarks'));
  39  
  40          $key = array_search($section, $bookmarks);
  41  
  42          if ($key === false) {
  43              print_error('nonexistentbookmark','admin');
  44              die;
  45          }
  46  
  47          unset($bookmarks[$key]);
  48          $bookmarks = implode(',', $bookmarks);
  49          set_user_preference('admin_bookmarks', $bookmarks);
  50  
  51          $temp = $adminroot->locate($section);
  52  
  53          if ($temp instanceof admin_externalpage) {
  54              redirect($temp->url, get_string('bookmarkdeleted','admin'));
  55          } elseif ($temp instanceof admin_settingpage) {
  56              redirect($CFG->wwwroot . '/' . $CFG->admin . '/settings.php?section=' . $section);
  57          } else {
  58              redirect($CFG->wwwroot);
  59          }
  60          die;
  61  
  62  
  63      }
  64  
  65      print_error('nobookmarksforuser','admin');
  66      die;
  67  
  68  } else {
  69      print_error('invalidsection', 'admin');
  70      die;
  71  }
  72  
  73  


Generated: Thu Aug 11 10:00:09 2016 Cross-referenced by PHPXref 0.7.1