outbox.php 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  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. include_once ('../inc/global.inc.php');
  30. require_once '../messages/message.class.php';
  31. require_once (api_get_path(LIBRARY_PATH).'message.lib.php');
  32. api_block_anonymous_users();
  33. if (isset($_GET['messages_page_nr'])) {
  34. if (api_get_setting('allow_social_tool')=='true' && api_get_setting('allow_message_tool')=='true') {
  35. header('Location:../social/index.php?pager="'.Security::remove_XSS($_GET['messages_page_nr']).'"&remote=3#remote-tab-3');
  36. }
  37. }
  38. if (api_get_setting('allow_message_tool')!='true'){
  39. api_not_allowed();
  40. }
  41. $htmlHeadXtra[]='<script language="javascript">
  42. <!--
  43. function enviar(miforma)
  44. {
  45. if(confirm("'.get_lang("SureYouWantToDeleteSelectedMessages").'"))
  46. miforma.submit();
  47. }
  48. function select_all(formita)
  49. {
  50. for (i=0;i<formita.elements.length;i++)
  51. {
  52. if(formita.elements[i].type == "checkbox")
  53. formita.elements[i].checked=1
  54. }
  55. }
  56. function deselect_all(formita)
  57. {
  58. for (i=0;i<formita.elements.length;i++)
  59. {
  60. if(formita.elements[i].type == "checkbox")
  61. formita.elements[i].checked=0
  62. }
  63. }
  64. //-->
  65. </script>';
  66. /*
  67. ==============================================================================
  68. MAIN CODE
  69. ==============================================================================
  70. */
  71. //$nameTools = get_lang('Messages');
  72. $request=api_is_xml_http_request();
  73. if ($request===false) {
  74. $interbreadcrumb[]= array (
  75. 'url' => '#',
  76. 'name' => get_lang('Messages')
  77. );
  78. $interbreadcrumb[]= array (
  79. 'url' => 'inbox.php',
  80. 'name' => get_lang('Inbox')
  81. );
  82. $interbreadcrumb[]= array (
  83. 'url' => 'outbox.php',
  84. 'name' => get_lang('Outbox')
  85. );
  86. Display::display_header('');
  87. }
  88. /**************************************************************/
  89. $info_delete_outbox=array();
  90. $info_delete_outbox=explode(',',$_GET['form_delete_outbox']);
  91. $count_delete_outbox=(count($info_delete_outbox)-1);
  92. /**************************************************************/
  93. if( trim($info_delete_outbox[0])=='delete' ) {
  94. for ($i=1;$i<=$count_delete_outbox;$i++) {
  95. MessageManager::delete_message_by_user_sender(api_get_user_id(),$info_delete_outbox[$i]);
  96. }
  97. $message_box=get_lang('SelectedMessagesDeleted').
  98. '&nbsp
  99. <br><a href="../social/index.php?#remote-tab-3">'.
  100. get_lang('BackToOutbox').
  101. '</a>';
  102. Display::display_normal_message($message_box,false);
  103. exit;
  104. }
  105. /**************************************************************/
  106. $table_message = Database::get_main_table(TABLE_MESSAGE);
  107. echo '<div id="div_content_messages_sent">&nbsp;&nbsp;';
  108. //api_display_tool_title(mb_convert_encoding(get_lang('Outbox'),'UTF-8',$charset));
  109. echo '</div>';
  110. $user_sender_id=api_get_user_id();
  111. if ($_REQUEST['action']=='delete') {
  112. $delete_list_id=array();
  113. if (isset($_POST['out'])) {
  114. $delete_list_id=$_POST['out'];
  115. }
  116. if (isset($_POST['id'])) {
  117. $delete_list_id=$_POST['id'];
  118. }
  119. for ($i=0;$i<count($delete_list_id);$i++) {
  120. MessageManager::delete_message_by_user_sender(api_get_user_id(), $delete_list_id[$i]);
  121. }
  122. $delete_list_id=array();
  123. outbox_display();
  124. } elseif ($_REQUEST['action']=='deleteone') {
  125. $delete_list_id=array();
  126. $id=Security::remove_XSS($_GET['id']);
  127. MessageManager::delete_message_by_user_sender(api_get_user_id(),$id);
  128. $delete_list_id=array();
  129. outbox_display();
  130. }else {
  131. outbox_display();
  132. }
  133. /*
  134. ==============================================================================
  135. FOOTER
  136. ==============================================================================
  137. */
  138. if ($request===false) {
  139. Display::display_footer();
  140. }
  141. ?>