Index: modules/shortcut/shortcut.module =================================================================== RCS file: /cvs/drupal/drupal/modules/shortcut/shortcut.module,v retrieving revision 1.24 diff -u -p -r1.24 shortcut.module --- modules/shortcut/shortcut.module 6 Mar 2010 06:33:14 -0000 1.24 +++ modules/shortcut/shortcut.module 6 Apr 2010 02:59:30 -0000 @@ -625,52 +625,57 @@ function shortcut_renderable_links($shor * Implements hook_preprocess_page(). */ function shortcut_preprocess_page(&$variables) { - if (shortcut_set_edit_access()) { - $link = $_GET['q']; - $query_parameters = drupal_get_query_parameters(); - if (!empty($query_parameters)) { - $link .= '?' . drupal_http_build_query($query_parameters); - } - $query = array( - 'link' => $link, - 'name' => drupal_get_title(), - ); - $query += drupal_get_destination(); + if (shortcut_set_edit_access() && path_is_admin(current_path())) { + $variables['title_suffix']['add_or_remove_shortcut'] = shortcut_add_or_remove_link(); + } +} - $shortcut_set = shortcut_current_displayed_set(); +/** + * Returns a renderable array for the on-page link to add or remove a shortcut. + */ +function shortcut_add_or_remove_link() { + $link = current_path(); + $query_parameters = drupal_get_query_parameters(); + if (!empty($query_parameters)) { + $link .= '?' . drupal_http_build_query($query_parameters); + } + $query = array( + 'link' => $link, + 'name' => drupal_get_title(), + ); + $query += drupal_get_destination(); - // Check if $link is already a shortcut and set $link_mode accordingly. - foreach ($shortcut_set->links as $shortcut) { - if ($link == $shortcut['link_path']) { - $mlid = $shortcut['mlid']; - break; - } - } - $link_mode = isset($mlid) ? "remove" : "add"; + $shortcut_set = shortcut_current_displayed_set(); - if ($link_mode == "add") { - $query['token'] = drupal_get_token('shortcut-add-link'); - $link_text = shortcut_set_switch_access() ? t('Add to %shortcut_set shortcuts', array('%shortcut_set' => $shortcut_set->title)) : t('Add to shortcuts'); - $link_path = 'admin/config/user-interface/shortcut/' . $shortcut_set->set_name . '/add-link-inline'; - } - else { - $query['mlid'] = $mlid; - $link_text = shortcut_set_switch_access() ? t('Remove from %shortcut_set shortcuts', array('%shortcut_set' => $shortcut_set->title)) : t('Remove from shortcuts'); - $link_path = 'admin/config/user-interface/shortcut/link/' . $mlid . '/delete'; + // Check if $link is already a shortcut and set $link_mode accordingly. + foreach ($shortcut_set->links as $shortcut) { + if ($link == $shortcut['link_path']) { + $mlid = $shortcut['mlid']; + break; } + } + $link_mode = isset($mlid) ? "remove" : "add"; - if (theme_get_setting('shortcut_module_link')) { - $variables['title_suffix']['add_or_remove_shortcut'] = array( - '#attached' => array('css' => array(drupal_get_path('module', 'shortcut') . '/shortcut.css')), - '#prefix' => '