view_message.php 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  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. }