toggle_status.php 880 B

1234567891011121314151617181920212223242526272829303132
  1. <?php
  2. /**
  3. * Quickly open/close a discussion
  4. */
  5. $guid = (int) get_input("guid");
  6. if (!empty($guid)) {
  7. $entity = get_entity($guid);
  8. if (!empty($entity) && $entity->canEdit()) {
  9. if (elgg_instanceof($entity, "object", "groupforumtopic")) {
  10. if ($entity->status == "closed") {
  11. $entity->status = "open";
  12. system_message(elgg_echo("group_tools:action:discussion:toggle_status:success:open"));
  13. } else {
  14. $entity->status = "closed";
  15. system_message(elgg_echo("group_tools:action:discussion:toggle_status:success:close"));
  16. }
  17. } else {
  18. register_error(elgg_echo("ClassException:ClassnameNotClass", array($guid, elgg_echo("item:object:groupforumtopic"))));
  19. }
  20. } else {
  21. register_error(elgg_echo("InvalidParameterException:NoEntityFound"));
  22. }
  23. } else {
  24. register_error(elgg_echo("InvalidParameterException:MissingParameter"));
  25. }
  26. forward(REFERER);