moderate.php 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. <?php
  2. namespace AU\AnonymousComments;
  3. $guids = (array) get_input('guid', array());
  4. $review = get_input('review');
  5. access_show_hidden_entities(true);
  6. $deleted = false;
  7. $approved = false;
  8. foreach ($guids as $g) {
  9. $comment = get_entity($g);
  10. if (!($comment instanceof \ElggComment)) {
  11. continue;
  12. }
  13. $entity = $comment->getContainerEntity();
  14. if (!$entity || !$entity->canEdit()) {
  15. continue;
  16. }
  17. $ia = elgg_set_ignore_access(true);
  18. if ($review == 'delete' || $review == elgg_echo('AU_anonymous_comments:delete_checked')) {
  19. $comment->delete();
  20. $deleted = true;
  21. }
  22. if ($review == 'approve' || $review == elgg_echo('AU_anonymous_comments:approve_checked')) {
  23. $comment->enable();
  24. $comment->__anonymous_comment_token = null;
  25. $approved = true;
  26. }
  27. elgg_set_ignore_access($ia);
  28. }
  29. if ($deleted) {
  30. system_message(elgg_echo('AU_anonymous_comments:deleted'));
  31. }
  32. if ($approved) {
  33. system_message(elgg_echo('AU_anonymous_comments:approved'));
  34. }
  35. if (!$deleted && !$approved) {
  36. register_error(elgg_echo('AU_anonymous_comments:invalid:moderation'));
  37. }
  38. forward(REFERER);