function og_membership_orphans_worker in Organic groups 7.2
Queue worker; Process a queue item.
Delete memberships, and if needed all related group-content.
2 calls to og_membership_orphans_worker()
- OgDeleteOrphansTestCase::testDeleteGroup in ./
og.test - Testing two things: When deleting a group, the node of the group will be deleted. Associated node with the deleted group and another group won't be deleted.
- OgDeleteOrphansTestCase::testMoveOrphans in ./
og.test - Testing the moving of the node to another group when deleting a group.
1 string reference to 'og_membership_orphans_worker'
- og_cron_queue_info in ./
og.module - Implements hook_cron_queue_info().
File
- ./
og.module, line 1643 - Enable users to create and manage groups with roles and permissions.
Code
function og_membership_orphans_worker($data) {
$group_type = $data['group_type'];
$gid = $data['gid'];
$query = new EntityFieldQuery();
$result = $query
->entityCondition('entity_type', 'og_membership')
->propertyCondition('group_type', $group_type, '=')
->propertyCondition('gid', $gid, '=')
->propertyOrderBy('id')
->range(0, 50)
->execute();
if (empty($result['og_membership'])) {
return;
}
$ids = array_keys($result['og_membership']);
if ($data['orphans']['move']) {
_og_orphans_move($ids, $data['orphans']['move']['group_type'], $data['orphans']['move']['gid']);
$queue = DrupalQueue::get('og_membership_orphans');
return $queue
->createItem($data);
}
elseif ($data['orphans']['delete']) {
_og_orphans_delete($ids);
// Create a new item.
$queue = DrupalQueue::get('og_membership_orphans');
return $queue
->createItem($data);
}
}