You are here

function ack_menu_realm_links in Access Control Kit 7

Loads the menu links for a realm.

Parameters

object $scheme: An access scheme.

int $realm: A realm value.

string $menu_name: (optional) Limit the returned links to the given menu. If omitted, links from all menus will be included. Defaults to NULL.

bool $reset: (optional) Whether to reset the internal cache. Defaults to FALSE.

Return value

array The realm's menu links, sorted by menu and depth. Each value is an array defining a link, similar to what would be returned by menu_link_load().

4 calls to ack_menu_realm_links()
AckMenuAccessTest::testEventHooks in ack_menu/ack_menu.test
Test that the module responds appropriately to events that affect the map.
ack_menu_overview_form in ack_menu/ack_menu.pages.inc
Form for editing the menu tree for a realm.
ack_menu_realm_access in ack_menu/ack_menu.module
Access callback for managing realm links.
ack_menu_realm_menus in ack_menu/ack_menu.module
Returns a list of menus that contain links for a realm.

File

ack_menu/ack_menu.module, line 474
The ACK menu module.

Code

function ack_menu_realm_links($scheme, $realm, $menu_name = NULL, $reset = FALSE) {
  $links =& drupal_static(__FUNCTION__, array());
  if (!isset($links[$scheme->sid][$realm]) || $reset) {
    $realm_links = array();

    // Validate the scheme.
    if (isset($scheme->handlers['menu_link'])) {

      // Validate the realm value.
      if (is_numeric($realm) && isset($scheme->realms[$realm])) {
        $managed = $scheme->handlers['menu_link']
          ->managedMenus();
        ksort($managed);
        foreach (array_keys($managed) as $menu) {
          $realm_links[$menu] = $scheme->handlers['menu_link']
            ->realmLinks($realm, $menu);
        }
      }
    }
    $links[$scheme->sid][$realm] = $realm_links;
  }
  $list = array();
  if (isset($menu_name)) {
    if (isset($links[$scheme->sid][$realm][$menu_name])) {
      $list = $links[$scheme->sid][$realm][$menu_name];
    }
  }
  else {
    foreach ($links[$scheme->sid][$realm] as $menu_links) {
      if (!empty($menu_links)) {
        $list = array_merge($list, $menu_links);
      }
    }
  }
  return $list;
}