PageRenderTime 47ms CodeModel.GetById 23ms RepoModel.GetById 0ms app.codeStats 0ms

/mod/messages/views/default/messages/view.php

https://github.com/sarriaroman/PuntoUBP
PHP | 153 lines | 86 code | 40 blank | 27 comment | 32 complexity | 23d3b9dc0880447e43b25ed89958fed2 MD5 | raw file
  1. <?php
  2. /**
  3. * Elgg messages view page
  4. *
  5. * @package ElggMessages
  6. * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2
  7. * @author Curverider Ltd <info@elgg.com>
  8. * @copyright Curverider Ltd 2008-2009
  9. * @link http://elgg.com/
  10. *
  11. * @uses $vars['entity'] An array of messages to view
  12. * @uses $vars['page_view'] This is the page the messages are being accessed from; inbox or sentbox
  13. *
  14. */
  15. $limit = $vars['limit']; if (empty($limit)) $limit = 10;
  16. $offset = $vars['offset']; if (!isset($offset)) $offset = 0;
  17. // If there are any messages to view, view them
  18. if (isloggedin())
  19. if (is_array($vars['entity']) && sizeof($vars['entity']) > 0) {
  20. ?>
  21. <div id="messages" /><!-- start the main messages wrapper div -->
  22. <?php
  23. // get the correct display for the inbox view
  24. if($vars['page_view'] == "inbox") {
  25. $counter = 0;
  26. foreach($vars['entity'] as $message) {
  27. if ($message->owner_guid == $vars['user']->guid
  28. || $message->toID == $vars['user']->guid) {
  29. //make sure to only display the messages that have not been 'deleted' (1 = deleted)
  30. if($message->hiddenFrom != 1){
  31. // check to see if the message has been read, if so, get the correct background color
  32. if($message->readYet == 1){
  33. echo "<div class=\"message_read\" />";
  34. }else{
  35. echo "<div class=\"message_notread\" />";
  36. }
  37. //set the table
  38. echo "<table width=\"100%\" cellspacing='0'><tr>";
  39. //get the icon of the user who owns the message
  40. $from = get_entity($message->fromId);
  41. echo "<td width='200px'>" . elgg_view("profile/icon",array('entity' => $from, 'size' => 'tiny')) . "<div class='msgsender'><b>" . $from->name . "</b><br /><small>" . friendly_time($message->time_created) . "</small></div></td>";
  42. //display the message title
  43. echo "<td><div class='msgsubject'>";
  44. echo "<input type=\"checkbox\" name=\"message_id[]\" value=\"{$message->guid}\" /> ";
  45. echo "<a href=\"{$message->getURL()}\">" . $message->title . "</a></div></td>";
  46. //display the link to 'delete'
  47. echo "<td width='70px'>";
  48. echo "<div class='delete_msg'>" . elgg_view("output/confirmlink", array(
  49. 'href' => $vars['url'] . "action/messages/delete?message_id=" . $message->getGUID() . "&type=inbox&submit=" . urlencode(elgg_echo('delete')),
  50. 'text' => elgg_echo('delete'),
  51. 'confirm' => elgg_echo('deleteconfirm'),
  52. )) . "</div>";
  53. echo "</td></tr></table>";
  54. echo "</div>"; // close the message background div
  55. }//end of hiddenFrom if statement
  56. } // end of user check
  57. $counter++;
  58. if ($counter == $limit) break;
  59. }//end of for each loop
  60. }//end of inbox if statement
  61. // get the correct display for the sentbox view
  62. if($vars['page_view'] == "sent") {
  63. $counter = 0;
  64. foreach($vars['entity'] as $message) {
  65. //make sure to only display the messages that have not been 'deleted' (1 = deleted)
  66. if($message->hiddenTo != 1){
  67. //get the correct user entity
  68. $user = get_entity($message->toID);
  69. echo "<div class=\"message_sent\" />";
  70. echo "<table width=\"100%\" cellspacing='0'><tr>";
  71. //get the icon for the user the message was sent to
  72. echo "<tr><td width='200px'>" . elgg_view("profile/icon",array('entity' => $user, 'size' => 'tiny')) . "<div class='msgsender'><b>" . $user->name . "</b><br /><small>" . friendly_time($message->time_created) . "</small></div></td>";
  73. //display the message title
  74. echo "<td><div class='msgsubject'>";
  75. echo "<input type=\"checkbox\" name=\"message_id[]\" value=\"{$message->guid}\" /> ";
  76. echo "<a href=\"{$message->getURL()}?type=sent\">" . $message->title . "</a></div></td>";
  77. //display the link to 'delete'
  78. echo "<td width='70px'>";
  79. echo "<div class='delete_msg'>" . elgg_view("output/confirmlink", array(
  80. 'href' => $vars['url'] . "action/messages/delete?message_id=" . $message->getGUID() . "&type=sent&submit=" . urlencode(elgg_echo('delete')),
  81. 'text' => elgg_echo('delete'),
  82. 'confirm' => elgg_echo('deleteconfirm'),
  83. )) . "</div>";
  84. echo "</td></tr></table></div>";
  85. }//close hiddeTo if statement
  86. $counter++;
  87. if ($counter == $limit) break;
  88. }//close foreach
  89. }//close page_view sent if statement
  90. $baseurl = $_SERVER['REQUEST_URI'];
  91. $baseurl = $baseurl = preg_replace('/[\&\?]offset\=[0-9]*/',"",$baseurl);
  92. $nav = '';
  93. if (sizeof($vars['entity']) > $limit) {
  94. $newoffset = $offset + $limit;
  95. $urladdition = 'offset='.$newoffset;
  96. if (substr_count($baseurl,'?')) $nexturl=$baseurl . '&' . $urladdition; else $nexturl=$baseurl . '?' . $urladdition;
  97. $nav .= '<a class="pagination_previous" href="'.$nexturl.'">&laquo; ' . elgg_echo('previous') . '</a> ';
  98. }
  99. if ($offset > 0) {
  100. $newoffset = $offset - $limit;
  101. if ($newoffset < 0) $newoffset = 0;
  102. $urladdition = 'offset='.$newoffset;
  103. if (substr_count($baseurl,'?')) $prevurl=$baseurl . '&' . $urladdition; else $prevurl=$baseurl . '?' . $urladdition;
  104. $nav .= '<a class="pagination_next" href="'.$prevurl.'">' . elgg_echo('next') . ' &raquo;</a> ';
  105. }
  106. if (!empty($nav)) {
  107. echo '<div class="pagination"><p>'.$nav.'</p><div class="clearfloat"></div></div>';
  108. }
  109. echo "</div>"; // close the main messages wrapper div
  110. } else {
  111. "<p class='messages_nomessage_message'>" . elgg_echo("messages:nomessages") . "</p>";
  112. }//end of the first if statement
  113. ?>