function spaces_get_space_from_object in Spaces 6.3
Same name and namespace in other branches
- 7.3 spaces.module \spaces_get_space_from_object()
Get the space that an $object is in.
1 call to spaces_get_space_from_object()
- spaces_is_spaces_object in ./
spaces.module - Tests whether the object is part of the current space.
File
- ./
spaces.module, line 1017
Code
function spaces_get_space_from_object($type, $object) {
static $spaces;
$id = $type == 'node' ? $object->nid : $object->uid;
if (!isset($spaces[$type][$id])) {
$spaces = module_invoke_all('spaces_get_space_from_object', $type, $object);
if ($space = current($spaces)) {
$spaces[$type][$id] = array(
'type' => $space->type,
'id' => $space->id,
);
}
else {
$spaces[$type][$id] = FALSE;
}
}
return $spaces[$type][$id] ? spaces_load($spaces[$type][$id]['type'], $spaces[$type][$id]['id']) : FALSE;
}