function spaces_og_nodeapi in Spaces 6.2
Same name and namespace in other branches
- 5.2 spaces_og.module \spaces_og_nodeapi()
- 6.3 spaces_og/spaces_og.module \spaces_og_nodeapi()
- 6 spaces_og/spaces_og.module \spaces_og_nodeapi()
Implementation of hook_nodeapi().
File
- spaces_og/
spaces_og.module, line 671
Code
function spaces_og_nodeapi(&$node, $op, $teaser = NULL, $page = NULL) {
switch ($op) {
case 'prepare':
if (og_is_group_type($node->type) && ($space = spaces_load('og', $node->nid))) {
$node->purl = $space->purl;
}
else {
if (!og_is_omitted_type($node->type)) {
$space = spaces_get_space();
if ($space->type == 'og') {
_spaces_enforce_feature($space->sid, $node);
}
}
}
break;
case 'presave':
// switch node's group if specified
if (!og_is_omitted_type($node->type)) {
if (isset($node->spaces_og['gid']) && !in_array($node->spaces_og['gid'], $node->og_groups)) {
$new_gid = $node->spaces_og['gid'];
_spaces_enforce_feature($new_gid, $node);
}
}
break;
case 'insert':
case 'update':
// save PURL modifier & preset from node form information
if (og_is_group_type($node->type)) {
$space = !empty($node->space) ? $node->space : spaces_load('og', $node->nid);
$space->purl = is_array($node->purl) && !empty($node->purl['value']) ? $node->purl['value'] : $space->purl;
$space->preset = isset($node->preset) ? $node->preset : $space->preset;
$space->group = $node;
// Save that shiz
spaces_save($space);
// Enforce OG preset directly on node object for inserts
if ($op == 'insert') {
$node->og_selective = $space->group->og_selective;
$node->og_register = $space->group->og_register;
$node->og_directory = $space->group->og_directory;
$node->og_private = $space->group->og_private;
}
}
break;
case 'delete':
if (og_is_group_type($node->type)) {
$space = spaces_load('og', $node->nid);
if ($space) {
spaces_delete($space);
}
}
break;
}
}