function spaces_menu_access in Spaces 7
Same name and namespace in other branches
- 6.3 spaces.module \spaces_menu_access()
- 6.2 spaces.module \spaces_menu_access()
- 7.3 spaces.module \spaces_menu_access()
Spaces menu access callback. Allows space types to manage access as related to their space workflow. See hook_menu_alter() for how menu access callbacks / arguments get passed.
1 string reference to 'spaces_menu_access'
- spaces_menu_alter in ./
spaces.module - Implements hook_menu_alter().
File
- ./
spaces.module, line 685
Code
function spaces_menu_access() {
// Run the standard Drupal access check.
$args = func_get_args();
$access_callback = array_pop($args);
if (empty($access_callback) || call_user_func_array($access_callback, $args)) {
$map = features_get_component_map('node');
// Determine the access callback to use by inspecting args.
if ($access_callback == 'node_access' && $args[0] == 'create') {
$node_type = str_replace('-', '_', $args[1]);
$feature = !empty($map[$node_type]) ? reset($map[$node_type]) : NULL;
if ($feature) {
return spaces_access_feature('create', $feature);
}
}
else {
foreach (array_filter($args, 'is_object') as $object) {
if (isset($object->nid)) {
spaces_router('node', $object);
$feature = !empty($map[$object->type]) ? reset($map[$object->type]) : NULL;
if ($feature) {
return spaces_access_feature('view', $feature);
}
}
elseif (isset($object->uid)) {
spaces_router('user', $object);
return spaces_access_user('view', $object);
}
break;
}
}
return TRUE;
}
return FALSE;
}