delete.php 723 B

123456789101112131415161718192021222324252627282930313233
  1. <?php
  2. namespace AU\AnonymousComments;
  3. $page = $vars['page'];
  4. $show_hidden = access_get_show_hidden_status();
  5. access_show_hidden_entities(true);
  6. $comment = get_entity($page[1]);
  7. $token = $page[2];
  8. // make sure this is a legit moderated comment
  9. if (!($comment instanceof \ElggComment) || $comment->isEnabled()) {
  10. forward('', '404');
  11. }
  12. // make sure the token matches
  13. if ($token != get_token($comment)) {
  14. forward('', '404');
  15. }
  16. $container = $comment->getContainerEntity();
  17. // ok, all checks are passed
  18. $ia = elgg_set_ignore_access();
  19. $comment->delete();
  20. elgg_set_ignore_access($ia);
  21. access_show_hidden_entities($show_hidden);
  22. system_message(elgg_echo('AU_anonymous_comments:deleted'));
  23. forward($container->getURL());