You are here

function spaces_menu_access in Spaces 6.2

Same name and namespace in other branches
  1. 6.3 spaces.module \spaces_menu_access()
  2. 7.3 spaces.module \spaces_menu_access()
  3. 7 spaces.module \spaces_menu_access()

Spaces menu access callback. Allows space types to manage menu access as related to their space workflow. See hook_menu_alter() for how the original menu access callback / argument gets passed to an altered item.

1 call to spaces_menu_access()
spaces_init in ./spaces.module
Implementation of hook_init().
1 string reference to 'spaces_menu_access'
spaces_menu_alter in ./spaces.module
Implementation of hook_menu_alter().

File

./spaces.module, line 172

Code

function spaces_menu_access() {
  $args = func_get_args();
  $op = 'menu';
  $object = NULL;
  if (!empty($args)) {
    $access_callback = array_pop($args);
    if ($access_callback == 'node_access' && $args[0] == 'create') {
      $object = new StdClass();
      $object->type = $args[1];
      $op = 'node';
    }
    else {
      foreach ($args as $arg) {
        if (is_object($arg)) {
          $object = $arg;
          if (isset($object->nid)) {
            $op = 'node';
          }
          else {
            if (isset($object->uid)) {
              $op = 'user';
            }
          }
          break;
        }
      }
    }
  }
  $access = true;
  $types = spaces_types();

  // Check menu access for the active space type
  if ($space = spaces_get_space()) {
    $access = $access && $space
      ->menu_access($op, $object);
    unset($types[$space->type]);
  }

  // Run each non-active space type's menu access check
  foreach ($types as $type => $info) {
    $access = $access && call_user_func(array(
      $info['class'],
      'menu_access',
    ), $op, $object, FALSE);
  }
  $standard_access = !empty($access_callback) ? call_user_func_array($access_callback, $args) : TRUE;
  return $access && $standard_access;
}