Created
October 15, 2014 17:48
-
-
Save pcave/8ec768094bbe5da89d50 to your computer and use it in GitHub Desktop.
Admin ui menu title callbacks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Title callback used to change the menu titles based on whether a user gets | |
* the Springboard admin UI. | |
* | |
* @param $original_title | |
* Original title for users who do not get the Springboard admin ui. | |
* | |
* @param $new_title | |
* Replacement title for users who get the the Springboard admin ui. | |
*/ | |
function springboard_admin_menu_title_callback($original_title, $new_title) { | |
global $user; | |
if (springboard_admin_user_gets_sbux($user)) { | |
return $new_title; | |
} | |
return $original_title; | |
} | |
/** | |
* Implements hook_menu_alter(). | |
* | |
* Alterations to menu items to maintain the Springboard User Experience. | |
*/ | |
function springboard_admin_menu_alter(&$items) { | |
global $user; | |
if (springboard_admin_user_gets_sbux($user)) { | |
// Redirect to /admin to /springboard | |
$items['admin']['page callback'] = 'drupal_goto'; | |
$items['admin']['page arguments'] = array('springboard'); | |
// Disable the User Orders tab since it's irrelevant | |
unset($items['user/%views_arg/orders']); | |
} | |
// Customizations to menu item titles | |
$items['node/%webform_menu/webform']['title callback'] = 'springboard_admin_menu_title_callback'; | |
$items['node/%webform_menu/webform']['title arguments'] = array($items['node/%webform_menu/webform']['title'], t('Form components')); | |
$items['node/%webform_menu/webform/components']['title callback'] = 'springboard_admin_menu_title_callback'; | |
$items['node/%webform_menu/webform/components']['title arguments'] = array($items['node/%webform_menu/webform/components']['title'], t('Form fields')); | |
$items['node/%webform_menu/webform/emails']['title callback'] = 'springboard_admin_menu_title_callback'; | |
$items['node/%webform_menu/webform/emails']['title arguments'] = array($items['node/%webform_menu/webform/emails']['title'], t('Confirmation emails')); | |
$items['node/%webform_menu/webform/configure']['title callback'] = 'springboard_admin_menu_title_callback'; | |
$items['node/%webform_menu/webform/configure']['title arguments'] = array($items['node/%webform_menu/webform/configure']['title'], t('Confirmation page & settings')); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment