outbox.php 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187
  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 type="text/javascript" src="/main/inc/lib/javascript/jquery.js"></script>';
  27. $htmlHeadXtra[] = '<script src="'.api_get_path(WEB_LIBRARY_PATH).'javascript/thickbox.js" type="text/javascript" language="javascript"></script>';
  28. $htmlHeadXtra[] = '<link rel="stylesheet" href="'.api_get_path(WEB_LIBRARY_PATH).'javascript/thickbox.css" type="text/css" media="projection, screen">';
  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. ==============================================================================
  56. MAIN CODE
  57. ==============================================================================
  58. */
  59. //$nameTools = get_lang('Messages');
  60. //api_display_tool_title(api_xml_http_response_encode(get_lang('Inbox')));
  61. if ($_GET['f']=='social') {
  62. $this_section = SECTION_SOCIAL;
  63. $interbreadcrumb[]= array ('url' => api_get_path(WEB_PATH).'main/social/home.php','name' => get_lang('Social'));
  64. $interbreadcrumb[]= array ('url' => '#','name' => get_lang('Outbox'));
  65. } else {
  66. $this_section = SECTION_MYPROFILE;
  67. $interbreadcrumb[]= array ('url' => api_get_path(WEB_PATH).'main/auth/profile.php','name' => get_lang('Profile'));
  68. $interbreadcrumb[]= array ('url' => '#','name' => get_lang('Inbox'));
  69. }
  70. Display::display_header('');
  71. if ($_GET['f']=='social') {
  72. } else {
  73. if (api_get_setting('extended_profile') == 'true') {
  74. echo '<div class="actions">';
  75. if (api_get_setting('allow_social_tool') == 'true' && api_get_setting('allow_message_tool') == 'true') {
  76. 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>';
  77. }
  78. if (api_get_setting('allow_message_tool') == 'true') {
  79. echo '<a href="'.api_get_path(WEB_PATH).'main/messages/inbox.php">'.Display::return_icon('inbox.png').' '.get_lang('Messages').'</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. /**************************************************************/
  86. $info_delete_outbox=array();
  87. $info_delete_outbox=explode(',',$_GET['form_delete_outbox']);
  88. $count_delete_outbox=(count($info_delete_outbox)-1);
  89. /**************************************************************/
  90. if( trim($info_delete_outbox[0])=='delete' ) {
  91. for ($i=1;$i<=$count_delete_outbox;$i++) {
  92. MessageManager::delete_message_by_user_sender(api_get_user_id(),$info_delete_outbox[$i]);
  93. }
  94. $message_box=get_lang('SelectedMessagesDeleted').
  95. '&nbsp
  96. <br><a href="../social/index.php?#remote-tab-3">'.
  97. get_lang('BackToOutbox').
  98. '</a>';
  99. Display::display_normal_message(api_xml_http_response_encode($message_box),false);
  100. exit;
  101. }
  102. /**************************************************************/
  103. $table_message = Database::get_main_table(TABLE_MESSAGE);
  104. $user_sender_id=api_get_user_id();
  105. echo '<div id="social-content">';
  106. $id_content_right = '';
  107. //LEFT COLUMN
  108. if (api_get_setting('allow_social_tool') != 'true') {
  109. $id_content_right = 'outbox';
  110. echo '<div id="inbox-menu" class="actions">';
  111. echo '<ul>';
  112. 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>';
  113. 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>';
  114. 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>';
  115. echo '</ul>';
  116. echo '</div>';
  117. } else {
  118. require_once api_get_path(LIBRARY_PATH).'social.lib.php';
  119. $id_content_right = 'social-content-right';
  120. echo '<div id="social-content-left">';
  121. //this include the social menu div
  122. SocialManager::show_social_menu('messages_outbox');
  123. echo '</div>';
  124. }
  125. echo '<div id="'.$id_content_right.'">';
  126. //MAIN CONTENT
  127. if ($_REQUEST['action']=='delete') {
  128. $delete_list_id=array();
  129. if (isset($_POST['out'])) {
  130. $delete_list_id=$_POST['out'];
  131. }
  132. if (isset($_POST['id'])) {
  133. $delete_list_id=$_POST['id'];
  134. }
  135. for ($i=0;$i<count($delete_list_id);$i++) {
  136. MessageManager::delete_message_by_user_sender(api_get_user_id(), $delete_list_id[$i]);
  137. }
  138. $delete_list_id=array();
  139. //------------------------
  140. outbox_display();
  141. //------------------------
  142. } elseif ($_REQUEST['action']=='deleteone') {
  143. $delete_list_id=array();
  144. $id=Security::remove_XSS($_GET['id']);
  145. MessageManager::delete_message_by_user_sender(api_get_user_id(),$id);
  146. $delete_list_id=array();
  147. outbox_display();
  148. }else {
  149. outbox_display();
  150. }
  151. echo '</div>';
  152. echo '</div>';
  153. /*
  154. ==============================================================================
  155. FOOTER
  156. ==============================================================================
  157. */
  158. Display::display_footer();
  159. ?>