approve.php 768 B

12345678910111213141516171819202122232425262728293031323334
  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->enable();
  20. $comment->__anonymous_comment_token = null;
  21. elgg_set_ignore_access($ia);
  22. access_show_hidden_entities($show_hidden);
  23. system_message(elgg_echo('AU_anonymous_comments:approved'));
  24. forward($container->getURL());