Same name and namespace in other branches
  1. 4.6.x includes/menu.inc \_menu_build_local_tasks()
  2. 5.x includes/menu.inc \_menu_build_local_tasks()

Find all the items in the current local task tree.

Since this is only for display, we only need title, path, and children for each item.

At the close of this function, $_menu['local tasks'] is populated with the menu items in the local task tree.

Return value

TRUE if the local task tree is forked. It does not need to be displayed otherwise.

File

includes/menu.inc, line 1311
API for the Drupal menu system.

Code

function _menu_build_local_tasks($pid) {
  global $_menu;
  $forked = FALSE;
  if (isset($_menu['items'][$pid])) {
    $parent = $_menu['items'][$pid];
    $children = array();
    if (isset($parent['children'])) {
      foreach ($parent['children'] as $mid) {
        if ($_menu['items'][$mid]['type'] & MENU_IS_LOCAL_TASK && _menu_item_is_accessible($mid)) {
          $children[] = $mid;

          // Beware short-circuiting || operator!
          $forked = _menu_build_local_tasks($mid) || $forked;
        }
      }
    }
    usort($children, '_menu_sort');
    $forked = $forked || count($children) > 1;
    $_menu['local tasks'][$pid] = array(
      'title' => $parent['title'],
      'path' => $parent['path'],
      'children' => $children,
    );
    foreach ($children as $mid) {
      $_menu['local tasks'][$mid]['pid'] = $pid;
    }
  }
  return $forked;
}