outbox.php 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  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. $social_right_content = '';
  92. if (api_get_setting('allow_social_tool') == 'true') {
  93. //Block Social Menu
  94. $social_menu_block = SocialManager::show_social_menu('messages');
  95. $social_right_content .= '<div class="actions">';
  96. $social_right_content .= '<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. $social_right_content .= '</div>';
  99. }
  100. //MAIN CONTENT
  101. if ($action == 'delete') {
  102. $delete_list_id=array();
  103. if (isset($_POST['out'])) {
  104. $delete_list_id=$_POST['out'];
  105. }
  106. if (isset($_POST['id'])) {
  107. $delete_list_id=$_POST['id'];
  108. }
  109. for ($i=0;$i<count($delete_list_id);$i++) {
  110. MessageManager::delete_message_by_user_sender(api_get_user_id(), $delete_list_id[$i]);
  111. }
  112. $delete_list_id=array();
  113. $social_right_content .= MessageManager::outbox_display();
  114. } elseif($action =='deleteone') {
  115. $delete_list_id=array();
  116. $id = Security::remove_XSS($_GET['id']);
  117. MessageManager::delete_message_by_user_sender(api_get_user_id(),$id);
  118. $delete_list_id=array();
  119. $social_right_content .= MessageManager::outbox_display();
  120. } else {
  121. $social_right_content .= MessageManager::outbox_display();
  122. }
  123. $tpl = new Template(get_lang('ComposeMessage'));
  124. // Block Social Avatar
  125. SocialManager::setSocialUserBlock($tpl, $user_id, 'messages');
  126. if (api_get_setting('allow_social_tool') == 'true') {
  127. $tpl->assign('social_menu_block', $social_menu_block);
  128. $tpl->assign('social_right_content', $social_right_content);
  129. $social_layout = $tpl->get_template('social/inbox.tpl');
  130. $tpl->display($social_layout);
  131. } else {
  132. $content = $social_right_content;
  133. $tpl->assign('actions', $actions);
  134. //$tpl->assign('message', $show_message);
  135. $tpl->assign('content', $content);
  136. $tpl->display_one_col_template();
  137. }