generic_comment.php 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. <?php
  2. /**
  3. * Elgg generic comment
  4. *
  5. * @package Elgg
  6. * @subpackage Core
  7. *
  8. * Modified for moderated comments
  9. */
  10. $owner = get_user($vars['annotation']->owner_guid);
  11. $entity_guid = $vars['annotation']->entity_guid;
  12. $mc_entity = get_entity($entity_guid);
  13. // get array of unreviewed comments
  14. $review_array = explode(',', $mc_entity->unmoderated_comments);
  15. // find out if our logged in user is the owner of the entity
  16. $entity_owner_id = $mc_entity->owner_guid;
  17. if(elgg_get_logged_in_user_guid() == $entity_owner_id){ // user IS the owner - they can see and approve comments
  18. //set a flag
  19. $can_see_unapproved = TRUE;
  20. }
  21. else{
  22. $can_see_unapproved = FALSE;
  23. }
  24. /*
  25. #### iku 2016-01-13 #1 ####
  26. #
  27. # function not AU_anonymous_comments_is_moderated found in module directory, commenting out
  28. #
  29. // show the comment only if it's already been reviewed, or if we're the moderator, or if moderation is turned off
  30. if(!in_array($vars['annotation']->id, $review_array) || $can_see_unapproved || !AU_anonymous_comments_is_moderated($entity_guid)){
  31. $mc_class = "generic_comment";
  32. $reviewed = true;
  33. if(AU_anonymous_comments_is_moderated($entity_guid)){
  34. if(in_array($vars['annotation']->id, $review_array)){ // we're moderating and this is unreviewed
  35. $mc_class = "generic_comment unreviewed";
  36. $reviewed = false;
  37. }
  38. }
  39. # simplified condition :
  40. */
  41. if(!in_array($vars['annotation']->id, $review_array) || $can_see_unapproved ){
  42. $mc_class = "generic_comment";
  43. $reviewed = true;
  44. ?>
  45. <div
  46. class="<?php echo $mc_class; ?>">
  47. <!-- start of generic_comment div -->
  48. <div class="generic_comment_icon">
  49. <?php
  50. echo elgg_view_entity_icon($owner, 'small');
  51. ?>
  52. </div>
  53. <div class="generic_comment_details">
  54. <!-- output the actual comment -->
  55. <?php echo elgg_view("output/longtext",array("value" => $vars['annotation']->value)); ?>
  56. <p class="generic_comment_owner">
  57. <a href="<?php echo $owner->getURL(); ?>"><?php echo $owner->name; ?>
  58. </a>
  59. <?php echo elgg_view_friendly_time($vars['annotation']->time_created); ?>
  60. </p>
  61. <?php
  62. // if the user looking at the comment can edit, show the delete link
  63. if ($vars['annotation']->canEdit() && $reviewed) {
  64. ?>
  65. <p>
  66. <?php
  67. echo elgg_view("output/confirmlink",array(
  68. 'href' => elgg_get_site_url() . "action/comments/delete?annotation_id=" . $vars['annotation']->id,
  69. 'text' => elgg_echo('delete'),
  70. 'confirm' => elgg_echo('deleteconfirm'),
  71. ));
  72. ?>
  73. </p>
  74. <?php
  75. } //end of can edit if statement
  76. /**
  77. *
  78. * Comment hasn't been reviewed, show options for approval/deletion
  79. */
  80. if($can_see_unapproved && !$reviewed){
  81. echo "<div class=\"moderate_options\">";
  82. echo "<table><tr><td style=\"width: 60px; vertical-align: middle;\">";
  83. echo "<input type=\"checkbox\" name=\"moderate_comments[]\" value=\"" . $vars['annotation']->id . "\" onclick=\"javascript:mc_toggle_approve('" . $vars['annotation']->id . "');\">";
  84. echo "</td><td>";
  85. echo elgg_echo('AU_anonymous_comments:comment_text');
  86. echo "<br><br>";
  87. echo "<a href=\"" . elgg_get_site_url() . "mod/AU_anonymous_comments/actions/annotation/review.php?id=" . $vars['annotation']->id . "&method=approve\">Approve</a>";
  88. echo "&nbsp;&nbsp;|&nbsp;&nbsp;";
  89. echo "<a href=\"" . elgg_get_site_url() . "mod/AU_anonymous_comments/actions/annotation/review.php?id=" . $vars['annotation']->id . "&method=delete\" onclick=\"return confirm('". elgg_echo('AU_anonymous_comments:delete_confirm') . "')\";>Delete</a>";
  90. echo "</td></tr></table>";
  91. echo "</div>";
  92. }
  93. ?>
  94. </div>
  95. <!-- end of generic_comment_details -->
  96. </div>
  97. <!-- end of generic_comment div -->
  98. <?php
  99. } // endif review check
  100. ?>