diff -u includes/menu.inc includes/menu.inc --- includes/menu.inc 15 Oct 2009 15:52:41 -0000 +++ includes/menu.inc 15 Oct 2009 21:11:01 -0000 @@ -2294,11 +2294,13 @@ $links = db_select('menu_links', 'ml', array('fetch' => PDO::FETCH_ASSOC)) ->fields('ml') ->condition('ml.menu_name', $menu_name) + // Order by weight so as to be helpful for menus that are only one level + // deep. ->orderBy('weight') ->execute() ->fetchAll(); - foreach ($links as $key => &$link) { + foreach ($links as &$link) { $link['options'] = unserialize($link['options']); } return $links; diff -u modules/shortcut/shortcut.admin.css modules/shortcut/shortcut.admin.css --- modules/shortcut/shortcut.admin.css 15 Oct 2009 15:52:41 -0000 +++ modules/shortcut/shortcut.admin.css 15 Oct 2009 21:11:02 -0000 @@ -5,7 +5,7 @@ display: inline; } -.toolbar-slot-hidden { +.shortcut-slot-hidden { display: none; } diff -u modules/shortcut/shortcut.admin.inc modules/shortcut/shortcut.admin.inc --- modules/shortcut/shortcut.admin.inc 15 Oct 2009 15:52:41 -0000 +++ modules/shortcut/shortcut.admin.inc 15 Oct 2009 21:11:02 -0000 @@ -91,7 +91,7 @@ if ($form_state['values']['set'] == 'new') { // Save a new shortcut set with links copied from the default set. $default_set = shortcut_default_set(); - $set = array( + $set = (object) array( 'title' => $form_state['values']['new'], 'links' => menu_links_clone($default_set->links), ); @@ -145,7 +145,7 @@ * @param $form_state * An associative array containing the current state of the form. * @param $shortcut_set - * An array representing the shortcut set which is being edited. + * An object representing the shortcut set which is being edited. * @return * An array representing the form definition. * @@ -162,10 +162,10 @@ $form['change_set'] = array( '#markup' => l(t('Change set'), 'admin/config/system/shortcut'), - '#prefix' => '
(', + '#prefix' => '
(', '#suffix' => ')
', '#weight' => -99, - '#access' => user_access('switch shortcut sets'), + '#access' => shortcut_set_switch_access(), ); $form['shortcuts']['#tree'] = TRUE; @@ -204,38 +204,15 @@ * Submit handler for the shortcut set customization form. */ function shortcut_set_customize_submit($form, &$form_state) { - foreach ($form_state['values']['shortcuts'] as $status => $links) { + foreach ($form_state['values']['shortcuts'] as $group => $links) { foreach ($links as $mlid => $data) { $link = menu_link_load($mlid); - $link['hidden'] = $status == 'enabled' ? 0 : 1; + $link['hidden'] = $data['status'] == 'enabled' ? 0 : 1; $link['weight'] = $data['weight']; menu_link_save($link); } } -/* -TODO: - // Knock an enabled one out if we have to. - $set = toolbar_set_load(shortcut_max_slots(), TRUE); - // Too many, knock one out. - while (count($set['shortcuts']) >= TOOLBAR_MAX_SLOTS) { - $disable = array_pop($set['shortcuts']); - $disable['status'] = 0; - toolbar_shortcut_save($disable); - } - $largest_weight = -50; - foreach ($set['shortcuts'] as $shortcut) { - $largest_weight = max($shortcut['weight'], $largest_weight); - } - toolbar_shortcut_save(array( - 'sid' => toolbar_current_set(), - 'weight' => $largest_weight + 1, - 'path' => $_GET['link'], - 'name' => $_GET['name'], - 'status' => 1, - )); - drupal_goto('admin/config/system/shortcuts'); -*/ - + drupal_set_message(t('The shortcut set has been updated.')); } /** @@ -265,7 +242,7 @@ 'colspan' => 5, 'data' => '' . $map[$status] . '', )), - 'class' => array('toolbar-status', 'toolbar-status-' . $status), + 'class' => array('shortcut-status', 'shortcut-status-' . $status), ); foreach (element_children($form['shortcuts'][$status]) as $key) { $shortcut = &$form['shortcuts'][$status][$key]; @@ -287,13 +264,13 @@ 'colspan' => 5, 'data' => '' . t('Empty') . '', )), - 'class' => array('toolbar-slot-empty'), + 'class' => array('shortcut-slot-empty'), ); } $count_shortcuts = count(element_children($form['shortcuts'][$status])); if (!empty($count_shortcuts)) { for ($i = 0; $i < min($count_shortcuts, shortcut_max_slots()); $i++) { - $rows['empty-' . $i]['class'][] = 'toolbar-slot-hidden'; + $rows['empty-' . $i]['class'][] = 'shortcut-slot-hidden'; } } } @@ -305,36 +282,75 @@ return $output; } - /** - * Menu callback; Build the form for adding or editing a shortcut link. + * Menu callback; Build the form for adding a new shortcut link. * * @param $form * An associative array containing the structure of the form. * @param $form_state * An associative array containing the current state of the form. * @param $shortcut_set - * (optional) - * An object representing the shortcut set that the link is assigned to. + * An object representing the shortcut set to which the link will be added. + * @return + * An array representing the form definition. + * + * @ingroup forms + * @see shortcut_link_add_submit() + */ +function shortcut_link_add($form, &$form_state, $shortcut_set) { + drupal_set_title(t('Add new shortcut')); + $form['shortcut_set'] = array( + '#type' => 'value', + '#value' => $shortcut_set, + ); + $form += _shortcut_link_form_elements(); + return $form; +} + +/** + * Menu callback; Build the form for editing a shortcut link. + * + * @param $form + * An associative array containing the structure of the form. + * @param $form_state + * An associative array containing the current state of the form. * @param $shortcut_link - * (optional) An array representing the link that is being edited. If not - * set, the form will allow a new link to be created. + * An array representing the link that is being edited. * @return * An array representing the form definition. * * @ingroup forms * @see shortcut_link_edit_submit() */ -function shortcut_link_edit($form, &$form_state, $shortcut_set = NULL, $shortcut_link = NULL) { +function shortcut_link_edit($form, &$form_state, $shortcut_link) { + drupal_set_title(t('Editing @shortcut', array('@shortcut' => $shortcut_link['link_title']))); + $form['original_shortcut_link'] = array( + '#type' => 'value', + '#value' => $shortcut_link, + ); + $form += _shortcut_link_form_elements($shortcut_link); + return $form; +} + +/** + * Helper function for building a form for adding or editing shortcut links. + * + * @param $shortcut_link + * (optional) An array representing the shortcut link that will be edited. If + * not provided, a new link will be created. + * @return + * An array of form elements. + */ +function _shortcut_link_form_elements($shortcut_link = NULL) { if (!isset($shortcut_link)) { - $shortcut_link = array('link_title' => t(''), 'link_path' => ''); - drupal_set_title(t('Add new shortcut')); - } - else { - drupal_set_title(t('Editing @shortcut', array('@shortcut' => $shortcut_link['link_title']))); + $shortcut_link = array( + 'link_title' => '', + 'link_path' => '' + ); } - $form['link_title'] = array( + $form['shortcut_link']['#tree'] = TRUE; + $form['shortcut_link']['link_title'] = array( '#type' => 'textfield', '#title' => t('Name'), '#description' => t('The name of the shortcut.'), @@ -343,7 +359,7 @@ '#default_value' => $shortcut_link['link_title'], ); - $form['link_path'] = array( + $form['shortcut_link']['link_path'] = array( '#type' => 'textfield', '#title' => t('Path'), '#description' => t('The path to the shortcut.'), @@ -358,7 +374,6 @@ '#value' => t('Save'), ); - $form_state['shortcut_link'] = $shortcut_link; return $form; } @@ -366,9 +381,61 @@ * Submit handler for the shortcut link editing form. */ function shortcut_link_edit_submit($form, &$form_state) { - $form_state['shortcut_link'] = array_merge($form_state['shortcut_link'], $form_state['values']); - menu_link_save($form_state['shortcut_link']); - $form_state['redirect'] = 'admin/config/system/shortcut'; + $shortcut_link = array_merge($form_state['values']['original_shortcut_link'], $form_state['values']['shortcut_link']); + menu_link_save($shortcut_link); + $form_state['redirect'] = 'admin/config/system/shortcut/' . $shortcut_link['menu_name']; + drupal_set_message(t('The shortcut %link has been updated.', array('%link' => $shortcut_link['link_title']))); +} + +/** + * Submit handler for the form that adds shortcut links. + */ +function shortcut_link_add_submit($form, &$form_state) { + // Add the shortcut link to the set. + $shortcut_set = $form_state['values']['shortcut_set']; + $shortcut_link = $form_state['values']['shortcut_link']; + $shortcut_link['menu_name'] = $shortcut_set->set_name; + shortcut_admin_add_link($shortcut_link, $shortcut_set, shortcut_max_slots()); + shortcut_set_save($shortcut_set); + $form_state['redirect'] = 'admin/config/system/shortcut/' . $shortcut_link['menu_name']; + drupal_set_message(t('Added a shortcut for %title.', array('%title' => $shortcut_link['link_title']))); +} + +/** + * Add a link to the end of a shortcut set, keeping within a prescribed limit. + * + * @param $link + * An array representing a shortcut link. + * @param $shortcut_set + * An object representing the shortcut set which the link will be added to. + * The links in the shortcut set will be re-weighted so that the new link is + * at the end, and some existing links may be disabled (if the $limit + * parameter is provided). + * @param $limit + * (optional) The maximum number of links that are allowed to be enabled for + * this shortcut set. If provided, existing links at the end of the list that + * exceed the limit will be automatically disabled. If not provided, no limit + * will be enforced. + */ +function shortcut_admin_add_link($shortcut_link, &$shortcut_set, $limit = NULL) { + if (isset($limit)) { + // Disable any existing links at the end of the list that would cause the + // limit to be exceeded. Take into account whether or not the new link will + // be enabled and count towards the total. + $number_enabled = !empty($shortcut_link['hidden']) ? 0 : 1; + foreach ($shortcut_set->links as &$link) { + if (!$link['hidden']) { + $number_enabled++; + if ($number_enabled > $limit) { + $link['hidden'] = 1; + } + } + } + } + + // Add the link to the end of the list. + $shortcut_set->links[] = $shortcut_link; + shortcut_set_reset_link_weights($shortcut_set); } /** @@ -387,14 +454,29 @@ * @see shortcut_link_delete_submit() */ function shortcut_link_delete($form, &$form_state, $shortcut_link) { - // TODO: Copy code here. + $form['shortcut_link'] = array( + '#type' => 'value', + '#value' => $shortcut_link, + ); + + return confirm_form( + $form, + t('Are you sure you want to delete the shortcut %title?', array('%title' => $shortcut_link['link_title'])), + 'admin/config/system/shortcut/' . $shortcut_link['menu_name'], + t('This action cannot be undone.'), + t('Delete'), + t('Cancel') + ); } /** * Submit handler for the shortcut link deletion form. */ function shortcut_link_delete_submit($form, &$form_state) { - // TODO: Copy code here. + $shortcut_link = $form_state['values']['shortcut_link']; + menu_link_delete($shortcut_link['mlid']); + $form_state['redirect'] = 'admin/config/system/shortcut/' . $shortcut_link['menu_name']; + drupal_set_message(t('The shortcut %title has been deleted.', array('%title' => $shortcut_link['link_title']))); } /** @@ -405,15 +487,13 @@ * @param $shortcut_set * Returned from shortcut_set_load(). */ -function shortcut_add_link($shortcut_set) { +function shortcut_link_add_inline($shortcut_set) { if (isset($_REQUEST['token']) && drupal_valid_token($_REQUEST['token'], 'shortcut-add-link')) { $link = array( 'link_title' => $_GET['name'], 'link_path' => $_GET['link'], ); - // Really we should test for a dupe here. - $shortcut_set->links[] = $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']))); drupal_goto(); @@ -424,2 +504,3 @@ } + return drupal_access_denied(); } diff -u modules/shortcut/shortcut.admin.js modules/shortcut/shortcut.admin.js --- modules/shortcut/shortcut.admin.js 15 Oct 2009 15:52:41 -0000 +++ modules/shortcut/shortcut.admin.js 15 Oct 2009 21:11:02 -0000 @@ -23,7 +23,7 @@ .removeClass('even').addClass('odd') .end().end() .end() - .filter('.toolbar-slot-empty').each(function(index) { + .filter('.shortcut-slot-empty').each(function(index) { if ($(this).is(':visible')) { visibleLength++; } @@ -32,27 +32,27 @@ // Add a handler for when a row is swapped. tableDrag.row.prototype.onSwap = function (swappedRow) { - var disabledIndex = $(table).find('tr').index($(table).find('tr.toolbar-status-disabled')) - slots - 2, + var disabledIndex = $(table).find('tr').index($(table).find('tr.shortcut-status-disabled')) - slots - 2, count = 0; - $(table).find('tr.toolbar-status-enabled').nextAll().filter(':not(.toolbar-slot-empty)').each(function(index) { + $(table).find('tr.shortcut-status-enabled').nextAll().filter(':not(.shortcut-slot-empty)').each(function(index) { if (index < disabledIndex) { count++; } }); var total = slots - count; if (total == -1) { - var disabled = $(table).find('tr.toolbar-status-disabled'); - disabled.after(disabled.prevAll().filter(':not(.toolbar-slot-empty)').get(0)); + var disabled = $(table).find('tr.shortcut-status-disabled'); + disabled.after(disabled.prevAll().filter(':not(.shortcut-slot-empty)').get(0)); } else if (total != visibleLength) { if (total > visibleLength) { // Less slots on screen than needed. - $('.toolbar-slot-empty:hidden:last').show(); + $('.shortcut-slot-empty:hidden:last').show(); visibleLength++; } else { // More slots on screen than needed. - $('.toolbar-slot-empty:visible:last').hide(); + $('.shortcut-slot-empty:visible:last').hide(); visibleLength--; } } @@ -62,8 +62,8 @@ tableDrag.onDrop = function () { // Use "status-message" row instead of "status" row because // "status-{status_name}-message" is less prone to regexp match errors. - var statusRow = $(this.rowObject.element).prevAll('tr.toolbar-status').get(0); - var statusName = statusRow.className.replace(/([^ ]+[ ]+)*toolbar-status-([^ ]+)([ ]+[^ ]+)*/, '$2'); + var statusRow = $(this.rowObject.element).prevAll('tr.shortcut-status').get(0); + var statusName = statusRow.className.replace(/([^ ]+[ ]+)*shortcut-status-([^ ]+)([ ]+[^ ]+)*/, '$2'); var statusField = $('select.shortcut-status-select', this.rowObject.element); statusField.val(statusName); return true; diff -u modules/shortcut/shortcut.css modules/shortcut/shortcut.css --- modules/shortcut/shortcut.css 15 Oct 2009 15:52:41 -0000 +++ modules/shortcut/shortcut.css 15 Oct 2009 21:11:02 -0000 @@ -40,7 +40,7 @@ -webkit-border-radius: 5px; } -div.toolbar-add-to-shortcuts a span.icon { +div.add-to-shortcuts a span.icon { display: block; width: 12px; background: url(../toolbar/toolbar.png) no-repeat -50px -60px; @@ -49,17 +49,17 @@ margin-left:8px; } -div.toolbar-add-to-shortcuts a:hover span.icon { +div.add-to-shortcuts a:hover span.icon { background-position: -50px -72px; } -div.toolbar-add-to-shortcuts a span.text { +div.add-to-shortcuts a span.text { float: left; padding-left:10px; display: none; } -div.toolbar-add-to-shortcuts a:hover span.text { +div.add-to-shortcuts a:hover span.text { font-size: 10px; line-height: 12px; color: #fff; diff -u modules/shortcut/shortcut.module modules/shortcut/shortcut.module --- modules/shortcut/shortcut.module 15 Oct 2009 15:52:41 -0000 +++ modules/shortcut/shortcut.module 15 Oct 2009 21:11:02 -0000 @@ -50,25 +50,25 @@ 'title' => 'Customize shortcuts', 'page callback' => 'drupal_get_form', 'page arguments' => array('shortcut_set_customize', 4), - 'access callback' => 'shortcut_set_access', + 'access callback' => 'shortcut_set_edit_access', 'access arguments' => array(4), 'type' => MENU_CALLBACK, 'file' => 'shortcut.admin.inc', ); $items['admin/config/system/shortcut/%shortcut_set/add-link'] = array( 'title' => 'Add shortcut', - 'page callback' => 'shortcut_link_edit', - 'page arguments' => array(4), - 'access callback' => 'shortcut_set_access', + 'page callback' => 'drupal_get_form', + 'page arguments' => array('shortcut_link_add', 4), + 'access callback' => 'shortcut_set_edit_access', 'access arguments' => array(4), 'type' => MENU_LOCAL_ACTION, 'file' => 'shortcut.admin.inc', ); $items['admin/config/system/shortcut/%shortcut_set/add-link-inline'] = array( 'title' => 'Add shortcut', - 'page callback' => 'shortcut_add_link', + 'page callback' => 'shortcut_link_add_inline', 'page arguments' => array(4), - 'access callback' => 'shortcut_set_access', + 'access callback' => 'shortcut_set_edit_access', 'access arguments' => array(4), 'type' => MENU_CALLBACK, 'file' => 'shortcut.admin.inc', @@ -76,9 +76,9 @@ $items['admin/config/system/shortcut/link/%menu_link'] = array( 'title' => 'Edit shortcut', 'page callback' => 'drupal_get_form', - 'page arguments' => array('shortcut_link_edit', NULL, 5), - 'access callback' => 'shortcut_set_access', - 'access arguments' => array(4), + 'page arguments' => array('shortcut_link_edit', 5), + 'access callback' => 'shortcut_link_access', + 'access arguments' => array(5), 'type' => MENU_CALLBACK, 'file' => 'shortcut.admin.inc', ); @@ -86,8 +86,8 @@ 'title' => 'Delete shortcut', 'page callback' => 'drupal_get_form', 'page arguments' => array('shortcut_link_delete', 5), - 'access callback' => 'shortcut_set_access', - 'access arguments' => array(4), + 'access callback' => 'shortcut_link_access', + 'access arguments' => array(5), 'type' => MENU_CALLBACK, 'file' => 'shortcut.admin.inc', ); @@ -95,7 +95,7 @@ 'title' => 'Shortcuts', 'page callback' => 'drupal_get_form', 'page arguments' => array('shortcut_set_switch', 1), - 'access callback' => 'shortcut_switch_access', + 'access callback' => 'shortcut_set_switch_access', 'access arguments' => array(1), 'type' => MENU_LOCAL_TASK, 'file' => 'shortcut.admin.inc', @@ -144,21 +144,53 @@ /** * Access callback for editing a shortcut set. + * + * @param $shortcut_set + * (optional) The shortcut set to be edited. If not set, the current + * displayed shortcut set will be assumed. + * @return + * TRUE if the current user has access to edit the shortcut set, FALSE + * otherwise. */ -function shortcut_set_access($shortcut_set) { +function shortcut_set_edit_access($shortcut_set = NULL) { // Sufficiently-privileged users can edit their currently displayed shortcut // set, but not other sets. Shortcut administrators can edit any set. - return user_access('administer shortcuts') || (user_access('customize shortcut links') && ($current_set = shortcut_current_displayed_set()) && $current_set->set_name == $shortcut_set->set_name); + if (user_access('administer shortcuts')) { + return TRUE; + } + if (user_access('customize shortcut links')) { + return !isset($shortcut_set) || $shortcut_set == shortcut_current_displayed_set(); + } + return FALSE; } /** * Access callback for switching the shortcut set assigned to a user account. + * + * @param $account + * (optional) The user account whose shortcuts will be switched. If not set, + * the account of the current logged-in user will be assumed. + * @return + * TRUE if the current user has access to switch the shortcut set of the + * provided account, FALSE otherwise. */ -function shortcut_switch_access($account) { +function shortcut_set_switch_access($account = NULL) { global $user; // Sufficiently-privileged users can switch their own shortcut sets, but not // those of other users. Shortcut administrators can switch any user's set. - return user_access('administer shortcuts') || (user_access('switch shortcut sets') && $user->uid == $account->uid); + return user_access('administer shortcuts') || (user_access('switch shortcut sets') && (!isset($account) || $user->uid == $account->uid)); +} + +/** + * Access callback for editing a link in a shortcut set. + */ +function shortcut_link_access($menu_link) { + // The link must belong to a shortcut set that the current user has access + // to edit. + if ($shortcut_set = shortcut_set_load($menu_link['menu_name'])) { + return shortcut_set_edit_access($shortcut_set); + } + return FALSE; } /** @@ -167,7 +199,8 @@ * @param $set_name * The name of the shortcut set to load. * @return - * If the shortcut set exists, a StdClass containing the following properties: + * If the shortcut set exists, an object of type stdClass containing the + * following properties: * - 'set_name': The internal name of the shortcut set. * - 'title': The title of the shortcut set. * - 'links': An array of links associated with this shortcut set. @@ -189,7 +222,7 @@ * An object containing the following properties: * - 'title': The title of the shortcut set. * - 'set_name': (optional) The internal name of the shortcut set. If - * omitted, a new shortcut set will be created, and the 'set_name' key + * omitted, a new shortcut set will be created, and the 'set_name' property * will be added to the passed-in array. * - 'links': (optional) An array of menu links to save for the shortcut set. * Each link is an array containing at least the following keys (which will @@ -240,7 +273,7 @@ * Note that the default set cannot be deleted. * * @param $shortcut_set - * An array representing the shortcut set to delete. + * An object representing the shortcut set to delete. * @return * TRUE if the set was deleted, FALSE otherwise. */ @@ -265,10 +298,29 @@ } /** + * Reset the link weights in a shortcut set to match their current order. + * + * This function can be used, for example, when a new shortcut link is added to + * the set. If the link is added to the end of the array and this function is + * called, it will force that link to display at the end of the list. + * + * @param $shortcut_set + * An object representing a shortcut set. The link weights of the passed-in + * object will be reset as described above. + */ +function shortcut_set_reset_link_weights(&$shortcut_set) { + $weight = -50; + foreach ($shortcut_set->links as &$link) { + $link['weight'] = $weight; + $weight++; + } +} + +/** * Assign a user to a particular shortcut set. * * @param $shortcut_set - * An array representing the shortcut set. + * An object representing the shortcut set. * @param $account * A user account that will be assigned to use the set. */ @@ -305,7 +357,7 @@ * (optional) The user account whose shortcuts will be returned. Defaults to * the current logged-in user. * @return - * An array representing the shortcut set that should be displayed to the + * An object representing the shortcut set that should be displayed to the * current user. If the user does not have an explicit shortcut set defined, * the default set is returned. */ @@ -341,7 +393,7 @@ * (optional) The user account whose shortcuts will be returned. Defaults to * the current logged-in user. * @return - * An array representing the default shortcut set. + * An object representing the default shortcut set. */ function shortcut_default_set($account = NULL) { global $user; @@ -394,6 +446,11 @@ /** * Returns an array of all shortcut sets, keyed by the set name. + * + * @return + * An array of shortcut sets. Note that only the basic shortcut set + * properties (name and title) are returned by this function, not the list + * of menu links that belong to the set. */ function shortcut_sets() { return db_query("SELECT * FROM {shortcut_set}")->fetchAllAssoc('set_name'); @@ -403,7 +460,7 @@ * Returns an array of shortcut links, suitable for rendering. * * @param $shortcut_set - * (optional) An array representing the set whose links will be displayed. + * (optional) An object representing the set whose links will be displayed. * If not provided, the user's current set will be displayed. * @return * An array of shortcut links, in the format returned by the menu system. @@ -439,8 +496,8 @@ $shortcut_set = shortcut_current_displayed_set(); $page['add_to_shortcuts'] = array( - '#prefix' => '
', - '#markup' => l('' . t('Add to %shortcut_set shortcuts', array('%shortcut_set' => $shortcut_set->title)) . '', 'admin/config/system/shortcut/' . $shortcut_set->set_name . '/add-link-inline', array('query' => $query, 'html' => TRUE)), + '#prefix' => '
', + '#markup' => l('' . (shortcut_set_switch_access() ? t('Add to %shortcut_set shortcuts', array('%shortcut_set' => $shortcut_set->title)) : t('Add to shortcuts')) . '', 'admin/config/system/shortcut/' . $shortcut_set->set_name . '/add-link-inline', array('query' => $query, 'html' => TRUE)), '#suffix' => '
', ); } @@ -452,20 +509,18 @@ $configure_link = array('#markup' => l(t('edit shortcuts'), 'admin/config/system/shortcut/' . $shortcut_set->set_name, array('attributes' => array('id' => 'toolbar-customize')))); - $drawrer = array ( + $drawer = array( 'shortcuts' => $links, 'configure' => $configure_link, ); - - - $page['toolbar_drawer'] = $drawrer; + $page['toolbar_drawer'] = $drawer; } /** * Implement hook_preprocess_page(). */ -function shortcut_preprocess_page(&$vars) { - if (user_access('customize toolbar shortcuts')) { - $vars['add_to_shortcuts'] = drupal_render($vars['page']['add_to_shortcuts']); +function shortcut_preprocess_page(&$variables) { + if (shortcut_set_edit_access()) { + $variables['add_to_shortcuts'] = drupal_render($variables['page']['add_to_shortcuts']); } } diff -u themes/seven/page.tpl.php themes/seven/page.tpl.php --- themes/seven/page.tpl.php 15 Oct 2009 15:52:41 -0000 +++ themes/seven/page.tpl.php 15 Oct 2009 21:11:03 -0000 @@ -4,7 +4,7 @@

- +
diff -u themes/seven/style.css themes/seven/style.css --- themes/seven/style.css 15 Oct 2009 15:52:41 -0000 +++ themes/seven/style.css 15 Oct 2009 21:11:03 -0000 @@ -737,7 +737,7 @@ } /* Shortcut theming */ -div.toolbar-add-to-shortcuts { +div.add-to-shortcuts { float: left; margin-left: 6px; margin-top: 6px;