function profile2_menu_alter in Profile 2 7.2
Implements hook_menu_alter()
Adjust the menu tabs depending on whether (a) User Revisions is enabled, and (b) whether there are any profiles that don't use a separate page.
File
- ./
profile2.module, line 206 - Support for configurable user profiles.
Code
function profile2_menu_alter(&$items) {
// Look for any profile type that is displayed inline or in tabs.
foreach (profile2_get_types() as $type) {
if (empty($type->data['use_page'])) {
// We have a profile without its own page,
// if no User Revisions tab, create one pointing to a placeholder page.
if (!isset($items['user/%user/revisions'])) {
$items['user/%user/revisions'] = array(
'title' => 'Revisions',
'page callback' => '_profile2_user_revisions',
'access callback' => '_profile2_any_revision_access',
'access arguments' => array(
1,
),
'weight' => 2,
'type' => MENU_LOCAL_TASK,
);
}
else {
// Change the page callback, and the access callback to check all possible revisions.
$items['user/%user/revisions']['page arguments'][] = $items['user/%user/revisions']['page callback'];
$items['user/%user/revisions']['page callback'] = '_profile2_user_revisions';
$items['user/%user/revisions']['access callback'] = '_profile2_any_revision_access';
$items['user/%user/revisions']['access arguments'] = array(
1,
TRUE,
);
}
// The user_diff module creates a MENU_DEFAULT_LOCAL_TASK entry,
// get rid of it because we want ours (if it doesn't exist this is a no-op).
unset($items['user/%user/revisions/list']);
// Create a default sub-tab for "Account".
$items['user/%user/revisions/account'] = array(
'title' => 'Account',
'type' => MENU_DEFAULT_LOCAL_TASK,
'weight' => -10,
);
// Only need to perform the above once, so break the loop.
break;
}
}
}