outbox.php 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  1. <?php
  2. /* For licensing terms, see /license.txt */
  3. /**
  4. * @package chamilo.messages
  5. */
  6. $cidReset = true;
  7. require_once '../inc/global.inc.php';
  8. api_block_anonymous_users();
  9. if (isset($_GET['messages_page_nr'])) {
  10. if (api_get_setting('allow_social_tool')=='true' &&
  11. api_get_setting('allow_message_tool')=='true'
  12. ) {
  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. function enviar(miforma) {
  27. if(confirm("'.get_lang('SureYouWantToDeleteSelectedMessages', '').'"))
  28. miforma.submit();
  29. }
  30. function select_all(formita)
  31. {
  32. for (i=0;i<formita.elements.length;i++)
  33. {
  34. if(formita.elements[i].type == "checkbox")
  35. formita.elements[i].checked=1
  36. }
  37. }
  38. function deselect_all(formita)
  39. {
  40. for (i=0;i<formita.elements.length;i++)
  41. {
  42. if(formita.elements[i].type == "checkbox")
  43. formita.elements[i].checked=0
  44. }
  45. }
  46. //-->
  47. </script>';
  48. /*
  49. MAIN CODE
  50. */
  51. if (isset($_GET['f']) && $_GET['f']=='social') {
  52. $this_section = SECTION_SOCIAL;
  53. $interbreadcrumb[]= array ('url' => api_get_path(WEB_PATH).'main/social/home.php','name' => get_lang('Social'));
  54. $interbreadcrumb[]= array ('url' => '#','name' => get_lang('Outbox'));
  55. } else {
  56. $this_section = SECTION_MYPROFILE;
  57. $interbreadcrumb[]= array ('url' => api_get_path(WEB_PATH).'main/auth/profile.php','name' => get_lang('Profile'));
  58. $interbreadcrumb[]= array ('url' => '#','name' => get_lang('Outbox'));
  59. }
  60. $actions = '';
  61. if (api_get_setting('extended_profile') == 'true') {
  62. if (api_get_setting('allow_social_tool') == 'true' && api_get_setting('allow_message_tool') == 'true') {
  63. $actions .= '<a href="'.api_get_path(WEB_PATH).'main/social/profile.php">'.Display::return_icon('shared_profile.png', get_lang('ViewSharedProfile')).'</a>';
  64. }
  65. if (api_get_setting('allow_message_tool') == 'true') {
  66. //echo '<a href="'.api_get_path(WEB_PATH).'main/messages/inbox.php">'.Display::return_icon('inbox.png').' '.get_lang('Messages').'</a>';
  67. $actions .= '<a href="'.api_get_path(WEB_PATH).'main/messages/new_message.php">'.Display::return_icon('message_new.png',get_lang('ComposeMessage')).'</a>';
  68. $actions .= '<a href="'.api_get_path(WEB_PATH).'main/messages/inbox.php">'.Display::return_icon('inbox.png',get_lang('Inbox')).'</a>';
  69. $actions .= '<a href="'.api_get_path(WEB_PATH).'main/messages/outbox.php">'.Display::return_icon('outbox.png',get_lang('Outbox')).'</a>';
  70. }
  71. }
  72. $info_delete_outbox =array();
  73. $info_delete_outbox = isset($_GET['form_delete_outbox']) ? explode(',',$_GET['form_delete_outbox']) : '';
  74. $count_delete_outbox = count($info_delete_outbox) - 1;
  75. if (isset($info_delete_outbox[0]) && 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. '&nbsp
  81. <br><a href="../social/index.php?#remote-tab-3">'.
  82. get_lang('BackToOutbox').
  83. '</a>';
  84. Display::display_normal_message(api_xml_http_response_encode($message_box),false);
  85. exit;
  86. }
  87. $action = null;
  88. if (isset($_REQUEST['action'])) {
  89. $action = $_REQUEST['action'];
  90. }
  91. $keyword = '';
  92. $social_right_content = '';
  93. if (api_get_setting('allow_social_tool') == 'true') {
  94. //Block Social Menu
  95. $social_menu_block = SocialManager::show_social_menu('messages');
  96. $actionsLeft = '<a href="'.api_get_path(WEB_PATH).'main/messages/inbox.php?f=social">'.
  97. Display::return_icon('back.png', get_lang('Back'), array(), 32).'</a>';
  98. $form = MessageManager::getSearchForm(api_get_path(WEB_PATH).'main/messages/outbox.php');
  99. if ($form->validate()) {
  100. $values = $form->getSubmitValues();
  101. $keyword = $values['keyword'];
  102. }
  103. $actionsRight = $form->returnForm();
  104. $social_right_content .= Display::toolbarAction('toolbar', [$actionsLeft, $actionsRight]);
  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($keyword);
  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($keyword);
  126. } else {
  127. $social_right_content .= MessageManager::outbox_display($keyword);
  128. }
  129. $tpl = new Template(get_lang('ComposeMessage'));
  130. // Block Social Avatar
  131. SocialManager::setSocialUserBlock($tpl, $user_id, 'messages');
  132. if (api_get_setting('allow_social_tool') == 'true') {
  133. $tpl->assign('social_menu_block', $social_menu_block);
  134. $tpl->assign('social_right_content', $social_right_content);
  135. $social_layout = $tpl->get_template('social/inbox.tpl');
  136. $tpl->display($social_layout);
  137. } else {
  138. $content = $social_right_content;
  139. $tpl->assign('actions', $actions);
  140. $tpl->assign('content', $content);
  141. $tpl->display_one_col_template();
  142. }