messages.php 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. <?php
  2. /**
  3. * File renderer.
  4. *
  5. * @package ElggFile
  6. */
  7. $full = elgg_extract('full_view', $vars, false);
  8. $message = elgg_extract('entity', $vars, false);
  9. $bulk_actions = (bool) elgg_extract('bulk_actions', $vars, false);
  10. if (!$message) {
  11. return true;
  12. }
  13. if ($message->toId == elgg_get_page_owner_guid()) {
  14. // received
  15. $user = get_user($message->fromId);
  16. if ($user) {
  17. $icon = elgg_view_entity_icon($user, 'tiny');
  18. $user_link = elgg_view('output/url', array(
  19. 'href' => "messages/compose?send_to=$user->guid",
  20. 'text' => $user->name,
  21. 'is_trusted' => true,
  22. ));
  23. } else {
  24. $icon = '';
  25. $user_link = elgg_echo('messages:deleted_sender');
  26. }
  27. if ($message->readYet) {
  28. $class = 'message read';
  29. } else {
  30. $class = 'message unread';
  31. }
  32. } else {
  33. // sent
  34. $user = get_user($message->toId);
  35. if ($user) {
  36. $icon = elgg_view_entity_icon($user, 'tiny');
  37. $user_link = elgg_view('output/url', array(
  38. 'href' => "messages/compose?send_to=$user->guid",
  39. 'text' => elgg_echo('messages:to_user', array($user->name)),
  40. 'is_trusted' => true,
  41. ));
  42. } else {
  43. $icon = '';
  44. $user_link = elgg_echo('messages:deleted_sender');
  45. }
  46. $class = 'message read';
  47. }
  48. $timestamp = elgg_view_friendly_time($message->time_created);
  49. $subject_info = elgg_view('output/url', array(
  50. 'href' => $message->getURL(),
  51. 'text' => $message->title,
  52. 'is_trusted' => true,
  53. ));
  54. $delete_link = elgg_view("output/url", array(
  55. 'href' => "action/messages/delete?guid=" . $message->getGUID() . "&full=$full",
  56. 'text' => elgg_view_icon('delete', 'float-alt'),
  57. 'confirm' => elgg_echo('deleteconfirm'),
  58. 'encode_text' => false,
  59. ));
  60. $body = <<<HTML
  61. <div class="messages-owner">$user_link</div>
  62. <div class="messages-subject">$subject_info</div>
  63. <div class="messages-timestamp">$timestamp</div>
  64. <div class="messages-delete">$delete_link</div>
  65. HTML;
  66. if ($full) {
  67. echo elgg_view_image_block($icon, $body, array('class' => $class));
  68. echo elgg_view('output/longtext', array('value' => $message->description));
  69. } else {
  70. $body .= elgg_view("output/longtext", array("value" => elgg_get_excerpt($message->description), "class" => "elgg-subtext clearfloat"));
  71. if ($bulk_actions) {
  72. $checkbox = elgg_view('input/checkbox', array(
  73. 'name' => 'message_id[]',
  74. 'value' => $message->guid,
  75. 'default' => false
  76. ));
  77. $entity_listing = elgg_view_image_block($icon, $body, array('class' => $class));
  78. echo elgg_view_image_block($checkbox, $entity_listing);
  79. } else {
  80. echo elgg_view_image_block($icon, $body, array('class' => $class));
  81. }
  82. }