function og_subgroups_nodeapi in Subgroups for Organic groups 6
Same name and namespace in other branches
- 5.4 og_subgroups.module \og_subgroups_nodeapi()
- 5 og_subgroups.module \og_subgroups_nodeapi()
- 5.3 og_subgroups.module \og_subgroups_nodeapi()
Implementation of hook_nodeapi().
File
- ./
og_subgroups.module, line 250 - Maintains a hierarchy of groups created by the orgainc groups module.
Code
function og_subgroups_nodeapi($node, $op, $teaser = NULL, $page = NULL) {
og_subgroups_include('tree');
switch ($op) {
case 'load':
// Check if this is a group
if (og_is_group_type($node->type)) {
// Attach the group's parent group, if one
$parent = og_subgroups_get_group_parent($node);
$node->og_parent = $parent ? $parent : NULL;
}
break;
case 'insert':
case 'update':
// Check if this is a group
if (og_is_group_type($node->type)) {
// Save the node parent, if one
og_subgroups_set_parent($node, $node->og_parent);
// Optionally force children to be private
og_subgroups_force_private_children($node);
}
break;
case 'delete':
if (og_is_group_type($node->type)) {
og_subgroups_delete_group($node);
}
}
// Switch again just to clear hierarchy cache
switch ($op) {
case 'insert':
case 'update':
case 'delete':
if (og_is_group_type($node->type)) {
cache_clear_all('og_subgroups', 'cache', TRUE);
}
}
}