function rabbit_hole_menu_local_tasks_alter in Rabbit Hole 7.2
Same name and namespace in other branches
- 7 rabbit_hole.module \rabbit_hole_menu_local_tasks_alter()
Implements hook_menu_local_tasks_alter().
File
- ./
rabbit_hole.module, line 436 - Main module file for Rabbit Hole.
Code
function rabbit_hole_menu_local_tasks_alter(&$data, $router_item, $root_path) {
$primary =& $data['tabs'][0];
if (empty($primary['output']) || !is_array($primary['output'])) {
// There are no tabs present, exit early.
return;
}
// Get the modules that implements hook_rabbit_hole().
$modules = module_invoke_all('rabbit_hole');
// Iterate through the primary tabs, and look for the View tab for any entity
// that is handled by Rabbit Hole.
foreach ($primary['output'] as $delta => $element) {
// If path is not set on this item, just continue to the next item.
if (!isset($element['#link']['path'])) {
continue;
}
foreach ($modules as $module => $info) {
if ($element['#link']['path'] == $info['view path']) {
// Found the View tab, get the Rabbit Hole action for this entity, and
// remove the tab if any Rabbit Hole action has been set.
$entity_position = array_search('%', explode('/', $info['view path']));
$entity = menu_get_object($info['entity type'], $entity_position, $router_item['tab_root_href']);
if (isset($entity)) {
$bundle = rabbit_hole_entity_get_bundle($info['entity type'], $entity);
if (rabbit_hole_get_action($info['entity type'], $entity) != RABBIT_HOLE_DISPLAY_CONTENT && !user_access('bypass ' . $module)) {
unset($primary['output'][$delta]);
}
}
}
}
}
// Reset the count and keys for the existing tabs.
$primary['output'] = array_values($primary['output']);
$primary['count'] = count($primary['output']);
}