outbox.php 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191
  1. <?php
  2. /* For licensing terms, see /chamilo_license.txt */
  3. /*
  4. ==============================================================================
  5. INIT SECTION
  6. ==============================================================================
  7. */
  8. // name of the language file that needs to be included
  9. $language_file = array('registration','messages','userInfo');
  10. $cidReset=true;
  11. require_once '../inc/global.inc.php';
  12. require_once api_get_path(LIBRARY_PATH).'message.lib.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. }
  22. }
  23. if (api_get_setting('allow_message_tool')!='true'){
  24. api_not_allowed();
  25. }
  26. $htmlHeadXtra[]='<script language="javascript">
  27. <!--
  28. function enviar(miforma)
  29. {
  30. if(confirm("'.get_lang('SureYouWantToDeleteSelectedMessages', '').'"))
  31. miforma.submit();
  32. }
  33. function select_all(formita)
  34. {
  35. for (i=0;i<formita.elements.length;i++)
  36. {
  37. if(formita.elements[i].type == "checkbox")
  38. formita.elements[i].checked=1
  39. }
  40. }
  41. function deselect_all(formita)
  42. {
  43. for (i=0;i<formita.elements.length;i++)
  44. {
  45. if(formita.elements[i].type == "checkbox")
  46. formita.elements[i].checked=0
  47. }
  48. }
  49. //-->
  50. </script>';
  51. /*
  52. ==============================================================================
  53. MAIN CODE
  54. ==============================================================================
  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/profile.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('Inbox'));
  66. }
  67. Display::display_header('');
  68. if ($_GET['f']=='social') {
  69. $user_online_list = WhoIsOnline(api_get_setting('time_limit_whosonline'),true);
  70. $user_online_count = count($user_online_list);
  71. echo '<div class="social-header">';
  72. echo '<table width="100%"><tr><td width="150px" bgcolor="#32578b"><center><span class="social-menu-text1">'.strtoupper(get_lang('Menu')).'</span></center></td>
  73. <td width="15px">&nbsp;</td><td bgcolor="#32578b">'.Display::return_icon('whoisonline.png','',array('hspace'=>'6')).'<a href="#" ><span class="social-menu-text1">'.get_lang('FriendsOnline').' '.$user_online_count.'</span></a></td>
  74. </tr></table>';
  75. /*
  76. echo '<div class="social-menu-title" align="center"><span class="social-menu-text1">'.get_lang('Menu').'</span></div>';
  77. echo '<div class="social-menu-title-right">'.Display::return_icon('whoisonline.png','',array('hspace'=>'6')).'<a href="#" ><span class="social-menu-text1">'.$who_is_on_line.'</span></a></div>';
  78. */
  79. echo '</div>';
  80. } else {
  81. if (api_get_setting('extended_profile') == 'true') {
  82. echo '<div class="actions">';
  83. if (api_get_setting('allow_social_tool') == 'true' && api_get_setting('allow_message_tool') == 'true') {
  84. 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>';
  85. }
  86. if (api_get_setting('allow_message_tool') == 'true') {
  87. echo '<a href="'.api_get_path(WEB_PATH).'main/messages/inbox.php">'.Display::return_icon('inbox.png').' '.get_lang('Messages').'</a>';
  88. }
  89. 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>';
  90. echo '</div>';
  91. }
  92. }
  93. /**************************************************************/
  94. $info_delete_outbox=array();
  95. $info_delete_outbox=explode(',',$_GET['form_delete_outbox']);
  96. $count_delete_outbox=(count($info_delete_outbox)-1);
  97. /**************************************************************/
  98. if( trim($info_delete_outbox[0])=='delete' ) {
  99. for ($i=1;$i<=$count_delete_outbox;$i++) {
  100. MessageManager::delete_message_by_user_sender(api_get_user_id(),$info_delete_outbox[$i]);
  101. }
  102. $message_box=get_lang('SelectedMessagesDeleted').
  103. '&nbsp
  104. <br><a href="../social/index.php?#remote-tab-3">'.
  105. get_lang('BackToOutbox').
  106. '</a>';
  107. Display::display_normal_message(api_xml_http_response_encode($message_box),false);
  108. exit;
  109. }
  110. /**************************************************************/
  111. $table_message = Database::get_main_table(TABLE_MESSAGE);
  112. $user_sender_id=api_get_user_id();
  113. echo '<div id="social-content">';
  114. $id_content_right = '';
  115. //LEFT COLUMN
  116. if (api_get_setting('allow_social_tool') != 'true') {
  117. $id_content_right = 'outbox';
  118. echo '<div id="inbox-menu" class="actions">';
  119. echo '<ul>';
  120. 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>';
  121. 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>';
  122. 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>';
  123. echo '</ul>';
  124. echo '</div>';
  125. } else {
  126. require_once api_get_path(LIBRARY_PATH).'social.lib.php';
  127. $id_content_right = 'social-content-right';
  128. echo '<div id="social-content-left">';
  129. //this include the social menu div
  130. SocialManager::show_social_menu('messages_outbox');
  131. echo '</div>';
  132. }
  133. echo '<div id="'.$id_content_right.'">';
  134. //MAIN CONTENT
  135. if ($_REQUEST['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 ($_REQUEST['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. /*
  160. ==============================================================================
  161. FOOTER
  162. ==============================================================================
  163. */
  164. Display::display_footer();
  165. ?>