56 lines
1.2 KiB
PHP
Raw Normal View History

2006-08-18 08:25:02 +00:00
<?php // $Id$
require('../../config.php');
require_once($CFG->libdir.'/adminlib.php');
$adminroot = admin_get_root();
2006-09-26 09:25:37 +00:00
require_login();
2006-08-18 08:25:02 +00:00
2006-09-26 09:25:37 +00:00
if ($section = optional_param('section', '', PARAM_ALPHAEXT) and confirm_sesskey()) {
2006-08-18 08:25:02 +00:00
if (isset($USER->preference['admin_bookmarks'])) {
2006-08-18 08:25:02 +00:00
$bookmarks = explode(',',$USER->preference['admin_bookmarks']);
2006-09-26 09:25:37 +00:00
2006-08-18 08:25:02 +00:00
if (in_array($section, $bookmarks)) {
error(get_string('bookmarkalreadyexists','admin'));
2006-09-20 20:31:09 +00:00
die;
}
2006-09-26 09:25:37 +00:00
2006-09-20 20:31:09 +00:00
} else {
$bookmarks = array();
}
2006-08-18 08:25:02 +00:00
$temp = $adminroot->locate($section);
2006-09-26 09:25:37 +00:00
if (is_a($temp, 'admin_settingpage') || is_a($temp, 'admin_externalpage')) {
2006-09-26 09:25:37 +00:00
2006-08-18 08:25:02 +00:00
$bookmarks[] = $section;
2006-09-26 09:25:37 +00:00
2006-09-20 20:31:09 +00:00
$bookmarks = implode(',',$bookmarks);
2006-09-26 09:25:37 +00:00
2006-09-20 20:31:09 +00:00
set_user_preference('admin_bookmarks', $bookmarks);
2006-09-26 09:25:37 +00:00
2006-08-18 08:25:02 +00:00
} else {
2006-09-26 09:25:37 +00:00
error(get_string('invaludsection','admin'));
2006-08-18 08:25:02 +00:00
die;
2006-09-26 09:25:37 +00:00
2006-08-18 08:25:02 +00:00
}
2006-09-26 09:25:37 +00:00
2006-09-20 20:31:09 +00:00
if (is_a($temp, 'admin_settingpage')) {
2006-09-26 09:25:37 +00:00
redirect($CFG->wwwroot . '/' . $CFG->admin . '/settings.php?section=' . $section, get_string('bookmarkadded','admin'), 1);
} elseif (is_a($temp, 'admin_externalpage')) {
2006-09-26 09:25:37 +00:00
redirect($temp->url, get_string('bookmarkadded','admin'), 1);
2006-09-26 09:25:37 +00:00
2006-08-18 08:25:02 +00:00
}
} else {
error(get_string('invalidsection','admin'));
die;
2006-08-18 08:25:02 +00:00
}
?>