You are here

function _menu_link_weight_get_tree in Menu Link Weight 7

Same name and namespace in other branches
  1. 8.2 menu_link_weight.module \_menu_link_weight_get_tree()
  2. 8 menu_link_weight.module \_menu_link_weight_get_tree()

Helper function to get all siblings of an item based on the parent.

Parameters

string $menu_name: Name of the menu.

int $plid: Parent link ID.

Return value

array List of all items under the plid (that the user has access to).

1 call to _menu_link_weight_get_tree()
_menu_link_weight_get_options in ./menu_link_weight.module
Gets a list of of options for a specific menu/parent.

File

./menu_link_weight.module, line 332
Replaces the menu link weight dropdown with a tabledrag widget.

Code

function _menu_link_weight_get_tree($menu_name, $plid) {
  global $menu_admin;
  if ($plid != 0) {
    $link = menu_Link_load($plid);
    $limit = $link['depth'] + 1;
  }
  else {
    $limit = 1;
  }

  // We indicate that a menu administrator will be running the menu access
  // check.
  $menu_admin = TRUE;
  $tree = menu_build_tree($menu_name, array(
    'active_trail' => array(
      $plid,
    ),
    'only_active_trail' => FALSE,
    'min_depth' => $limit,
    'max_depth' => $limit,
    'conditions' => array(
      'plid' => $plid,
    ),
    // To prevent core bug: https://www.drupal.org/node/1477608.
    // We do not want this call to be cached (which is partly done based on
    // the hash of the parameters), so we put a unique ID in the parameters.
    'do_not_cache' => uniqid(),
  ));
  $menu_admin = FALSE;
  return $tree;
}