outbox.php 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  1. <?php
  2. /*
  3. ==============================================================================
  4. Dokeos - elearning and course management software
  5. Copyright (c) 2009 Dokeos SPRL
  6. Copyright (c) 2009 Julio Montoya Armas <gugli100@gmail.com>
  7. Copyright (c) 2009 Isaac Flores Paz <florespaz@bidsoftperu.com>
  8. Copyright (c) Facultad de Matematicas, UADY (México)
  9. Copyright (c) Evie, Free University of Brussels (Belgium)
  10. For a full list of contributors, see "credits.txt".
  11. The full license can be read in "license.txt".
  12. This program is free software; you can redistribute it and/or
  13. modify it under the terms of the GNU General Public License
  14. as published by the Free Software Foundation; either version 2
  15. of the License, or (at your option) any later version.
  16. See the GNU General Public License for more details.
  17. Contact address: Dokeos, rue du Corbeau, 108, B-1030 Brussels, Belgium
  18. Mail: info@dokeos.com
  19. ==============================================================================
  20. */
  21. /*
  22. ==============================================================================
  23. INIT SECTION
  24. ==============================================================================
  25. */
  26. // name of the language file that needs to be included
  27. $language_file = array('registration','messages','userInfo','admin');
  28. $cidReset=true;
  29. require_once '../inc/global.inc.php';
  30. require_once api_get_path(LIBRARY_PATH).'message.lib.php';
  31. api_block_anonymous_users();
  32. if (isset($_GET['messages_page_nr'])) {
  33. if (api_get_setting('allow_social_tool')=='true' && api_get_setting('allow_message_tool')=='true') {
  34. header('Location:../social/index.php?pager="'.Security::remove_XSS($_GET['messages_page_nr']).'"&remote=3#remote-tab-3');
  35. }
  36. }
  37. if (api_get_setting('allow_message_tool')!='true'){
  38. api_not_allowed();
  39. }
  40. $htmlHeadXtra[]='<script language="javascript">
  41. <!--
  42. function enviar(miforma)
  43. {
  44. if(confirm("'.get_lang('SureYouWantToDeleteSelectedMessages', '').'"))
  45. miforma.submit();
  46. }
  47. function select_all(formita)
  48. {
  49. for (i=0;i<formita.elements.length;i++)
  50. {
  51. if(formita.elements[i].type == "checkbox")
  52. formita.elements[i].checked=1
  53. }
  54. }
  55. function deselect_all(formita)
  56. {
  57. for (i=0;i<formita.elements.length;i++)
  58. {
  59. if(formita.elements[i].type == "checkbox")
  60. formita.elements[i].checked=0
  61. }
  62. }
  63. //-->
  64. </script>';
  65. /*
  66. ==============================================================================
  67. MAIN CODE
  68. ==============================================================================
  69. */
  70. //$nameTools = get_lang('Messages');
  71. $request=api_is_xml_http_request();
  72. if ($request===false) {
  73. $interbreadcrumb[]= array (
  74. 'url' => '#',
  75. 'name' => get_lang('Messages')
  76. );
  77. $interbreadcrumb[]= array (
  78. 'url' => 'inbox.php',
  79. 'name' => get_lang('Inbox')
  80. );
  81. $interbreadcrumb[]= array (
  82. 'url' => 'outbox.php',
  83. 'name' => get_lang('Outbox')
  84. );
  85. Display::display_header('');
  86. }
  87. echo '<div class=actions>';
  88. echo '<a href="'.api_get_path(WEB_PATH).'main/messages/inbox.php">'.Display::return_icon('inbox.png',api_xml_http_response_encode(get_lang('Inbox'))).api_xml_http_response_encode(get_lang('Inbox')).'</a>';
  89. echo '<a href="'.api_get_path(WEB_PATH).'main/messages/new_message.php">'.Display::return_icon('message_new.png',api_xml_http_response_encode(get_lang('ComposeMessage'))).api_xml_http_response_encode(get_lang('ComposeMessage')).'</a>';
  90. echo '<a href="'.api_get_path(WEB_PATH).'main/messages/outbox.php">'.Display::return_icon('outbox.png',api_xml_http_response_encode(get_lang('Outbox'))).api_xml_http_response_encode(get_lang('Outbox')).'</a>';
  91. echo '</div>';
  92. /**************************************************************/
  93. $info_delete_outbox=array();
  94. $info_delete_outbox=explode(',',$_GET['form_delete_outbox']);
  95. $count_delete_outbox=(count($info_delete_outbox)-1);
  96. /**************************************************************/
  97. if( trim($info_delete_outbox[0])=='delete' ) {
  98. for ($i=1;$i<=$count_delete_outbox;$i++) {
  99. MessageManager::delete_message_by_user_sender(api_get_user_id(),$info_delete_outbox[$i]);
  100. }
  101. $message_box=get_lang('SelectedMessagesDeleted').
  102. '&nbsp
  103. <br><a href="../social/index.php?#remote-tab-3">'.
  104. get_lang('BackToOutbox').
  105. '</a>';
  106. Display::display_normal_message(api_xml_http_response_encode($message_box),false);
  107. exit;
  108. }
  109. /**************************************************************/
  110. $table_message = Database::get_main_table(TABLE_MESSAGE);
  111. $user_sender_id=api_get_user_id();
  112. if ($_REQUEST['action']=='delete') {
  113. $delete_list_id=array();
  114. if (isset($_POST['out'])) {
  115. $delete_list_id=$_POST['out'];
  116. }
  117. if (isset($_POST['id'])) {
  118. $delete_list_id=$_POST['id'];
  119. }
  120. for ($i=0;$i<count($delete_list_id);$i++) {
  121. MessageManager::delete_message_by_user_sender(api_get_user_id(), $delete_list_id[$i]);
  122. }
  123. $delete_list_id=array();
  124. outbox_display();
  125. } elseif ($_REQUEST['action']=='deleteone') {
  126. $delete_list_id=array();
  127. $id=Security::remove_XSS($_GET['id']);
  128. MessageManager::delete_message_by_user_sender(api_get_user_id(),$id);
  129. $delete_list_id=array();
  130. outbox_display();
  131. }else {
  132. outbox_display();
  133. }
  134. /*
  135. ==============================================================================
  136. FOOTER
  137. ==============================================================================
  138. */
  139. if ($request===false) {
  140. Display::display_footer();
  141. }
  142. ?>