AU_anonymous_comments_pre_edit.php 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. <?php
  2. namespace AU\AnonymousComments;
  3. /**
  4. *
  5. * This view prepends the comment form, displays the notice letting users know comments are moderated
  6. * If the user is the content owner, it gives the forms to batch approve/delete comments
  7. *
  8. * Note that as of 1.8 this gets called inside another form, hence the javascript needed
  9. * to properly submit approve/delete
  10. *
  11. */
  12. elgg_require_js('anonymous_comments');
  13. if($vars['annotation_name'] == "generic_comment" && is_numeric($vars['guid'])){
  14. $entity_guid = $vars['guid'];
  15. $entity = get_entity($entity_guid);
  16. // have to count total number of comments like this because we have a plugin hook
  17. // that modifies the default count to only include visible comments
  18. $tmpcommentcount = $entity->getAnnotations('generic_comment');
  19. $real_comment_num = count($tmpcommentcount);
  20. $visible_comment_count = $entity->countComments();
  21. $comments_to_moderate = $real_comment_num - $visible_comment_count;
  22. // only show the message once
  23. if($mc_notice_count != 1){
  24. $mc_notice_count = 1;
  25. if((is_moderated($entity) && !elgg_is_logged_in()) || (is_moderated($entity) && $comments_to_moderate > 0 && $entity->owner_guid == elgg_get_logged_in_user_guid())){
  26. echo "<div class=\"generic_comment mc_notice\">";
  27. }
  28. if(elgg_get_logged_in_user_guid() == $entity->owner_guid && is_moderated($entity) && $comments_to_moderate > 0){
  29. ?>
  30. <div class="mc_moderation_control">
  31. <form id="mcApprovalForm"
  32. action="<?php echo $vars['url']; ?>mod/AU_anonymous_comments/actions/annotation/review.php"
  33. method="post">
  34. <input id="mcApprovalID" type="hidden" name="id" value=""> <input
  35. type="hidden" name="method" value="approve"> <input type="submit"
  36. value="<?php echo elgg_echo('AU_anonymous_comments:approve_checked'); ?>">
  37. </form>
  38. </div>
  39. <div class="mc_moderation_control">
  40. <form id="mcDeleteForm"
  41. action="<?php echo $vars['url']; ?>mod/AU_anonymous_comments/actions/annotation/review.php"
  42. method="post">
  43. <input id="mcDeleteID" type="hidden" name="id" value=""> <input
  44. type="hidden" name="method" value="delete"> <input type="submit"
  45. value="<?php echo elgg_echo('AU_anonymous_comments:delete_checked'); ?>"
  46. onclick="return confirm('<?php echo elgg_echo('AU_anonymous_comments:delete_confirm'); ?>');">
  47. </form>
  48. </div>
  49. <script type="text/javascript">
  50. var idarray = new Array();
  51. </script>
  52. <?php
  53. }
  54. if((is_moderated($entity) && !elgg_is_logged_in()) || (is_moderated($entity_guid) && $comments_to_moderate > 0 && $entity->owner_guid == elgg_get_logged_in_user_guid())){
  55. echo "<div class=\"mc_clear_div\"></div>";
  56. echo "</div>";
  57. }
  58. ?>
  59. <?php
  60. } // end if $mc_notice_count
  61. }