shortcut_set_switch_submit
function shortcut_set_switch_submit
shortcut_set_switch_submit($form, &$form_state)
Submit handler for shortcut_set_switch().
File
- modules/shortcut/shortcut.admin.inc, line 125
- Administrative page callbacks for the shortcut module.
Code
function shortcut_set_switch_submit($form, &$form_state) { global $user; $account = $form_state['values']['account']; if ($form_state['values']['set'] == 'new') { // Save a new shortcut set with links copied from the user's default set. $default_set = shortcut_default_set($account); $set = (object) array( 'title' => $form_state['values']['new'], 'links' => menu_links_clone($default_set->links), ); shortcut_set_save($set); $replacements = array( '%user' => $account->name, '%set_name' => $set->title, '@switch-url' => url(current_path()), ); if ($account->uid == $user->uid) { // Only administrators can create new shortcut sets, so we know they have // access to switch back. drupal_set_message(t('You are now using the new %set_name shortcut set. You can edit it from this page or <a href="drupal_7-modules-shortcut-shortcut-admin-inc-function-shortcut_set_switch_submit-@switch-url.html?lang=en">switch back to a different one.</a>', $replacements)); } else { drupal_set_message(t('%user is now using a new shortcut set called %set_name. You can edit it from this page.', $replacements)); } $form_state['redirect'] = 'admin/config/user-interface/shortcut/' . $set->set_name; } else { // Switch to a different shortcut set. $set = shortcut_set_load($form_state['values']['set']); $replacements = array( '%user' => $account->name, '%set_name' => $set->title, ); drupal_set_message($account->uid == $user->uid ? t('You are now using the %set_name shortcut set.', $replacements) : t('%user is now using the %set_name shortcut set.', $replacements)); } // Assign the shortcut set to the provided user account. shortcut_set_assign_user($set, $account); }
© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/modules!shortcut!shortcut.admin.inc/function/shortcut_set_switch_submit/7.x