function og_subgroups_prop_propagate_user in Subgroups for Organic groups 6
Propagate user memberships along a groups tree
Parameters
$op: The operation to execute (subscribe, unsubscribe)
$gid: The group nid
uid: The user uid
$args: Any passed arguments from hook_og()
1 call to og_subgroups_prop_propagate_user()
- og_subgroups_prop_og in modules/
og_subgroups_prop/ og_subgroups_prop.module - Implementation of hook_og()
File
- modules/
og_subgroups_prop/ og_subgroups_prop.module, line 84
Code
function og_subgroups_prop_propagate_user($op, $gid, $uid, $args = array()) {
og_subgroups_include('tree');
// Determine the desired member propagation directions based on
// the selected operation
switch ($op) {
case 'subscribe':
$directions = variable_get('og_subgroups_propagate_members', array());
break;
case 'unsubscribe':
$directions = variable_get('og_subgroups_propagate_members_unsubscribe', array());
break;
default:
return FALSE;
}
// Load the group
$group = node_load($gid);
// Load the user
$user = user_load($uid);
// Iterate the directions
foreach ($directions as $direction) {
if ($direction) {
// Iterate the groups
foreach (_og_subgroups_prop_groups_by_direction($group, $direction) as $member) {
// Execute the propagation function
$propfunc = "_og_subgroups_prop_propagate_user_{$op}";
$propfunc($member, $user, $args);
}
}
}
}