outbox.php 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182
  1. <?php
  2. /* For licensing terms, see /license.txt */
  3. /**
  4. * @package chamilo.messages
  5. */
  6. // name of the language file that needs to be included
  7. $language_file = array('registration','messages','userInfo');
  8. $cidReset=true;
  9. require_once '../inc/global.inc.php';
  10. require_once api_get_path(LIBRARY_PATH).'message.lib.php';
  11. api_block_anonymous_users();
  12. if (isset($_GET['messages_page_nr'])) {
  13. if (api_get_setting('allow_social_tool')=='true' && api_get_setting('allow_message_tool')=='true') {
  14. $social_link = '';
  15. if ($_REQUEST['f']=='social') {
  16. $social_link = '&f=social';
  17. }
  18. header('Location:outbox.php?pager='.Security::remove_XSS($_GET['messages_page_nr']).$social_link.'');
  19. exit;
  20. }
  21. }
  22. if (api_get_setting('allow_message_tool')!='true'){
  23. api_not_allowed();
  24. }
  25. //jquery thickbox already called from main/inc/header.inc.php
  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. MAIN CODE
  53. */
  54. //$nameTools = get_lang('Messages');
  55. //api_display_tool_title(api_xml_http_response_encode(get_lang('Inbox')));
  56. if ($_GET['f']=='social') {
  57. $this_section = SECTION_SOCIAL;
  58. $interbreadcrumb[]= array ('url' => api_get_path(WEB_PATH).'main/social/home.php','name' => get_lang('Social'));
  59. $interbreadcrumb[]= array ('url' => '#','name' => get_lang('Outbox'));
  60. } else {
  61. $this_section = SECTION_MYPROFILE;
  62. $interbreadcrumb[]= array ('url' => api_get_path(WEB_PATH).'main/auth/profile.php','name' => get_lang('Profile'));
  63. $interbreadcrumb[]= array ('url' => '#','name' => get_lang('Outbox'));
  64. }
  65. Display::display_header('');
  66. if ($_GET['f']=='social') {
  67. } else {
  68. if (api_get_setting('extended_profile') == 'true') {
  69. echo '<div class="actions">';
  70. if (api_get_setting('allow_social_tool') == 'true' && api_get_setting('allow_message_tool') == 'true') {
  71. 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>';
  72. }
  73. if (api_get_setting('allow_message_tool') == 'true') {
  74. //echo '<a href="'.api_get_path(WEB_PATH).'main/messages/inbox.php">'.Display::return_icon('inbox.png').' '.get_lang('Messages').'</a>';
  75. 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>';
  76. echo '<a href="'.api_get_path(WEB_PATH).'main/messages/inbox.php">'.Display::return_icon('inbox.png',get_lang('Inbox')).get_lang('Inbox').'</a>';
  77. echo '<a href="'.api_get_path(WEB_PATH).'main/messages/outbox.php">'.Display::return_icon('outbox.png',get_lang('Outbox')).get_lang('Outbox').'</a>';
  78. }
  79. //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>';
  80. echo '</div>';
  81. }
  82. }
  83. $info_delete_outbox=array();
  84. $info_delete_outbox=explode(',',$_GET['form_delete_outbox']);
  85. $count_delete_outbox=(count($info_delete_outbox)-1);
  86. if( trim($info_delete_outbox[0])=='delete' ) {
  87. for ($i=1;$i<=$count_delete_outbox;$i++) {
  88. MessageManager::delete_message_by_user_sender(api_get_user_id(),$info_delete_outbox[$i]);
  89. }
  90. $message_box=get_lang('SelectedMessagesDeleted').
  91. '&nbsp
  92. <br><a href="../social/index.php?#remote-tab-3">'.
  93. get_lang('BackToOutbox').
  94. '</a>';
  95. Display::display_normal_message(api_xml_http_response_encode($message_box),false);
  96. exit;
  97. }
  98. $table_message = Database::get_main_table(TABLE_MESSAGE);
  99. $user_sender_id = api_get_user_id();
  100. $action = null;
  101. if (isset($_REQUEST['action'])) {
  102. $action = $_REQUEST['action'];
  103. }
  104. echo '<div id="social-content">';
  105. $id_content_right = '';
  106. //LEFT COLUMN
  107. if (api_get_setting('allow_social_tool') != 'true') {
  108. $id_content_right = 'outbox';
  109. /*
  110. echo '<div id="inbox-menu" class="actions">';
  111. echo '<ul>';
  112. 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>';
  113. 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>';
  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');
  123. echo '</div>';
  124. }
  125. echo '<div id="'.$id_content_right.'">';
  126. if (api_get_setting('allow_social_tool') == 'true') {
  127. echo '<div class="actions">';
  128. 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>';
  129. echo '</div>';
  130. }
  131. //MAIN CONTENT
  132. if ($action == 'delete') {
  133. $delete_list_id=array();
  134. if (isset($_POST['out'])) {
  135. $delete_list_id=$_POST['out'];
  136. }
  137. if (isset($_POST['id'])) {
  138. $delete_list_id=$_POST['id'];
  139. }
  140. for ($i=0;$i<count($delete_list_id);$i++) {
  141. MessageManager::delete_message_by_user_sender(api_get_user_id(), $delete_list_id[$i]);
  142. }
  143. $delete_list_id=array();
  144. outbox_display();
  145. } elseif($action =='deleteone') {
  146. $delete_list_id=array();
  147. $id=Security::remove_XSS($_GET['id']);
  148. MessageManager::delete_message_by_user_sender(api_get_user_id(),$id);
  149. $delete_list_id=array();
  150. outbox_display();
  151. } else {
  152. outbox_display();
  153. }
  154. echo '</div>';
  155. echo '</div>';
  156. /* FOOTER */
  157. Display::display_footer();