function og_subgroups_propogate_content in Subgroups for Organic groups 5
Same name and namespace in other branches
- 5.4 og_subgroups.module \og_subgroups_propogate_content()
Propagates content along the subgroups tree.
Parameters
$node: The node object that needs to be propagated
$groups: The groups the node is currently assigend to
$directions: Array with the direction propogation should happen (parent, children, syblings)
1 call to og_subgroups_propogate_content()
- og_subgroups_nodeapi in ./
og_subgroups.module - Implementation of hook_nodeapi().
File
- ./
og_subgroups.module, line 561 - Maintains subgroups hierarchy created by the orgainc groups module.
Code
function og_subgroups_propogate_content($node, $groups, $directions) {
$save = FALSE;
$directions = array_filter($directions);
foreach ($directions as $direction) {
foreach ($groups as $group => $foo) {
// Get the path to the top level group.
$trees = og_subgroups_get_all_family($group, $direction);
foreach ($trees as $tree) {
// Check that group isn't already there.
$save = TRUE;
if (!in_array($tree->gid, $node->og_groups)) {
$node->og_groups[] = $tree->gid;
$node->og_groups_both[$tree->gid] = $tree->title;
}
}
}
}
// Save node only if changed.
if ($save) {
og_save_ancestry($node);
}
}