2010062301.php 784 B

12345678910111213141516171819202122232425262728293031323334
  1. <?php
  2. /**
  3. * Change ownership of group ACLs to group entity
  4. */
  5. elgg_set_ignore_access(TRUE);
  6. $params = array('type' => 'group',
  7. 'limit' => 0);
  8. $groups = elgg_get_entities($params);
  9. if ($groups) {
  10. foreach ($groups as $group) {
  11. $acl = $group->group_acl;
  12. try {
  13. $query = "UPDATE {$CONFIG->dbprefix}access_collections
  14. SET owner_guid = $group->guid WHERE id = $acl";
  15. update_data($query);
  16. } catch (Exception $e) {
  17. // no acl so create one
  18. $ac_name = elgg_echo('groups:group') . ": " . $group->name;
  19. $group_acl = create_access_collection($ac_name, $group->guid);
  20. if ($group_acl) {
  21. create_metadata($group->guid, 'group_acl', $group_acl, 'integer', $group->owner_guid);
  22. $object->group_acl = $group_id;
  23. }
  24. }
  25. }
  26. }
  27. elgg_set_ignore_access(FALSE);