outbox.php 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  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. api_block_anonymous_users();
  11. if (isset($_GET['messages_page_nr'])) {
  12. if (api_get_setting('allow_social_tool')=='true' && api_get_setting('allow_message_tool')=='true') {
  13. $social_link = '';
  14. if ($_REQUEST['f']=='social') {
  15. $social_link = '&f=social';
  16. }
  17. header('Location:outbox.php?pager='.Security::remove_XSS($_GET['messages_page_nr']).$social_link.'');
  18. exit;
  19. }
  20. }
  21. if (api_get_setting('allow_message_tool')!='true'){
  22. api_not_allowed();
  23. }
  24. //jquery thickbox already called from main/inc/header.inc.php
  25. $htmlHeadXtra[]='<script language="javascript">
  26. <!--
  27. function enviar(miforma)
  28. {
  29. if(confirm("'.get_lang('SureYouWantToDeleteSelectedMessages', '').'"))
  30. miforma.submit();
  31. }
  32. function select_all(formita)
  33. {
  34. for (i=0;i<formita.elements.length;i++)
  35. {
  36. if(formita.elements[i].type == "checkbox")
  37. formita.elements[i].checked=1
  38. }
  39. }
  40. function deselect_all(formita)
  41. {
  42. for (i=0;i<formita.elements.length;i++)
  43. {
  44. if(formita.elements[i].type == "checkbox")
  45. formita.elements[i].checked=0
  46. }
  47. }
  48. //-->
  49. </script>';
  50. /*
  51. MAIN CODE
  52. */
  53. if ($_GET['f']=='social') {
  54. $this_section = SECTION_SOCIAL;
  55. $interbreadcrumb[]= array ('url' => api_get_path(WEB_PATH).'main/social/home.php','name' => get_lang('Social'));
  56. $interbreadcrumb[]= array ('url' => '#','name' => get_lang('Outbox'));
  57. } else {
  58. $this_section = SECTION_MYPROFILE;
  59. $interbreadcrumb[]= array ('url' => api_get_path(WEB_PATH).'main/auth/profile.php','name' => get_lang('Profile'));
  60. $interbreadcrumb[]= array ('url' => '#','name' => get_lang('Outbox'));
  61. }
  62. if ($_GET['f']=='social') {
  63. } else {
  64. if (api_get_setting('extended_profile') == 'true') {
  65. if (api_get_setting('allow_social_tool') == 'true' && api_get_setting('allow_message_tool') == 'true') {
  66. $actions .= '<a href="'.api_get_path(WEB_PATH).'main/social/profile.php">'.Display::return_icon('shared_profile.png', get_lang('ViewSharedProfile')).'</a>';
  67. }
  68. if (api_get_setting('allow_message_tool') == 'true') {
  69. //echo '<a href="'.api_get_path(WEB_PATH).'main/messages/inbox.php">'.Display::return_icon('inbox.png').' '.get_lang('Messages').'</a>';
  70. $actions .= '<a href="'.api_get_path(WEB_PATH).'main/messages/new_message.php">'.Display::return_icon('message_new.png',get_lang('ComposeMessage')).'</a>';
  71. $actions .= '<a href="'.api_get_path(WEB_PATH).'main/messages/inbox.php">'.Display::return_icon('inbox.png',get_lang('Inbox')).'</a>';
  72. $actions .= '<a href="'.api_get_path(WEB_PATH).'main/messages/outbox.php">'.Display::return_icon('outbox.png',get_lang('Outbox')).'</a>';
  73. }
  74. }
  75. }
  76. $info_delete_outbox=array();
  77. $info_delete_outbox=explode(',',$_GET['form_delete_outbox']);
  78. $count_delete_outbox=(count($info_delete_outbox)-1);
  79. if( trim($info_delete_outbox[0])=='delete' ) {
  80. for ($i=1;$i<=$count_delete_outbox;$i++) {
  81. MessageManager::delete_message_by_user_sender(api_get_user_id(),$info_delete_outbox[$i]);
  82. }
  83. $message_box=get_lang('SelectedMessagesDeleted').
  84. '&nbsp
  85. <br><a href="../social/index.php?#remote-tab-3">'.
  86. get_lang('BackToOutbox').
  87. '</a>';
  88. Display::display_normal_message(api_xml_http_response_encode($message_box),false);
  89. exit;
  90. }
  91. $action = null;
  92. if (isset($_REQUEST['action'])) {
  93. $action = $_REQUEST['action'];
  94. }
  95. $social_right_content = '';
  96. if (api_get_setting('allow_social_tool') == 'true') {
  97. $social_avatar_block = SocialManager::show_social_avatar_block('messages');
  98. $social_menu_block = SocialManager::show_social_menu('messages');
  99. $social_right_content .= '<div class="span9">';
  100. $social_right_content .= '<div class="actions">';
  101. $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>';
  102. $social_right_content .= '</div>';
  103. $social_right_content .= '</div>';
  104. $social_right_content .= '<div class="span9">';
  105. }
  106. //MAIN CONTENT
  107. if ($action == 'delete') {
  108. $delete_list_id=array();
  109. if (isset($_POST['out'])) {
  110. $delete_list_id=$_POST['out'];
  111. }
  112. if (isset($_POST['id'])) {
  113. $delete_list_id=$_POST['id'];
  114. }
  115. for ($i=0;$i<count($delete_list_id);$i++) {
  116. MessageManager::delete_message_by_user_sender(api_get_user_id(), $delete_list_id[$i]);
  117. }
  118. $delete_list_id=array();
  119. $social_right_content .= MessageManager::outbox_display();
  120. } elseif($action =='deleteone') {
  121. $delete_list_id=array();
  122. $id = Security::remove_XSS($_GET['id']);
  123. MessageManager::delete_message_by_user_sender(api_get_user_id(),$id);
  124. $delete_list_id=array();
  125. $social_right_content .= MessageManager::outbox_display();
  126. } else {
  127. $social_right_content .= MessageManager::outbox_display();
  128. }
  129. if (api_get_setting('allow_social_tool') == 'true') {
  130. $social_right_content .= '</div>';
  131. }
  132. $tpl = new Template(get_lang('ComposeMessage'));
  133. if (api_get_setting('allow_social_tool') == 'true') {
  134. $tpl->assign('social_avatar_block', $social_avatar_block);
  135. $tpl->assign('social_menu_block', $social_menu_block);
  136. $tpl->assign('social_right_content', $social_right_content);
  137. $social_layout = $tpl->get_template('layout/social_layout.tpl');
  138. $tpl->display($social_layout);
  139. } else {
  140. $content = $social_right_content;
  141. $tpl->assign('actions', $actions);
  142. $tpl->assign('message', $show_message);
  143. $tpl->assign('content', $content);
  144. $tpl->display_one_col_template();
  145. }