outbox.php 3.1 KB

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