outbox.php 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  1. <?php
  2. /* For licensing terms, see /license.txt */
  3. use Chamilo\CoreBundle\Framework\Container;
  4. /**
  5. * @package chamilo.messages
  6. */
  7. $cidReset = true;
  8. //require_once '../inc/global.inc.php';
  9. api_block_anonymous_users();
  10. if (isset($_GET['messages_page_nr'])) {
  11. if (api_get_setting('social.allow_social_tool') == 'true' &&
  12. api_get_setting('message.allow_message_tool') == 'true'
  13. ) {
  14. $social_link = '';
  15. if ($_REQUEST['f']=='social') {
  16. $social_link = '&f=social';
  17. }
  18. header('Location:outbox.php?pager='.Security::remove_XSS($_GET['messages_page_nr']).$social_link.'');
  19. exit;
  20. }
  21. }
  22. if (api_get_setting('message.allow_message_tool') != 'true') {
  23. api_not_allowed();
  24. }
  25. //jquery thickbox already called from main/inc/header.inc.php
  26. $htmlHeadXtra[]='<script language="javascript">
  27. function enviar(miforma) {
  28. if(confirm("'.get_lang('SureYouWantToDeleteSelectedMessages', '').'"))
  29. miforma.submit();
  30. }
  31. function select_all(formita)
  32. {
  33. for (i=0;i<formita.elements.length;i++)
  34. {
  35. if(formita.elements[i].type == "checkbox")
  36. formita.elements[i].checked=1
  37. }
  38. }
  39. function deselect_all(formita)
  40. {
  41. for (i=0;i<formita.elements.length;i++)
  42. {
  43. if(formita.elements[i].type == "checkbox")
  44. formita.elements[i].checked=0
  45. }
  46. }
  47. //-->
  48. </script>';
  49. /*
  50. MAIN CODE
  51. */
  52. if (isset($_GET['f']) && $_GET['f']=='social') {
  53. $this_section = SECTION_SOCIAL;
  54. $interbreadcrumb[]= array ('url' => api_get_path(WEB_PATH).'main/social/home.php','name' => get_lang('Social'));
  55. $interbreadcrumb[]= array ('url' => '#','name' => get_lang('Outbox'));
  56. } else {
  57. $this_section = SECTION_MYPROFILE;
  58. $interbreadcrumb[]= array ('url' => Container::getRouter()->generate('fos_user_profile_edit'), 'name' => get_lang('Profile'));
  59. $interbreadcrumb[]= array ('url' => '#','name' => get_lang('Outbox'));
  60. }
  61. $actions = '';
  62. if (api_get_setting('profile.extended_profile') == 'true') {
  63. if (api_get_setting(
  64. 'social.allow_social_tool'
  65. ) == 'true' && api_get_setting('message.allow_message_tool') == 'true'
  66. ) {
  67. $actions .= '<a href="'.api_get_path(WEB_PATH).'main/social/profile.php">'.Display::return_icon('shared_profile.png', get_lang('ViewSharedProfile')).'</a>';
  68. }
  69. if (api_get_setting('message.allow_message_tool') == 'true') {
  70. //echo '<a href="'.api_get_path(WEB_PATH).'main/messages/inbox.php">'.Display::return_icon('inbox.png').' '.get_lang('Messages').'</a>';
  71. $actions .= '<a href="'.api_get_path(WEB_PATH).'main/messages/new_message.php">'.Display::return_icon('message_new.png',get_lang('ComposeMessage')).'</a>';
  72. $actions .= '<a href="'.api_get_path(WEB_PATH).'main/messages/inbox.php">'.Display::return_icon('inbox.png',get_lang('Inbox')).'</a>';
  73. $actions .= '<a href="'.api_get_path(WEB_PATH).'main/messages/outbox.php">'.Display::return_icon('outbox.png',get_lang('Outbox')).'</a>';
  74. }
  75. }
  76. $info_delete_outbox =array();
  77. $info_delete_outbox = isset($_GET['form_delete_outbox']) ? explode(',',$_GET['form_delete_outbox']) : '';
  78. $count_delete_outbox = count($info_delete_outbox) - 1;
  79. if (isset($info_delete_outbox[0]) && 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. $keyword = '';
  96. $social_right_content = '';
  97. if (api_get_setting('social.allow_social_tool') == 'true') {
  98. //Block Social Menu
  99. $social_menu_block = SocialManager::show_social_menu('messages');
  100. $actionsLeft = '<a href="'.api_get_path(WEB_PATH).'main/messages/inbox.php?f=social">'.
  101. Display::return_icon('back.png', get_lang('Back'), array(), 32).'</a>';
  102. $form = MessageManager::getSearchForm(api_get_path(WEB_PATH).'main/messages/outbox.php');
  103. if ($form->validate()) {
  104. $values = $form->getSubmitValues();
  105. $keyword = $values['keyword'];
  106. }
  107. $actionsRight = $form->returnForm();
  108. $social_right_content .= Display::toolbarAction('toolbar', [$actionsLeft, $actionsRight]);
  109. }
  110. //MAIN CONTENT
  111. if ($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. $social_right_content .= MessageManager::outbox_display($keyword);
  124. } elseif ($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. $social_right_content .= MessageManager::outbox_display($keyword);
  130. } else {
  131. $social_right_content .= MessageManager::outbox_display($keyword);
  132. }
  133. //$tpl = new Template(get_lang('ComposeMessage'));
  134. $tpl = \Chamilo\CoreBundle\Framework\Container::getTwig();
  135. // Block Social Avatar
  136. SocialManager::setSocialUserBlock($tpl, api_get_user_id(), 'messages');
  137. if (api_get_setting('social.allow_social_tool') == 'true') {
  138. $tpl->addGlobal('social_menu_block', $social_menu_block);
  139. $tpl->addGlobal('social_right_content', $social_right_content);
  140. echo $tpl->render('@template_style/social/inbox.html.twig');
  141. } else {
  142. $content = $social_right_content;
  143. echo $actions;
  144. echo $content;
  145. }