PageRenderTime 51ms CodeModel.GetById 26ms RepoModel.GetById 1ms app.codeStats 0ms

/inc/app/cms/boxes/messages/view/index.php

https://github.com/lux/sitellite
PHP | 90 lines | 74 code | 16 blank | 0 comment | 21 complexity | 70fcc6f700712c4efbf762148ea8af98 MD5 | raw file
Possible License(s): GPL-2.0, LGPL-2.1, Apache-2.0, GPL-3.0
  1. <?php
  2. global $cgi;
  3. loader_import ('cms.Workspace.Message');
  4. $msg = new WorkspaceMessage;
  5. if ($cgi->item) {
  6. $cgi->id = $cgi->item;
  7. }
  8. if ($cgi->category == 'Sent') {
  9. $res = $msg->getSent ($cgi->id);
  10. } else {
  11. $res = $msg->get ($cgi->id);
  12. }
  13. if (! $res) {
  14. page_title (intl_get ('Reading Message'));
  15. echo '<p>Error: ' . $msg->error . '</p>';
  16. return;
  17. }
  18. if ($cgi->category == 'Sent') {
  19. $res->category = 'Sent';
  20. } elseif ($cgi->category == 'Trash') {
  21. $res->category = 'Trash';
  22. } elseif ($res->category == '') {
  23. $res->category = 'Inbox';
  24. }
  25. page_title (intl_get ('Reading Message') . ': ' . $res->subject);
  26. $res->response_subject = Workspace::createResponseSubject ($res->subject);
  27. $list = $msg->getRecipients ($cgi->id);
  28. if (! $list) {
  29. $user_list = array ();
  30. $recipients = array (session_username ());
  31. } else {
  32. $user_list = array ();
  33. $recipients = array ();
  34. foreach ($list as $user) {
  35. if ($user->user != $res->from_user) {
  36. $recipients[] = $user->user;
  37. }
  38. if ($user->user == session_username ()) {
  39. continue;
  40. }
  41. if ($user->type == 'email') {
  42. $user_list[] = $user->email;
  43. } else {
  44. $user_list[] = $user->user;
  45. }
  46. }
  47. }
  48. $res->user_list = array_unique ($user_list);
  49. $res->recipients = array_unique ($recipients);
  50. function msg_show_user ($user) {
  51. if (strstr ($user, '@')) {
  52. return '<a href="mailto:' . $user . '">' . $user . '</a>';
  53. }
  54. $info = session_get_user ($user);
  55. if (! $info || empty ($info->lastname)) {
  56. return '<a href="' . site_prefix () . '/index/cms-user-view-action?user=' . $user . '">' . $user . '</a>';
  57. }
  58. return '<a href="' . site_prefix () . '/index/cms-user-view-action?user=' . $user . '">' . $info->lastname . ', ' . $info->firstname . '</a>';
  59. }
  60. function msg_date_format ($date) {
  61. loader_import ('saf.Date');
  62. return Date::timestamp (
  63. $date,
  64. array (
  65. 'today' => '\T\o\d\a\y \a\t g:ia',
  66. 'yesterday' => '\Y\e\s\t\e\r\d\a\y \a\t g:ia',
  67. 'tomorrow' => '\T\o\m\o\r\r\o\w \a\t g:ia',
  68. 'this week' => 'M j, Y',
  69. 'other' => 'M j, Y',
  70. )
  71. );
  72. }
  73. echo template_simple ('messages/view.spt', $res);
  74. ?>