outbox.php 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. <?php
  2. /* For licensing terms, see /license.txt */
  3. /**
  4. * @package chamilo.messages
  5. */
  6. /**
  7. * Code
  8. */
  9. // name of the language file that needs to be included
  10. $language_file = array('registration','messages','userInfo');
  11. $cidReset=true;
  12. //require_once '../inc/global.inc.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. exit;
  22. }
  23. }
  24. if (api_get_setting('allow_message_tool')!='true'){
  25. api_not_allowed();
  26. }
  27. //jquery thickbox already called from main/inc/header.inc.php
  28. $htmlHeadXtra[]='<script language="javascript">
  29. <!--
  30. function enviar(miforma)
  31. {
  32. if(confirm("'.get_lang('SureYouWantToDeleteSelectedMessages', '').'"))
  33. miforma.submit();
  34. }
  35. function select_all(formita)
  36. {
  37. for (i=0;i<formita.elements.length;i++)
  38. {
  39. if(formita.elements[i].type == "checkbox")
  40. formita.elements[i].checked=1
  41. }
  42. }
  43. function deselect_all(formita)
  44. {
  45. for (i=0;i<formita.elements.length;i++)
  46. {
  47. if(formita.elements[i].type == "checkbox")
  48. formita.elements[i].checked=0
  49. }
  50. }
  51. //-->
  52. </script>';
  53. /*
  54. MAIN CODE
  55. */
  56. //$nameTools = get_lang('Messages');
  57. $interbreadcrumb[]= array ('url' => api_get_path(WEB_PATH).'main/messages/inbox.php','name' => get_lang('Messages'));
  58. if ($_GET['f']=='social') {
  59. } else {
  60. if (api_get_setting('extended_profile') == 'true') {
  61. if (api_get_setting('allow_social_tool') == 'true' && api_get_setting('allow_message_tool') == 'true') {
  62. $actions .= '<a href="'.api_get_path(WEB_PATH).'main/social/profile.php">'.Display::return_icon('shared_profile.png', get_lang('ViewSharedProfile')).'</a>';
  63. }
  64. if (api_get_setting('allow_message_tool') == 'true') {
  65. //echo '<a href="'.api_get_path(WEB_PATH).'main/messages/inbox.php">'.Display::return_icon('inbox.png').' '.get_lang('Messages').'</a>';
  66. $actions .= '<a href="'.api_get_path(WEB_PATH).'main/messages/new_message.php">'.Display::return_icon('message_new.png',get_lang('ComposeMessage')).'</a>';
  67. $actions .= '<a href="'.api_get_path(WEB_PATH).'main/messages/inbox.php">'.Display::return_icon('inbox.png',get_lang('Inbox')).'</a>';
  68. $actions .= '<a href="'.api_get_path(WEB_PATH).'main/messages/outbox.php">'.Display::return_icon('outbox.png',get_lang('Outbox')).'</a>';
  69. }
  70. }
  71. }
  72. $info_delete_outbox=array();
  73. $info_delete_outbox=explode(',',$_GET['form_delete_outbox']);
  74. $count_delete_outbox=(count($info_delete_outbox)-1);
  75. if( trim($info_delete_outbox[0])=='delete' ) {
  76. for ($i=1;$i<=$count_delete_outbox;$i++) {
  77. MessageManager::delete_message_by_user_sender(api_get_user_id(),$info_delete_outbox[$i]);
  78. }
  79. $message_box=get_lang('SelectedMessagesDeleted');
  80. Display::display_normal_message(api_xml_http_response_encode($message_box),false);
  81. exit;
  82. }
  83. $action = null;
  84. if (isset($_REQUEST['action'])) {
  85. $action = $_REQUEST['action'];
  86. }
  87. if (api_get_setting('allow_social_tool') == 'true') {
  88. $social_left_content = SocialManager::show_social_menu('messages');
  89. $social_right_content .= '<div class="span9">';
  90. }
  91. //MAIN CONTENT
  92. if ($action == 'delete') {
  93. $delete_list_id=array();
  94. if (isset($_POST['out'])) {
  95. $delete_list_id=$_POST['out'];
  96. }
  97. if (isset($_POST['id'])) {
  98. $delete_list_id=$_POST['id'];
  99. }
  100. for ($i=0;$i<count($delete_list_id);$i++) {
  101. MessageManager::delete_message_by_user_sender(api_get_user_id(), $delete_list_id[$i]);
  102. }
  103. $delete_list_id=array();
  104. $social_right_content .= MessageManager::outbox_display();
  105. } elseif($action =='deleteone') {
  106. $delete_list_id=array();
  107. $id = Security::remove_XSS($_GET['id']);
  108. MessageManager::delete_message_by_user_sender(api_get_user_id(),$id);
  109. $delete_list_id=array();
  110. $social_right_content .= MessageManager::outbox_display();
  111. } else {
  112. $social_right_content .= MessageManager::outbox_display();
  113. }
  114. if (api_get_setting('allow_social_tool') == 'true') {
  115. $social_right_content .= '</div>';
  116. }
  117. $tpl = $app['template'];
  118. $tpl->setTitle(get_lang('Outbox'));
  119. $content = $social_right_content;
  120. $tpl->assign('actions', $actions);
  121. $tpl->assign('message', $show_message);
  122. $tpl->assign('content', $content);
  123. $tpl->display_one_col_template();