You are here

function _ack_menu_user_realms in Access Control Kit 7

Helper function to find the realms where the user is allowed to manage links.

Return value

array An array indexed by scheme machine name where the values are arrays of realm values manageable by the currently logged-in user.

3 calls to _ack_menu_user_realms()
ack_menu_form_node_form_alter in ack_menu/ack_menu.module
Implements hook_form_BASE_FORM_ID_alter().
ack_menu_overview_page in ack_menu/ack_menu.pages.inc
Menu page callback to list the realms wherein the user may manage menu links.
_ack_menu_form_alter in ack_menu/ack_menu.module
Helper function for altering the menu item and node forms.

File

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

Code

function _ack_menu_user_realms() {
  $schemes = access_object_schemes('menu_link');
  $realms = array();

  // Admins can access all realm menus.
  if (ack_menu_admin_access()) {
    foreach ($schemes as $scheme) {
      $realms[$scheme->machine_name] = array_keys($scheme->realms);
    }
  }
  else {

    // Otherwise, find the realms where the user has been granted access.
    foreach ($schemes as $scheme) {
      foreach (array_keys($scheme->realms) as $realm) {
        if (ack_menu_realm_access($scheme, $realm)) {
          $realms[$scheme->machine_name][] = $realm;
        }
      }
    }
  }
  return $realms;
}