You are here

function rabbit_hole_menu_local_tasks_alter in Rabbit Hole 7

Same name and namespace in other branches
  1. 7.2 rabbit_hole.module \rabbit_hole_menu_local_tasks_alter()

Implements hook_menu_local_tasks_alter().

File

./rabbit_hole.module, line 273
Main module file for Rabbit Hole.

Code

function rabbit_hole_menu_local_tasks_alter(&$data, $router_item, $root_path) {
  $primary =& $data['tabs'][0];
  if (!is_array($primary['output'])) {

    // There are no tabs present, exit early.
    return;
  }

  // Iterate through the primary tabs, and look for the View tab for nodes.
  foreach ($primary['output'] as $delta => $element) {
    if ($element['#link']['path'] == 'node/%/view') {

      // Found the View tab, get the Rabbit Hole action for this node, and
      // remove the tab if any Rabbit Hole action has been set.
      $node = menu_get_object('node', 1, $router_item['tab_root_href']);
      $action = isset($node->rabbit_hole_action) ? $node->rabbit_hole_action != RABBIT_HOLE_USE_DEFAULT ? $node->rabbit_hole_action : variable_get('rabbit_hole_action_' . $node->type) : variable_get('rabbit_hole_action_' . $node->type);
      if ($action != RABBIT_HOLE_DISPLAY_CONTENT && !user_access('bypass rabbit hole')) {
        unset($primary['output'][$delta]);
      }
    }
  }

  // Reset the count and keys for the existing tabs.
  $primary['output'] = array_values($primary['output']);
  $primary['count'] = count($primary['output']);
}