remove_related_groups.php 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. <?php
  2. /**
  3. * Action to save a new related group
  4. */
  5. $group_guid = (int) get_input("group_guid");
  6. $guid = (int) get_input("guid");
  7. if (!empty($group_guid) && !empty($guid)) {
  8. $group = get_entity($group_guid);
  9. $related = get_entity($guid);
  10. // do we have groups
  11. if (!empty($group) && elgg_instanceof($group, "group") && !empty($related) && elgg_instanceof($related, "group")) {
  12. if ($group->canEdit()) {
  13. // related?
  14. if (check_entity_relationship($group->getGUID(), "related_group", $related->getGUID())) {
  15. if (remove_entity_relationship($group->getGUID(), "related_group", $related->getGUID())) {
  16. system_message(elgg_echo("group_tools:action:remove_related_groups:success"));
  17. } else {
  18. register_error(elgg_echo("group_tools:action:remove_related_groups:error:remove"));
  19. }
  20. } else {
  21. register_error(elgg_echo("group_tools:action:remove_related_groups:error:not_related"));
  22. }
  23. } else {
  24. register_error(elgg_echo("groups:cantedit"));
  25. }
  26. } else {
  27. register_error(elgg_echo("groups:notfound:details"));
  28. }
  29. } else {
  30. register_error(elgg_echo("InvalidParameterException:MissingParameter"));
  31. }
  32. forward(REFERER);