inbox.php 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  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. $logInfo = [
  13. 'tool' => 'Messages',
  14. 'action' => isset($_GET['action']) ? $_GET['action'] : 'inbox',
  15. ];
  16. Event::registerLog($logInfo);
  17. $allowSocial = api_get_setting('allow_social_tool') == 'true';
  18. $allowMessage = api_get_setting('allow_message_tool') == 'true';
  19. if ($allowSocial) {
  20. $this_section = SECTION_SOCIAL;
  21. $interbreadcrumb[] = [
  22. 'url' => api_get_path(WEB_PATH).'main/social/home.php',
  23. 'name' => get_lang('Social network'),
  24. ];
  25. } else {
  26. $this_section = SECTION_MYPROFILE;
  27. $interbreadcrumb[] = [
  28. 'url' => api_get_path(WEB_PATH).'main/auth/profile.php',
  29. 'name' => get_lang('Profile'),
  30. ];
  31. }
  32. $interbreadcrumb[] = [
  33. 'url' => api_get_path(WEB_PATH).'main/messages/inbox.php',
  34. 'name' => get_lang('Messages'),
  35. ];
  36. $interbreadcrumb[] = ['url' => '#', 'name' => get_lang('Inbox')];
  37. $actions = '';
  38. // Comes from normal profile
  39. if ($allowSocial === false && $allowMessage) {
  40. $actions .= '<a href="'.api_get_path(WEB_PATH).'main/messages/new_message.php">'.
  41. Display::return_icon('message_new.png', get_lang('Compose message')).'</a>';
  42. $actions .= '<a href="'.api_get_path(WEB_PATH).'main/messages/inbox.php">'.
  43. Display::return_icon('inbox.png', get_lang('Inbox')).'</a>';
  44. $actions .= '<a href="'.api_get_path(WEB_PATH).'main/messages/outbox.php">'.
  45. Display::return_icon('outbox.png', get_lang('Outbox')).'</a>';
  46. }
  47. // LEFT CONTENT
  48. $social_menu_block = '';
  49. if ($allowSocial) {
  50. // Block Social Menu
  51. $social_menu_block = SocialManager::show_social_menu('messages');
  52. }
  53. // Right content
  54. $social_right_content = '';
  55. $keyword = '';
  56. if ($allowSocial) {
  57. $actionsLeft = '<a href="'.api_get_path(WEB_PATH).'main/messages/new_message.php">'.
  58. Display::return_icon('new-message.png', get_lang('Compose message'), [], 32).'</a>';
  59. $actionsLeft .= '<a href="'.api_get_path(WEB_PATH).'main/messages/outbox.php">'.
  60. Display::return_icon('outbox.png', get_lang('Outbox'), [], 32).'</a>';
  61. $form = MessageManager::getSearchForm(api_get_path(WEB_PATH).'main/messages/inbox.php');
  62. if ($form->validate()) {
  63. $values = $form->getSubmitValues();
  64. $keyword = $values['keyword'];
  65. }
  66. $actionsRight = $form->returnForm();
  67. $social_right_content .= Display::toolbarAction('toolbar', [$actionsLeft, $actionsRight]);
  68. }
  69. $social_right_content .= MessageManager::inboxDisplay($keyword);
  70. $tpl = new Template(null);
  71. if ($actions) {
  72. $tpl->assign('actions', Display::toolbarAction('toolbar', [$actions]));
  73. }
  74. // Block Social Avatar
  75. SocialManager::setSocialUserBlock($tpl, api_get_user_id(), 'messages');
  76. if ($allowSocial) {
  77. $tpl->assign('social_menu_block', $social_menu_block);
  78. $tpl->assign('social_right_content', $social_right_content);
  79. $social_layout = $tpl->get_template('social/inbox.tpl');
  80. $tpl->display($social_layout);
  81. } else {
  82. $content = $social_right_content;
  83. $tpl->assign('message', $show_message);
  84. $tpl->assign('content', $content);
  85. $tpl->display_one_col_template();
  86. }