mirror of
https://github.com/moodle/moodle.git
synced 2025-08-08 02:16:41 +02:00
admin bookmark cleanup
This commit is contained in:
parent
a3d23679e6
commit
62f62bf984
3 changed files with 34 additions and 32 deletions
|
@ -4,46 +4,47 @@ require('../../config.php');
|
|||
|
||||
require_once($CFG->libdir.'/adminlib.php');
|
||||
$adminroot = admin_get_root();
|
||||
require_login();
|
||||
|
||||
if ($section = optional_param('section', '', PARAM_ALPHAEXT)) {
|
||||
if ($section = optional_param('section', '', PARAM_ALPHAEXT) and confirm_sesskey()) {
|
||||
|
||||
if (isset($USER->preference['admin_bookmarks'])) {
|
||||
$bookmarks = explode(',',$USER->preference['admin_bookmarks']);
|
||||
|
||||
|
||||
if (in_array($section, $bookmarks)) {
|
||||
error(get_string('bookmarkalreadyexists','admin'));
|
||||
die;
|
||||
}
|
||||
|
||||
|
||||
} else {
|
||||
$bookmarks = array();
|
||||
}
|
||||
|
||||
$temp = $adminroot->locate($section);
|
||||
|
||||
|
||||
if (is_a($temp, 'admin_settingpage') || is_a($temp, 'admin_externalpage')) {
|
||||
|
||||
|
||||
$bookmarks[] = $section;
|
||||
|
||||
|
||||
$bookmarks = implode(',',$bookmarks);
|
||||
|
||||
|
||||
set_user_preference('admin_bookmarks', $bookmarks);
|
||||
|
||||
|
||||
} else {
|
||||
|
||||
error(get_string('invaludsection','admin'));
|
||||
|
||||
error(get_string('invaludsection','admin'));
|
||||
die;
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
if (is_a($temp, 'admin_settingpage')) {
|
||||
|
||||
redirect($CFG->wwwroot . '/' . $CFG->admin . '/settings.php?section=' . $section, 'Bookmark added.',1);
|
||||
|
||||
|
||||
redirect($CFG->wwwroot . '/' . $CFG->admin . '/settings.php?section=' . $section, get_string('bookmarkadded','admin'), 1);
|
||||
|
||||
} elseif (is_a($temp, 'admin_externalpage')) {
|
||||
|
||||
|
||||
redirect($temp->url, get_string('bookmarkadded','admin'), 1);
|
||||
|
||||
|
||||
}
|
||||
|
||||
} else {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue