outbox.php 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  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. if (isset($_GET['messages_page_nr'])) {
  13. if (api_get_setting('allow_social_tool') == 'true' &&
  14. api_get_setting('allow_message_tool') == 'true'
  15. ) {
  16. $social_link = '';
  17. if ($_REQUEST['f'] == 'social') {
  18. $social_link = '&f=social';
  19. }
  20. header('Location:outbox.php?pager='.Security::remove_XSS($_GET['messages_page_nr']).$social_link.'');
  21. exit;
  22. }
  23. }
  24. $htmlHeadXtra[] = '<script>
  25. function enviar(miforma) {
  26. if(confirm("'.get_lang('SureYouWantToDeleteSelectedMessages', '').'"))
  27. miforma.submit();
  28. }
  29. function select_all(formita) {
  30. for (i=0;i<formita.elements.length;i++)
  31. {
  32. if(formita.elements[i].type == "checkbox")
  33. formita.elements[i].checked=1
  34. }
  35. }
  36. function deselect_all(formita) {
  37. for (i=0;i<formita.elements.length;i++) {
  38. if(formita.elements[i].type == "checkbox")
  39. formita.elements[i].checked=0
  40. }
  41. }
  42. </script>';
  43. /*
  44. MAIN CODE
  45. */
  46. if (isset($_GET['f']) && $_GET['f'] === 'social') {
  47. $this_section = SECTION_SOCIAL;
  48. $interbreadcrumb[] = array('url' => api_get_path(WEB_PATH).'main/social/home.php', 'name' => get_lang('Social'));
  49. $interbreadcrumb[] = array('url' => '#', 'name' => get_lang('Outbox'));
  50. } else {
  51. $this_section = SECTION_MYPROFILE;
  52. $interbreadcrumb[] = array('url' => api_get_path(WEB_PATH).'main/auth/profile.php', 'name' => get_lang('Profile'));
  53. $interbreadcrumb[] = array('url' => '#', 'name' => get_lang('Outbox'));
  54. }
  55. $actions = '';
  56. if (api_get_setting('extended_profile') == 'true') {
  57. if (api_get_setting('allow_social_tool') == 'true' && api_get_setting('allow_message_tool') == 'true') {
  58. $actions .= '<a href="'.api_get_path(WEB_PATH).'main/social/profile.php">'.
  59. Display::return_icon('shared_profile.png', get_lang('ViewSharedProfile')).'</a>';
  60. }
  61. if (api_get_setting('allow_message_tool') == 'true') {
  62. //echo '<a href="'.api_get_path(WEB_PATH).'main/messages/inbox.php">'.Display::return_icon('inbox.png').' '.get_lang('Messages').'</a>';
  63. $actions .= '<a href="'.api_get_path(WEB_PATH).'main/messages/new_message.php">'.
  64. Display::return_icon('message_new.png', get_lang('ComposeMessage')).'</a>';
  65. $actions .= '<a href="'.api_get_path(WEB_PATH).'main/messages/inbox.php">'.
  66. Display::return_icon('inbox.png', get_lang('Inbox')).'</a>';
  67. $actions .= '<a href="'.api_get_path(WEB_PATH).'main/messages/outbox.php">'.
  68. Display::return_icon('outbox.png', get_lang('Outbox')).'</a>';
  69. }
  70. }
  71. $info_delete_outbox = array();
  72. $info_delete_outbox = isset($_GET['form_delete_outbox']) ? explode(',', $_GET['form_delete_outbox']) : '';
  73. $count_delete_outbox = count($info_delete_outbox) - 1;
  74. if (isset($info_delete_outbox[0]) && trim($info_delete_outbox[0]) == 'delete') {
  75. for ($i = 1; $i <= $count_delete_outbox; $i++) {
  76. MessageManager::delete_message_by_user_sender(api_get_user_id(), $info_delete_outbox[$i]);
  77. }
  78. $message_box = get_lang('SelectedMessagesDeleted').
  79. '&nbsp
  80. <br><a href="../social/index.php?#remote-tab-3">'.
  81. get_lang('BackToOutbox').
  82. '</a>';
  83. Display::addFlash(
  84. Display::return_message(
  85. api_xml_http_response_encode($message_box),
  86. 'normal',
  87. false
  88. )
  89. );
  90. exit;
  91. }
  92. $action = null;
  93. if (isset($_REQUEST['action'])) {
  94. $action = $_REQUEST['action'];
  95. }
  96. $keyword = '';
  97. $social_right_content = '';
  98. if (api_get_setting('allow_social_tool') == 'true') {
  99. //Block Social Menu
  100. $social_menu_block = SocialManager::show_social_menu('messages');
  101. $actionsLeft = '<a href="'.api_get_path(WEB_PATH).'main/messages/inbox.php?f=social">'.
  102. Display::return_icon('back.png', get_lang('Back'), array(), 32).'</a>';
  103. $form = MessageManager::getSearchForm(api_get_path(WEB_PATH).'main/messages/outbox.php');
  104. if ($form->validate()) {
  105. $values = $form->getSubmitValues();
  106. $keyword = $values['keyword'];
  107. }
  108. $actionsRight = $form->returnForm();
  109. $social_right_content .= Display::toolbarAction(
  110. 'toolbar',
  111. [$actionsLeft, $actionsRight]
  112. );
  113. }
  114. //MAIN CONTENT
  115. if ($action == 'delete') {
  116. $delete_list_id = array();
  117. if (isset($_POST['out'])) {
  118. $delete_list_id = $_POST['out'];
  119. }
  120. if (isset($_POST['id'])) {
  121. $delete_list_id = $_POST['id'];
  122. }
  123. for ($i = 0; $i < count($delete_list_id); $i++) {
  124. MessageManager::delete_message_by_user_sender(
  125. api_get_user_id(),
  126. $delete_list_id[$i]
  127. );
  128. }
  129. $delete_list_id = array();
  130. $social_right_content .= MessageManager::outbox_display($keyword);
  131. } elseif ($action == 'deleteone') {
  132. $delete_list_id = array();
  133. $id = Security::remove_XSS($_GET['id']);
  134. MessageManager::delete_message_by_user_sender(api_get_user_id(), $id);
  135. $delete_list_id = array();
  136. $social_right_content .= MessageManager::outbox_display($keyword);
  137. } else {
  138. $social_right_content .= MessageManager::outbox_display($keyword);
  139. }
  140. $tpl = new Template(get_lang('ComposeMessage'));
  141. // Block Social Avatar
  142. SocialManager::setSocialUserBlock($tpl, api_get_user_id(), 'messages');
  143. if (api_get_setting('allow_social_tool') == 'true') {
  144. $tpl->assign('social_menu_block', $social_menu_block);
  145. $tpl->assign('social_right_content', $social_right_content);
  146. $social_layout = $tpl->get_template('social/inbox.tpl');
  147. $tpl->display($social_layout);
  148. } else {
  149. $content = $social_right_content;
  150. if ($actions) {
  151. $tpl->assign(
  152. 'actions',
  153. Display::toolbarAction('toolbar', [$actions])
  154. );
  155. }
  156. $tpl->assign('content', $content);
  157. $tpl->display_one_col_template();
  158. }