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. if (api_get_setting('allow_message_tool') != 'true') {
  10. api_not_allowed(true);
  11. }
  12. $allowSocial = api_get_setting('allow_social_tool') === 'true';
  13. $allowMessage = api_get_setting('allow_message_tool') === 'true';
  14. if ($allowSocial) {
  15. $this_section = SECTION_SOCIAL;
  16. $interbreadcrumb[] = ['url' => api_get_path(WEB_PATH).'main/social/home.php', 'name' => get_lang('SocialNetwork')];
  17. } else {
  18. $this_section = SECTION_MYPROFILE;
  19. $interbreadcrumb[] = ['url' => api_get_path(WEB_PATH).'main/auth/profile.php', 'name' => get_lang('Profile')];
  20. }
  21. $interbreadcrumb[] = ['url' => 'inbox.php', 'name' => get_lang('Messages')];
  22. $social_right_content = '<div class="actions">';
  23. if (api_get_setting('allow_message_tool') === 'true') {
  24. $social_right_content .= '<a href="'.api_get_path(WEB_PATH).'main/messages/new_message.php">'.
  25. Display::return_icon('new-message.png', get_lang('ComposeMessage')).'</a>';
  26. $social_right_content .= '<a href="'.api_get_path(WEB_PATH).'main/messages/inbox.php">'.
  27. Display::return_icon('inbox.png', get_lang('Inbox')).'</a>';
  28. $social_right_content .= '<a href="'.api_get_path(WEB_PATH).'main/messages/outbox.php">'.
  29. Display::return_icon('outbox.png', get_lang('Outbox')).'</a>';
  30. }
  31. $social_right_content .= '</div>';
  32. if (empty($_GET['id'])) {
  33. $messageId = $_GET['id_send'];
  34. $source = 'outbox';
  35. $show_menu = 'messages_outbox';
  36. } else {
  37. $messageId = $_GET['id'];
  38. $source = 'inbox';
  39. $show_menu = 'messages_inbox';
  40. }
  41. $message = '';
  42. $logInfo = [
  43. 'tool' => 'Messages',
  44. 'tool_id' => 0,
  45. 'tool_id_detail' => 0,
  46. 'action' => $source,
  47. 'action_details' => 'view-message',
  48. ];
  49. Event::registerLog($logInfo);
  50. // LEFT COLUMN
  51. if (api_get_setting('allow_social_tool') === 'true') {
  52. // Block Social Menu
  53. $social_menu_block = SocialManager::show_social_menu($show_menu);
  54. }
  55. // MAIN CONTENT
  56. $message .= MessageManager::showMessageBox($messageId, $source);
  57. if (!empty($message)) {
  58. $social_right_content .= $message;
  59. } else {
  60. api_not_allowed(true);
  61. }
  62. $tpl = new Template(get_lang('View'));
  63. // Block Social Avatar
  64. SocialManager::setSocialUserBlock($tpl, api_get_user_id(), $show_menu);
  65. if (api_get_setting('allow_social_tool') === 'true') {
  66. $tpl->assign('social_menu_block', $social_menu_block);
  67. $tpl->assign('social_right_content', $social_right_content);
  68. $social_layout = $tpl->get_template('social/inbox.tpl');
  69. $tpl->display($social_layout);
  70. } else {
  71. $content = $social_right_content;
  72. $tpl->assign('content', $content);
  73. $tpl->display_one_col_template();
  74. }