diff options
Diffstat (limited to 'engine/lib/upgrades/2010062301.php')
| -rw-r--r-- | engine/lib/upgrades/2010062301.php | 33 | 
1 files changed, 33 insertions, 0 deletions
| diff --git a/engine/lib/upgrades/2010062301.php b/engine/lib/upgrades/2010062301.php new file mode 100644 index 000000000..f679fa46d --- /dev/null +++ b/engine/lib/upgrades/2010062301.php @@ -0,0 +1,33 @@ +<?php + +/** + * Change ownership of group ACLs to group entity + */ + +elgg_set_ignore_access(TRUE); + +$params = array('type' => 'group', +				'limit' => 0); +$groups = elgg_get_entities($params); +if ($groups) { +	foreach ($groups as $group) { +		$acl = $group->group_acl; + +		try { +			$query = "UPDATE {$CONFIG->dbprefix}access_collections +				SET owner_guid = $group->guid WHERE id = $acl"; +			update_data($query); +		} catch (Exception $e) { +			// no acl so create one +			$ac_name = elgg_echo('groups:group') . ": " . $group->name; +			$group_acl = create_access_collection($ac_name, $group->guid); +			if ($group_acl) { +				create_metadata($group->guid, 'group_acl', $group_acl, 'integer', $group->owner_guid); +				$object->group_acl = $group_id; +			} +		} + +	} +} +elgg_set_ignore_access(FALSE); + | 
