function spaces_init in Spaces 6.3
Same name and namespace in other branches
- 5.2 spaces.module \spaces_init()
- 6 spaces.module \spaces_init()
- 6.2 spaces.module \spaces_init()
- 7.3 spaces.module \spaces_init()
- 7 spaces.module \spaces_init()
Implementation of hook_init().
File
- ./
spaces.module, line 771
Code
function spaces_init() {
spaces_ahah_check();
if (module_exists('spaces_customtext')) {
global $language;
$language->language = $language->language === 'spaces_customtext' ? spaces_customtext_cache() : $language->language;
}
/**
* If the current menu object is not part of the space, this will
* redirect it to the correct space.
*
* Since the menu returns TRUE in the cases a redirect is needed if
* the user has access to the item, the object will be stored in the
* menu for this to fetch and redirect.
*/
// Can't call menu_get_item in hook_init without this.
if (variable_get('menu_rebuild_needed', FALSE) || !variable_get('menu_masks', array())) {
menu_rebuild();
}
// Simplist case, get the node.
if ($object = menu_get_object()) {
$type = 'node';
}
elseif (($item = menu_get_item()) && isset($item['map'])) {
foreach (array_filter($item['map'], 'is_object') as $object) {
$type = isset($object->nid) ? 'node' : (isset($object->uid) ? 'user' : NULL);
break;
}
}
// If the space is incorrect, reroute.
if (isset($type) && !spaces_is_spaces_object($type, $object)) {
spaces_router($type, $object);
}
if (!spaces_access_space()) {
menu_set_active_item('spaces-access-denied');
}
spaces_router('init');
}