/mod/openlabs/views/default/openlab_forum/topicposts.php

https://github.com/bpmn/bpmn · PHP · 182 lines · 129 code · 34 blank · 19 comment · 7 complexity · 9f00f9a870c4c22baaa081f8e632e14a MD5 · raw file

  1. <?php
  2. /**
  3. * Elgg Topic individual post view. This is all the follow up posts on a particular topic
  4. *
  5. * @package Elggopenlabs from ElggGroups
  6. *
  7. * @uses $vars['entity'] The posted comment to view
  8. */
  9. ?>
  10. <!-- start the topic_post -->
  11. <div class="topic_post">
  12. <table width="100%">
  13. <tr>
  14. <td>
  15. <a name="<?php echo $vars['entity']->id; ?>"></a>
  16. <?php
  17. //get infomation about the owner of the comment
  18. if ($post_owner = get_user($vars['entity']->owner_guid)) {
  19. //display the user icon
  20. echo "<div class=\"post_icon\">" . elgg_view("profile/icon",array('entity' => $post_owner, 'size' => 'small')) . "</div>";
  21. //display the user name
  22. echo "<p><b>" . $post_owner->name . "</b><br />";
  23. //display the date of the comment
  24. echo "<small>" . elgg_view_friendly_time($vars['entity']->time_created) . "</small></p>";
  25. } else {
  26. echo "<div class=\"post_icon\"><img src=\"" . elgg_view('icon/user/default/small') . "\" /></div>"; //display the user name
  27. echo "<p><b>" . $post_owner->name . "</b><br />";
  28. //display the date of the comment
  29. echo "<small>" . elgg_view_friendly_time($vars['entity']->time_created) . "</small></p>";
  30. echo "<p><b>" . elgg_echo('profile:deleteduser') . "</b><br />";
  31. }
  32. ?>
  33. </td>
  34. </tr>
  35. </table>
  36. <table width="100%">
  37. <tr>
  38. <td>
  39. <a name="<?php echo $vars['entity']->id; ?>"></a>
  40. <?php
  41. $boopinnComment = $vars['entity'];
  42. $authorId = $boopinnComment->getAuthorId();
  43. $post_owner = get_user($authorId);
  44. $topicGuid = $boopinnComment->getTopicGuid() ;
  45. $topic = get_entity($topicGuid) ;
  46. $openlabGuid = $topic->container_guid ;
  47. $post_owner = TRUE;
  48. //get infomation about the owner of the comment
  49. if ($post_owner) {
  50. //display the user icon
  51. echo "<div class=\"post_icon\">" . elgg_view("profile/icon", array('entity' => $post_owner, 'size' => 'small')) . "</div>";
  52. //display the user name
  53. echo "<p><b>" . $post_owner->name . "</b><br />";
  54. } else {
  55. echo "<div class=\"post_icon\"><img src=\"" . elgg_view('icon/user/default/small') . "\" /></div>";
  56. echo "<p><b>" . elgg_echo('profile:deleteduser') . "</b><br />";
  57. }
  58. ?>
  59. </td>
  60. </tr>
  61. <tr>
  62. <td>
  63. <?php
  64. //display the actual message posted
  65. $post = $boopinnComment->getComment() ;
  66. echo parse_urls(elgg_view("output/longtext", array("value" => $post )));
  67. ?>
  68. </td>
  69. </tr>
  70. <tr>
  71. <td>
  72. <?php
  73. $openlab = get_entity($openlabGuid) ;
  74. if ($openlab->isMember(get_loggedin_userid()) )
  75. {
  76. echo '<div class = "postrating">';
  77. echo elgg_view("openlab_output/iconurl", array(
  78. 'href' => $vars['url'] . "action/openlabs/rate_plus?annotation_id=" . $boopinnComment->guid,
  79. 'src' => $vars['url'] . "mod/openlabs/graphics/thumb-up-icon.png",
  80. 'alt' => "Good comment !!!",
  81. "is_action" => true));
  82. echo '</div>';
  83. if ($boopinnComment->getRating() > 0)
  84. {
  85. echo '<div class = "postrating">';
  86. echo elgg_view("openlab_output/iconurl", array(
  87. 'href' => $vars['url'] . "action/openlabs/rate_less?annotation_id=" . $boopinnComment->guid,
  88. 'src' => $vars['url'] . "mod/openlabs/graphics/thumb-down-icon.png",
  89. 'alt' => "Bad comment !!!",
  90. "is_action" => true));
  91. echo '</div>';
  92. }
  93. }
  94. ?>
  95. </td>
  96. <td>
  97. <?php
  98. $nbRating = $vars['entity']->getRating() ;
  99. echo '<div class = "commentnumberrating">'. sprintf(elgg_echo("openlab:commentnumberrating"),$nbRating) ."</div>" ;
  100. ?>
  101. </td>
  102. </tr>
  103. </table>
  104. <?php
  105. //if the comment owner is looking at it, or admin, or openlab owner they can edit
  106. if (openlabs_can_edit_discussion($vars['entity'], page_owner_entity()->owner_guid)) {
  107. ?>
  108. <p class="topic-post-menu">
  109. <?php
  110. echo elgg_view("output/confirmlink", array(
  111. 'href' => $vars['url'] . "action/openlabs/deletepost?post=" . $boopinnComment->guid . "&topic=" . get_input('topic') . "&openlab=" . get_input('openlab_guid'),
  112. 'text' => elgg_echo('delete'),
  113. 'confirm' => elgg_echo('deleteconfirm'),
  114. ));
  115. //display an edit link that will open up an edit area
  116. echo " <a class=\"collapsibleboxlink\">" . elgg_echo('edit') . "</a>";
  117. echo "<div class=\"collapsible_box\">";
  118. //get the edit form and details
  119. $submit_input = elgg_view('input/submit', array('internalname' => 'submit', 'value' => elgg_echo('save')));
  120. $text_textarea = elgg_view('input/longtext', array('internalname' => 'postComment' . $boopinnComment->guid, 'value' => $boopinnComment->post));
  121. $post = elgg_view('input/hidden', array('internalname' => 'post', 'value' => $boopinnComment->guid));
  122. $field = elgg_view('input/hidden', array('internalname' => 'field_num', 'value' => $boopinnComment->guid));
  123. $topic = elgg_view('input/hidden', array('internalname' => 'topic', 'value' => get_input('topic')));
  124. $openlab = elgg_view('input/hidden', array('internalname' => 'openlab', 'value' => $openlabGuid));
  125. $form_body = <<<EOT
  126. <div class='edit_forum_comments'>
  127. <p class='longtext_editarea'>
  128. $text_textarea
  129. </p>
  130. $post
  131. $topic
  132. $openlab
  133. $field
  134. <p>
  135. $submit_input
  136. </p>
  137. </div>
  138. EOT;
  139. ?>
  140. <?php
  141. echo elgg_view('input/form', array('action' => "{$vars['url']}action/openlabs/editpost", 'body' => $form_body, 'internalid' => 'editforumpostForm'));
  142. ?>
  143. </div>
  144. </p>
  145. <?php
  146. }
  147. ?>
  148. </div><!-- end the topic_post -->