view_message.php 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. <?php
  2. /* For licensing terms, see /license.txt */
  3. /**
  4. * @package chamilo.messages
  5. */
  6. $cidReset = true;
  7. require_once __DIR__.'/../inc/global.inc.php';
  8. api_block_anonymous_users();
  9. $allowSocial = api_get_setting('allow_social_tool') === 'true';
  10. $allowMessage = api_get_setting('allow_message_tool') === 'true';
  11. if (!$allowMessage) {
  12. api_not_allowed(true);
  13. }
  14. $messageId = isset($_GET['id']) ? (int) $_GET['id'] : 0;
  15. if (empty($messageId)) {
  16. api_not_allowed(true);
  17. }
  18. if ($allowSocial) {
  19. $this_section = SECTION_SOCIAL;
  20. $interbreadcrumb[] = ['url' => api_get_path(WEB_PATH).'main/social/home.php', 'name' => get_lang('Social network')];
  21. } else {
  22. $this_section = SECTION_MYPROFILE;
  23. $interbreadcrumb[] = ['url' => api_get_path(WEB_PATH).'main/auth/profile.php', 'name' => get_lang('Profile')];
  24. }
  25. $interbreadcrumb[] = ['url' => 'inbox.php', 'name' => get_lang('Messages')];
  26. $social_right_content = '<div class="actions">';
  27. if ($allowMessage) {
  28. $social_right_content .= '<a href="'.api_get_path(WEB_PATH).'main/messages/new_message.php">'.
  29. Display::return_icon('new-message.png', get_lang('Compose message')).'</a>';
  30. $social_right_content .= '<a href="'.api_get_path(WEB_PATH).'main/messages/inbox.php">'.
  31. Display::return_icon('inbox.png', get_lang('Inbox')).'</a>';
  32. $social_right_content .= '<a href="'.api_get_path(WEB_PATH).'main/messages/outbox.php">'.
  33. Display::return_icon('outbox.png', get_lang('Outbox')).'</a>';
  34. }
  35. $social_right_content .= '</div>';
  36. $type = isset($_GET['type']) ? (int) $_GET['type'] : MessageManager::MESSAGE_TYPE_INBOX;
  37. $show_menu = 'messages_inbox';
  38. if ($type === MessageManager::MESSAGE_TYPE_OUTBOX) {
  39. $show_menu = 'messages_outbox';
  40. }
  41. $message = '';
  42. $logInfo = [
  43. 'tool' => 'Messages',
  44. 'tool_id' => $messageId,
  45. 'action' => 'view-message',
  46. 'action_details' => 'view-message',
  47. ];
  48. Event::registerLog($logInfo);
  49. // LEFT COLUMN
  50. if (api_get_setting('allow_social_tool') === 'true') {
  51. // Block Social Menu
  52. $social_menu_block = SocialManager::show_social_menu($show_menu);
  53. }
  54. // MAIN CONTENT
  55. $message .= MessageManager::showMessageBox($messageId, $type);
  56. if (!empty($message)) {
  57. $social_right_content .= $message;
  58. } else {
  59. api_not_allowed(true);
  60. }
  61. $tpl = new Template(get_lang('View'));
  62. // Block Social Avatar
  63. SocialManager::setSocialUserBlock($tpl, api_get_user_id(), $show_menu);
  64. if (api_get_setting('allow_social_tool') === 'true') {
  65. $tpl->assign('social_menu_block', $social_menu_block);
  66. $tpl->assign('social_right_content', $social_right_content);
  67. $social_layout = $tpl->get_template('social/inbox.tpl');
  68. $tpl->display($social_layout);
  69. } else {
  70. $content = $social_right_content;
  71. $tpl->assign('content', $content);
  72. $tpl->display_one_col_template();
  73. }