function _og_orphans_move in Organic groups 7.2
Helper function to move orphan group-content to another group.
Parameters
$ids: Array of OG membership IDs.
See also
og_membership_delete_by_group_worker()
1 call to _og_orphans_move()
- og_membership_orphans_worker in ./
og.module - Queue worker; Process a queue item.
File
- ./
og.module, line 1724 - Enable users to create and manage groups with roles and permissions.
Code
function _og_orphans_move($ids, $group_type, $gid) {
if (!og_is_group($group_type, $gid)) {
$params = array(
'@group-type' => $group_type,
'@gid' => $gid,
);
throw new OgException(format_string('Cannot move orphan group-content to @group-type - @gid, as it is not a valid group.', $params));
}
$og_memberships = og_membership_load_multiple($ids);
foreach ($og_memberships as $og_membership) {
$entity_type = $og_membership->entity_type;
$id = $og_membership->etid;
if (count(og_get_entity_groups($entity_type, $id)) > 1) {
continue;
}
$og_membership->group_type = $group_type;
$og_membership->gid = $gid;
$og_membership
->save();
}
}