outbox.php 6.2 KB

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