diff -u modules/shortcut/shortcut.admin.inc modules/shortcut/shortcut.admin.inc --- modules/shortcut/shortcut.admin.inc 16 Oct 2009 04:24:13 -0000 +++ modules/shortcut/shortcut.admin.inc @@ -62,7 +62,7 @@ $form['set'] = array( '#type' => 'radios', - '#title' => t('Choose a set'), + '#title' => t('Choose a set of shortcuts to show in your toolbar'), '#options' => $options, '#default_value' => $current_set->set_name, ); @@ -86,6 +86,30 @@ return $form; } +function shortcut_set_switch_confirm($form, &$form_state, $shortcut_set) { + global $user; + $form = array(); + $form['set'] = array ( + '#type' => 'value', + '#value' => $shortcut_set->set_name, + ); + $form['account'] = array ( + '#type' => 'value', + '#value' => $user, + ); + + $form['#submit'] = array('shortcut_set_switch_submit'); + $title = $shortcut_set->title; + + return confirm_form( + $form, + t("Would you like to switch to %title", array('%title' => $title)), + 'admin/config/system/shortcut', + "", + t("Switch to @title", array('@title' => $title)), + t("Keep using current shortcuts") + ); +} /** * Submit handler for the form that switches shortcut sets. */ @@ -105,8 +129,9 @@ '%user' => $account->name, '%set_name' => $set->title, ); - drupal_set_message($account->uid == $user->uid ? t('A new shortcut set called %set_name was created with the default shortcut items. You are now using this set.', $replacements) : t('%user is now using a new shortcut set called %set_name with the default shortcut items.', $replacements)); - $form_state['redirect'] = 'admin/config/system/shortcut/' . $set->set_name; + drupal_set_message($account->uid == $user->uid ? t('A new shortcut set called %set_name was created with the default shortcut items.', $replacements) : t('%user is now using a new shortcut set called %set_name with the default shortcut items.', $replacements)); + $form_state['redirect'] = 'admin/config/system/shortcut/switch/confirm/' . $set->set_name; + return; } else { // Switch to a different shortcut set. @@ -120,6 +145,9 @@ // Assign the shortcut set to the provided user account. shortcut_set_assign_user($set, $account); + if (user_access('administer shortcuts')) { + $form_state['redirect'] = 'admin/config/system/shortcut'; + } } /** diff -u modules/shortcut/shortcut.module modules/shortcut/shortcut.module --- modules/shortcut/shortcut.module 16 Oct 2009 04:24:13 -0000 +++ modules/shortcut/shortcut.module @@ -21,11 +21,11 @@ return array( 'administer shortcuts' => array( 'title' => t('Administer shortcuts'), - 'description' => t('Manage shortcuts and shortcut sets regardless of which user they are assigned to.'), + 'description' => t('Manage all shortcut and shortcut sets.'), ), 'customize shortcut links' => array( 'title' => t('Customize shortcut links'), - 'description' => t("Edit, add and delete the links in the user's currently displayed shortcut set."), + 'description' => t("Edit, add and delete the links in shortcut set the user is using."), ), 'switch shortcut sets' => array( 'title' => t('Choose a different shortcut set'), @@ -46,6 +46,15 @@ 'access arguments' => array('administer shortcuts'), 'file' => 'shortcut.admin.inc', ); + $items['admin/config/system/shortcut/switch/confirm/%shortcut_set'] = array( + 'title' => 'Switch to new shortcut set', + 'description' => 'Confirmation form for switching to a new set.', + 'page callback' => 'drupal_get_form', + 'page arguments' => array('shortcut_set_switch_confirm', 6), + 'access arguments' => array('administer shortcuts'), + 'type' => MENU_CALLBACK, + 'file' => 'shortcut.admin.inc', + ); $items['admin/config/system/shortcut/%shortcut_set'] = array( 'title' => 'Customize shortcuts', 'page callback' => 'drupal_get_form', @@ -207,7 +216,11 @@ * If the shortcut set does not exist, the function returns FALSE. */ function shortcut_set_load($set_name) { - $set = db_query("SELECT * FROM {shortcut_set} WHERE set_name = :set_name", array(':set_name' => $set_name))->fetchObject(); + $set = db_select('shortcut_set', 'ss') + ->fields('ss') + ->condition('set_name', $set_name) + ->execute() + ->fetchObject(); if (!$set) { return FALSE; } @@ -453,7 +466,10 @@ * of menu links that belong to the set. */ function shortcut_sets() { - return db_query("SELECT * FROM {shortcut_set}")->fetchAllAssoc('set_name'); + return db_select('shortcut_set', 'ss') + ->fields('ss') + ->execute() + ->fetchAllAssoc('set_name'); } /** @@ -505,7 +521,10 @@ $links['#prefix'] = '
'; $links['#suffix'] = '
'; $shortcut_set = shortcut_current_displayed_set(); - $configure_link = array('#markup' => l(t('edit shortcuts'), 'admin/config/system/shortcut/' . $shortcut_set->set_name, array('attributes' => array('id' => 'toolbar-customize')))); + $configure_link = NULL; + if (shortcut_set_edit_access($shortcut_set)) { + $configure_link = array('#markup' => l(t('edit shortcuts'), 'admin/config/system/shortcut/' . $shortcut_set->set_name, array('attributes' => array('id' => 'toolbar-customize')))); + } $drawer = array( 'shortcuts' => $links,