Menu page callback: creates a new link in the provided shortcut set.
After completion, redirects the user back to where they came from.
$shortcut_set: Returned from shortcut_set_load().
function shortcut_link_add_inline($shortcut_set) {
if (isset($_REQUEST['token']) && drupal_valid_token($_REQUEST['token'], 'shortcut-add-link') && shortcut_valid_link($_GET['link'])) {
$item = menu_get_item($_GET['link']);
$title = $item && $item['title'] ? $item['title'] : $_GET['name'];
$link = array(
'link_title' => $title,
'link_path' => $_GET['link'],
);
shortcut_admin_add_link($link, $shortcut_set, shortcut_max_slots());
if (shortcut_set_save($shortcut_set)) {
drupal_set_message(t('Added a shortcut for %title.', array(
'%title' => $link['link_title'],
)));
}
else {
drupal_set_message(t('Unable to add a shortcut for %title.', array(
'%title' => $link['link_title'],
)));
}
drupal_goto();
}
return MENU_ACCESS_DENIED;
}