outbox.php 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  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. //api_display_tool_title(api_xml_http_response_encode(get_lang('Inbox')));
  58. if ($_GET['f']=='social') {
  59. $this_section = SECTION_SOCIAL;
  60. $interbreadcrumb[]= array ('url' => api_get_path(WEB_PATH).'main/social/home.php','name' => get_lang('Social'));
  61. $interbreadcrumb[]= array ('url' => '#','name' => get_lang('Outbox'));
  62. } else {
  63. $this_section = SECTION_MYPROFILE;
  64. $interbreadcrumb[]= array ('url' => api_get_path(WEB_PATH).'main/auth/profile.php','name' => get_lang('Profile'));
  65. $interbreadcrumb[]= array ('url' => '#','name' => get_lang('Outbox'));
  66. }
  67. if ($_GET['f']=='social') {
  68. } else {
  69. if (api_get_setting('extended_profile') == 'true') {
  70. if (api_get_setting('allow_social_tool') == 'true' && api_get_setting('allow_message_tool') == 'true') {
  71. $actions .= '<a href="'.api_get_path(WEB_PATH).'main/social/profile.php">'.Display::return_icon('shared_profile.png', 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. $actions .= '<a href="'.api_get_path(WEB_PATH).'main/messages/new_message.php">'.Display::return_icon('message_new.png',get_lang('ComposeMessage')).'</a>';
  76. $actions .= '<a href="'.api_get_path(WEB_PATH).'main/messages/inbox.php">'.Display::return_icon('inbox.png',get_lang('Inbox')).'</a>';
  77. $actions .= '<a href="'.api_get_path(WEB_PATH).'main/messages/outbox.php">'.Display::return_icon('outbox.png',get_lang('Outbox')).'</a>';
  78. }
  79. }
  80. }
  81. $info_delete_outbox=array();
  82. $info_delete_outbox=explode(',',$_GET['form_delete_outbox']);
  83. $count_delete_outbox=(count($info_delete_outbox)-1);
  84. if( trim($info_delete_outbox[0])=='delete' ) {
  85. for ($i=1;$i<=$count_delete_outbox;$i++) {
  86. MessageManager::delete_message_by_user_sender(api_get_user_id(),$info_delete_outbox[$i]);
  87. }
  88. $message_box=get_lang('SelectedMessagesDeleted').
  89. '&nbsp
  90. <br><a href="../social/index.php?#remote-tab-3">'.
  91. get_lang('BackToOutbox').
  92. '</a>';
  93. Display::display_normal_message(api_xml_http_response_encode($message_box),false);
  94. exit;
  95. }
  96. $action = null;
  97. if (isset($_REQUEST['action'])) {
  98. $action = $_REQUEST['action'];
  99. }
  100. if (api_get_setting('allow_social_tool') == 'true') {
  101. $social_left_content = SocialManager::show_social_menu('messages');
  102. $social_right_content .= '<div class="span9">';
  103. $social_right_content .= '<div class="actions">';
  104. $social_right_content .= '<a href="'.api_get_path(WEB_PATH).'main/messages/inbox.php?f=social">'.Display::return_icon('back.png', get_lang('Back'), array(), 32).'</a>';
  105. $social_right_content .= '</div>';
  106. $social_right_content .= '</div>';
  107. $social_right_content .= '<div class="span9">';
  108. }
  109. //MAIN CONTENT
  110. if ($action == 'delete') {
  111. $delete_list_id=array();
  112. if (isset($_POST['out'])) {
  113. $delete_list_id=$_POST['out'];
  114. }
  115. if (isset($_POST['id'])) {
  116. $delete_list_id=$_POST['id'];
  117. }
  118. for ($i=0;$i<count($delete_list_id);$i++) {
  119. MessageManager::delete_message_by_user_sender(api_get_user_id(), $delete_list_id[$i]);
  120. }
  121. $delete_list_id=array();
  122. $social_right_content .= MessageManager::outbox_display();
  123. } elseif($action =='deleteone') {
  124. $delete_list_id=array();
  125. $id = Security::remove_XSS($_GET['id']);
  126. MessageManager::delete_message_by_user_sender(api_get_user_id(),$id);
  127. $delete_list_id=array();
  128. $social_right_content .= MessageManager::outbox_display();
  129. } else {
  130. $social_right_content .= MessageManager::outbox_display();
  131. }
  132. if (api_get_setting('allow_social_tool') == 'true') {
  133. $social_right_content .= '</div>';
  134. }
  135. $app['title'] = get_lang('ComposeMessage');
  136. $tpl = $app['template'];
  137. if (api_get_setting('allow_social_tool') == 'true') {
  138. $tpl->assign('social_left_content', $social_left_content);
  139. $tpl->assign('social_left_menu', $social_left_menu);
  140. $tpl->assign('social_right_content', $social_right_content);
  141. $social_layout = $tpl->get_template('layout/social_layout.tpl');
  142. $tpl->display($social_layout);
  143. } else {
  144. $content = $social_right_content;
  145. $tpl->assign('actions', $actions);
  146. $tpl->assign('message', $show_message);
  147. $tpl->assign('content', $content);
  148. $tpl->display_one_col_template();
  149. }