outbox.php 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174
  1. <?php
  2. /* For licensing terms, see /license.txt */
  3. /**
  4. * @package chamilo.messages
  5. */
  6. /**
  7. * Code
  8. */
  9. // name of the language file that needs to be included
  10. $language_file = array('registration','messages','userInfo');
  11. $cidReset=true;
  12. require_once '../inc/global.inc.php';
  13. api_block_anonymous_users();
  14. if (isset($_GET['messages_page_nr'])) {
  15. if (api_get_setting('allow_social_tool')=='true' && api_get_setting('allow_message_tool')=='true') {
  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. if (api_get_setting('allow_message_tool')!='true'){
  25. api_not_allowed();
  26. }
  27. //jquery thickbox already called from main/inc/header.inc.php
  28. $htmlHeadXtra[]='<script language="javascript">
  29. <!--
  30. function enviar(miforma)
  31. {
  32. if(confirm("'.get_lang('SureYouWantToDeleteSelectedMessages', '').'"))
  33. miforma.submit();
  34. }
  35. function select_all(formita)
  36. {
  37. for (i=0;i<formita.elements.length;i++)
  38. {
  39. if(formita.elements[i].type == "checkbox")
  40. formita.elements[i].checked=1
  41. }
  42. }
  43. function deselect_all(formita)
  44. {
  45. for (i=0;i<formita.elements.length;i++)
  46. {
  47. if(formita.elements[i].type == "checkbox")
  48. formita.elements[i].checked=0
  49. }
  50. }
  51. //-->
  52. </script>';
  53. /*
  54. MAIN CODE
  55. */
  56. //$nameTools = get_lang('Messages');
  57. //api_display_tool_title(api_xml_http_response_encode(get_lang('Inbox')));
  58. if ($_GET['f']=='social') {
  59. $this_section = SECTION_SOCIAL;
  60. $interbreadcrumb[]= array ('url' => api_get_path(WEB_PATH).'main/social/home.php','name' => get_lang('Social'));
  61. $interbreadcrumb[]= array ('url' => '#','name' => get_lang('Outbox'));
  62. } else {
  63. $this_section = SECTION_MYPROFILE;
  64. $interbreadcrumb[]= array ('url' => api_get_path(WEB_PATH).'main/auth/profile.php','name' => get_lang('Profile'));
  65. $interbreadcrumb[]= array ('url' => '#','name' => get_lang('Outbox'));
  66. }
  67. Display::display_header('');
  68. if ($_GET['f']=='social') {
  69. } else {
  70. if (api_get_setting('extended_profile') == 'true') {
  71. echo '<div class="actions">';
  72. if (api_get_setting('allow_social_tool') == 'true' && api_get_setting('allow_message_tool') == 'true') {
  73. echo '<a href="'.api_get_path(WEB_PATH).'main/social/profile.php">'.Display::return_icon('shared_profile.png', get_lang('ViewSharedProfile')).'&nbsp;'.get_lang('ViewSharedProfile').'</a>';
  74. }
  75. if (api_get_setting('allow_message_tool') == 'true') {
  76. //echo '<a href="'.api_get_path(WEB_PATH).'main/messages/inbox.php">'.Display::return_icon('inbox.png').' '.get_lang('Messages').'</a>';
  77. echo '<a href="'.api_get_path(WEB_PATH).'main/messages/new_message.php">'.Display::return_icon('message_new.png',get_lang('ComposeMessage')).get_lang('ComposeMessage').'</a>';
  78. echo '<a href="'.api_get_path(WEB_PATH).'main/messages/inbox.php">'.Display::return_icon('inbox.png',get_lang('Inbox')).get_lang('Inbox').'</a>';
  79. echo '<a href="'.api_get_path(WEB_PATH).'main/messages/outbox.php">'.Display::return_icon('outbox.png',get_lang('Outbox')).get_lang('Outbox').'</a>';
  80. }
  81. //echo '<a href="'.api_get_path(WEB_PATH).'main/auth/profile.php?type=reduced">'.Display::return_icon('edit.gif', get_lang('EditNormalProfile')).'&nbsp;'.get_lang('EditNormalProfile').'</a>';
  82. echo '</div>';
  83. }
  84. }
  85. $info_delete_outbox=array();
  86. $info_delete_outbox=explode(',',$_GET['form_delete_outbox']);
  87. $count_delete_outbox=(count($info_delete_outbox)-1);
  88. if( trim($info_delete_outbox[0])=='delete' ) {
  89. for ($i=1;$i<=$count_delete_outbox;$i++) {
  90. MessageManager::delete_message_by_user_sender(api_get_user_id(),$info_delete_outbox[$i]);
  91. }
  92. $message_box=get_lang('SelectedMessagesDeleted').
  93. '&nbsp
  94. <br><a href="../social/index.php?#remote-tab-3">'.
  95. get_lang('BackToOutbox').
  96. '</a>';
  97. Display::display_normal_message(api_xml_http_response_encode($message_box),false);
  98. exit;
  99. }
  100. $table_message = Database::get_main_table(TABLE_MESSAGE);
  101. $user_sender_id = api_get_user_id();
  102. $action = null;
  103. if (isset($_REQUEST['action'])) {
  104. $action = $_REQUEST['action'];
  105. }
  106. echo '<div id="social-content">';
  107. $id_content_right = '';
  108. //LEFT COLUMN
  109. if (api_get_setting('allow_social_tool') != 'true') {
  110. $id_content_right = 'outbox';
  111. } else {
  112. $id_content_right = 'social-content-right';
  113. echo '<div id="social-content-left">';
  114. //this include the social menu div
  115. SocialManager::show_social_menu('messages');
  116. echo '</div>';
  117. }
  118. echo '<div id="'.$id_content_right.'">';
  119. if (api_get_setting('allow_social_tool') == 'true') {
  120. echo '<div class="actions">';
  121. echo '<a href="'.api_get_path(WEB_PATH).'main/messages/inbox.php?f=social">'.Display::return_icon('back.png', get_lang('Back'), array(), 32).'</a>';
  122. echo '</div>';
  123. }
  124. //MAIN CONTENT
  125. if ($action == 'delete') {
  126. $delete_list_id=array();
  127. if (isset($_POST['out'])) {
  128. $delete_list_id=$_POST['out'];
  129. }
  130. if (isset($_POST['id'])) {
  131. $delete_list_id=$_POST['id'];
  132. }
  133. for ($i=0;$i<count($delete_list_id);$i++) {
  134. MessageManager::delete_message_by_user_sender(api_get_user_id(), $delete_list_id[$i]);
  135. }
  136. $delete_list_id=array();
  137. outbox_display();
  138. } elseif($action =='deleteone') {
  139. $delete_list_id=array();
  140. $id=Security::remove_XSS($_GET['id']);
  141. MessageManager::delete_message_by_user_sender(api_get_user_id(),$id);
  142. $delete_list_id=array();
  143. outbox_display();
  144. } else {
  145. outbox_display();
  146. }
  147. echo '</div>';
  148. echo '</div>';
  149. /* FOOTER */
  150. Display::display_footer();