Browse Source

Fix bread crumbs and actions bar see BT#13429

jmontoyaa 7 years ago
parent
commit
15a3ff68cc
4 changed files with 106 additions and 145 deletions
  1. 36 40
      main/messages/inbox.php
  2. 19 27
      main/messages/new_message.php
  3. 30 52
      main/messages/outbox.php
  4. 21 26
      main/messages/view_message.php

+ 36 - 40
main/messages/inbox.php

@@ -10,24 +10,23 @@ $cidReset = true;
 require_once __DIR__.'/../inc/global.inc.php';
 
 api_block_anonymous_users();
+
+if (api_get_setting('allow_message_tool') != 'true') {
+    api_not_allowed(true);
+}
+
+$allowSocial = api_get_setting('allow_social_tool') == 'true';
+$allowMessage = api_get_setting('allow_message_tool') == 'true';
+
 if (isset($_GET['messages_page_nr'])) {
-    $social_link = '';
-    if ($_REQUEST['f'] == 'social') {
-        $social_link = '?f=social';
-    }
-    if (api_get_setting('allow_social_tool') == 'true' &&
-        api_get_setting('allow_message_tool') == 'true'
-    ) {
-        header('Location:inbox.php'.$social_link);
+    if ($allowSocial && $allowMessage) {
+        header('Location:inbox.php');
         exit;
     }
 }
-if (api_get_setting('allow_message_tool') != 'true') {
-    api_not_allowed();
-}
+
 
 $nameTools = get_lang('Messages');
-$request = api_is_xml_http_request();
 $show_message = null;
 if (isset($_GET['form_reply']) || isset($_GET['form_delete'])) {
     $info_reply = array();
@@ -88,13 +87,12 @@ if (isset($_GET['form_reply']) || isset($_GET['form_delete'])) {
     }
 }
 
-if (isset($_GET['f']) && $_GET['f'] == 'social') {
+if ($allowSocial) {
     $this_section = SECTION_SOCIAL;
     $interbreadcrumb[] = array(
         'url' => api_get_path(WEB_PATH).'main/social/home.php',
         'name' => get_lang('SocialNetwork')
     );
-    $interbreadcrumb[] = array('url' => '#', 'name' => get_lang('Inbox'));
 } else {
     $this_section = SECTION_MYPROFILE;
     $interbreadcrumb[] = array(
@@ -103,45 +101,43 @@ if (isset($_GET['f']) && $_GET['f'] == 'social') {
     );
 }
 
-$social_parameter = '';
+$interbreadcrumb[] = array(
+    'url' => api_get_path(WEB_PATH).'main/messages/inbox.php',
+    'name' => get_lang('Messages')
+);
+$interbreadcrumb[] = array('url' => '#', 'name' => get_lang('Inbox'));
+
 $actions = '';
-if ((isset($_GET['f']) && $_GET['f'] === 'social') ||
-    api_get_setting('allow_social_tool') === 'true'
-) {
-    $social_parameter = '?f=social';
-} else {
-    //Comes from normal profile
-    if (api_get_setting('allow_social_tool') === 'true' &&
-        api_get_setting('allow_message_tool') === 'true'
-    ) {
-        $actions .= '<a href="'.api_get_path(WEB_PATH).'main/social/profile.php">'.
-            Display::return_icon('shared_profile.png', get_lang('ViewSharedProfile')).'</a>';
-    }
+// Comes from normal profile
+if ($allowSocial && $allowMessage) {
+    $actions .= '<a href="'.api_get_path(WEB_PATH).'main/social/profile.php">'.
+        Display::return_icon('shared_profile.png', get_lang('ViewSharedProfile')).'</a>';
+}
 
-    if (api_get_setting('allow_message_tool') == 'true') {
-        $actions .= '<a href="'.api_get_path(WEB_PATH).'main/messages/new_message.php">'.
-            Display::return_icon('message_new.png', get_lang('ComposeMessage')).'</a>';
-        $actions .= '<a href="'.api_get_path(WEB_PATH).'main/messages/inbox.php">'.
-            Display::return_icon('inbox.png', get_lang('Inbox')).'</a>';
-        $actions .= '<a href="'.api_get_path(WEB_PATH).'main/messages/outbox.php">'.
-            Display::return_icon('outbox.png', get_lang('Outbox')).'</a>';
-    }
+if ($allowMessage) {
+    $actions .= '<a href="'.api_get_path(WEB_PATH).'main/messages/new_message.php">'.
+        Display::return_icon('message_new.png', get_lang('ComposeMessage')).'</a>';
+    $actions .= '<a href="'.api_get_path(WEB_PATH).'main/messages/inbox.php">'.
+        Display::return_icon('inbox.png', get_lang('Inbox')).'</a>';
+    $actions .= '<a href="'.api_get_path(WEB_PATH).'main/messages/outbox.php">'.
+        Display::return_icon('outbox.png', get_lang('Outbox')).'</a>';
 }
 
+
 // LEFT CONTENT
 $social_menu_block = '';
-if (api_get_setting('allow_social_tool') === 'true') {
+if ($allowSocial) {
     // Block Social Menu
     $social_menu_block = SocialManager::show_social_menu('messages');
 }
 
-//Right content
-$social_right_content = null;
+// Right content
+$social_right_content = '';
 $keyword = '';
 if (api_get_setting('allow_social_tool') === 'true') {
-    $actionsLeft = '<a href="'.api_get_path(WEB_PATH).'main/messages/new_message.php?f=social">'.
+    $actionsLeft = '<a href="'.api_get_path(WEB_PATH).'main/messages/new_message.php">'.
         Display::return_icon('new-message.png', get_lang('ComposeMessage'), array(), 32).'</a>';
-    $actionsLeft .= '<a href="'.api_get_path(WEB_PATH).'main/messages/outbox.php?f=social">'.
+    $actionsLeft .= '<a href="'.api_get_path(WEB_PATH).'main/messages/outbox.php">'.
         Display::return_icon('outbox.png', get_lang('Outbox'), array(), 32).'</a>';
 
     $form = MessageManager::getSearchForm(api_get_path(WEB_PATH).'main/messages/inbox.php');

+ 19 - 27
main/messages/new_message.php

@@ -1,5 +1,6 @@
 <?php
 /* For licensing terms, see /license.txt */
+
 /**
  * @package chamilo.messages
 */
@@ -18,24 +19,12 @@ require_once __DIR__.'/../inc/global.inc.php';
 api_block_anonymous_users();
 
 if (api_get_setting('allow_message_tool') !== 'true') {
-    api_not_allowed();
+    api_not_allowed(true);
 }
 
-$nameTools = api_xml_http_response_encode(get_lang('Messages'));
-/*	Constants and variables */
-
-$htmlHeadXtra[] = '
-<script>
-function validate(form, list) {
-    if(list.selectedIndex<0) {
-        alert("Please select someone to send the message to.")
-        return false
-    } else {
-        return true
-    }
-}
+$allowSocial = api_get_setting('allow_social_tool') == 'true';
 
-</script>';
+$nameTools = api_xml_http_response_encode(get_lang('Messages'));
 
 $htmlHeadXtra[] = '<script>
 var counter_image = 1;
@@ -116,12 +105,11 @@ function manageForm($default, $select_from_user_list = null, $sent_to = null)
 {
     $group_id = isset($_REQUEST['group_id']) ? intval($_REQUEST['group_id']) : null;
     $message_id = isset($_GET['message_id']) ? intval($_GET['message_id']) : null;
-    $param_f = isset($_GET['f']) && $_GET['f'] == 'social' ? 'social' : null;
 
     $form = new FormValidator(
         'compose_message',
         null,
-        api_get_self().'?f='.$param_f,
+        api_get_self(),
         null,
         array('enctype' => 'multipart/form-data')
     );
@@ -297,10 +285,8 @@ function manageForm($default, $select_from_user_list = null, $sent_to = null)
     return $html;
 }
 
-$socialToolIsActive = isset($_GET['f']) && $_GET['f'] == 'social';
-
 /* MAIN SECTION */
-if ($socialToolIsActive) {
+if ($allowSocial) {
     $this_section = SECTION_SOCIAL;
     $interbreadcrumb[] = array(
         'url' => api_get_path(WEB_PATH).'main/social/home.php',
@@ -314,6 +300,11 @@ if ($socialToolIsActive) {
     );
 }
 
+$interbreadcrumb[] = array(
+    'url' => api_get_path(WEB_PATH).'main/messages/inbox.php',
+    'name' => get_lang('Messages')
+);
+
 $group_id = isset($_REQUEST['group_id']) ? intval($_REQUEST['group_id']) : null;
 $social_right_content = null;
 if ($group_id != 0) {
@@ -324,10 +315,10 @@ if ($group_id != 0) {
         Display::return_icon('message_new.png', api_xml_http_response_encode(get_lang('ComposeMessage'))).'</a>';
     $social_right_content .= '</div>';
 } else {
-    if ($socialToolIsActive) {
+    if ($allowSocial) {
     } else {
         $social_right_content .= '<div class=actions>';
-        if (api_get_setting('allow_social_tool') === 'true' && api_get_setting('allow_message_tool') === 'true') {
+        if ($allowSocial && api_get_setting('allow_message_tool') === 'true') {
             $social_right_content .= '<a href="'.api_get_path(WEB_PATH).'main/social/profile.php">'.
                 Display::return_icon('shared_profile.png', get_lang('ViewSharedProfile')).'</a>';
         }
@@ -344,9 +335,9 @@ if ($group_id != 0) {
 }
 
 // LEFT COLUMN
-$social_left_content = null;
-if (api_get_setting('allow_social_tool') == 'true') {
-    //Block Social Menu
+$social_left_content = '';
+if ($allowSocial) {
+    // Block Social Menu
     $social_menu_block = SocialManager::show_social_menu('messages');
     $social_right_content .= '<div class="row">';
     $social_right_content .= '<div class="col-md-12">';
@@ -403,7 +394,8 @@ if (!isset($_POST['compose'])) {
         }
     }
 }
-if (api_get_setting('allow_social_tool') === 'true') {
+
+if ($allowSocial) {
     $social_right_content .= '</div>';
     $social_right_content .= '</div>';
 }
@@ -412,7 +404,7 @@ $tpl = new Template(get_lang('ComposeMessage'));
 // Block Social Avatar
 SocialManager::setSocialUserBlock($tpl, api_get_user_id(), 'messages');
 
-if (api_get_setting('allow_social_tool') === 'true') {
+if ($allowSocial) {
     $tpl->assign('social_menu_block', $social_menu_block);
     $tpl->assign('social_right_content', $social_right_content);
     $social_layout = $tpl->get_template('social/inbox.tpl');

+ 30 - 52
main/messages/outbox.php

@@ -14,69 +14,46 @@ if (api_get_setting('allow_message_tool') != 'true') {
     api_not_allowed(true);
 }
 
+$allowSocial = api_get_setting('allow_social_tool') == 'true';
+$allowMessage = api_get_setting('allow_message_tool') == 'true';
+
 if (isset($_GET['messages_page_nr'])) {
-    if (api_get_setting('allow_social_tool') == 'true' &&
-        api_get_setting('allow_message_tool') == 'true'
-    ) {
-        $social_link = '';
-        if ($_REQUEST['f'] == 'social') {
-            $social_link = '&f=social';
-        }
-        header('Location:outbox.php?pager='.Security::remove_XSS($_GET['messages_page_nr']).$social_link.'');
+    if ($allowSocial && $allowMessage) {
+        header('Location:outbox.php?pager='.intval($_GET['messages_page_nr']));
         exit;
     }
 }
 
-$htmlHeadXtra[] = '<script>
-function enviar(miforma) {
-    if(confirm("'.get_lang('SureYouWantToDeleteSelectedMessages', '').'"))
-        miforma.submit();
-}
-function select_all(formita) {
-   for (i=0;i<formita.elements.length;i++)
-    {
-            if(formita.elements[i].type == "checkbox")
-                formita.elements[i].checked=1
-    }
-}
-function deselect_all(formita) {
-   for (i=0;i<formita.elements.length;i++) {
-        if(formita.elements[i].type == "checkbox")
-            formita.elements[i].checked=0
-    }
-}
-</script>';
-
-/*
-        MAIN CODE
-*/
-if (isset($_GET['f']) && $_GET['f'] === 'social') {
+if ($allowSocial) {
     $this_section = SECTION_SOCIAL;
     $interbreadcrumb[] = array('url' => api_get_path(WEB_PATH).'main/social/home.php', 'name' => get_lang('Social'));
-    $interbreadcrumb[] = array('url' => '#', 'name' => get_lang('Outbox'));
 } else {
     $this_section = SECTION_MYPROFILE;
     $interbreadcrumb[] = array('url' => api_get_path(WEB_PATH).'main/auth/profile.php', 'name' => get_lang('Profile'));
-    $interbreadcrumb[] = array('url' => '#', 'name' => get_lang('Outbox'));
 }
 
+$interbreadcrumb[] = array(
+    'url' => api_get_path(WEB_PATH).'main/messages/inbox.php',
+    'name' => get_lang('Messages')
+);
+
 $actions = '';
-if (api_get_setting('extended_profile') == 'true') {
-    if (api_get_setting('allow_social_tool') == 'true' && api_get_setting('allow_message_tool') == 'true') {
-        $actions .= '<a href="'.api_get_path(WEB_PATH).'main/social/profile.php">'.
-            Display::return_icon('shared_profile.png', get_lang('ViewSharedProfile')).'</a>';
-    }
-    if (api_get_setting('allow_message_tool') == 'true') {
-        //echo '<a href="'.api_get_path(WEB_PATH).'main/messages/inbox.php">'.Display::return_icon('inbox.png').' '.get_lang('Messages').'</a>';
-        $actions .= '<a href="'.api_get_path(WEB_PATH).'main/messages/new_message.php">'.
-            Display::return_icon('message_new.png', get_lang('ComposeMessage')).'</a>';
-        $actions .= '<a href="'.api_get_path(WEB_PATH).'main/messages/inbox.php">'.
-            Display::return_icon('inbox.png', get_lang('Inbox')).'</a>';
-        $actions .= '<a href="'.api_get_path(WEB_PATH).'main/messages/outbox.php">'.
-            Display::return_icon('outbox.png', get_lang('Outbox')).'</a>';
-    }
+
+if ($allowSocial && $allowMessage) {
+    $actions .= '<a href="'.api_get_path(WEB_PATH).'main/social/profile.php">'.
+        Display::return_icon('shared_profile.png', get_lang('ViewSharedProfile')).'</a>';
 }
 
+if ($allowMessage) {
+    $actions .= '<a href="'.api_get_path(WEB_PATH).'main/messages/new_message.php">'.
+        Display::return_icon('message_new.png', get_lang('ComposeMessage')).'</a>';
+    $actions .= '<a href="'.api_get_path(WEB_PATH).'main/messages/inbox.php">'.
+        Display::return_icon('inbox.png', get_lang('Inbox')).'</a>';
+    $actions .= '<a href="'.api_get_path(WEB_PATH).'main/messages/outbox.php">'.
+        Display::return_icon('outbox.png', get_lang('Outbox')).'</a>';
+}
+
+
 $info_delete_outbox = array();
 $info_delete_outbox = isset($_GET['form_delete_outbox']) ? explode(',', $_GET['form_delete_outbox']) : '';
 $count_delete_outbox = count($info_delete_outbox) - 1;
@@ -107,8 +84,8 @@ if (isset($_REQUEST['action'])) {
 
 $keyword = '';
 $social_right_content = '';
-if (api_get_setting('allow_social_tool') == 'true') {
-    //Block Social Menu
+if ($allowSocial) {
+    // Block Social Menu
     $social_menu_block = SocialManager::show_social_menu('messages');
     $actionsLeft = '<a href="'.api_get_path(WEB_PATH).'main/messages/inbox.php?f=social">'.
         Display::return_icon('back.png', get_lang('Back'), array(), 32).'</a>';
@@ -151,10 +128,11 @@ if ($action == 'delete') {
     $social_right_content .= MessageManager::outbox_display($keyword);
 }
 
-$tpl = new Template(get_lang('ComposeMessage'));
+$tpl = new Template(get_lang('Outbox'));
 // Block Social Avatar
 SocialManager::setSocialUserBlock($tpl, api_get_user_id(), 'messages');
-if (api_get_setting('allow_social_tool') == 'true') {
+
+if ($allowSocial) {
     $tpl->assign('social_menu_block', $social_menu_block);
     $tpl->assign('social_right_content', $social_right_content);
     $social_layout = $tpl->get_template('social/inbox.tpl');

+ 21 - 26
main/messages/view_message.php

@@ -6,42 +6,37 @@
 $cidReset = true;
 require_once __DIR__.'/../inc/global.inc.php';
 api_block_anonymous_users();
+
 if (api_get_setting('allow_message_tool') != 'true') {
-    api_not_allowed();
+    api_not_allowed(true);
 }
 
-if (isset($_REQUEST['f']) && $_REQUEST['f'] == 'social') {
+$allowSocial = api_get_setting('allow_social_tool') == 'true';
+$allowMessage = api_get_setting('allow_message_tool') == 'true';
+
+if ($allowSocial) {
     $this_section = SECTION_SOCIAL;
-    $interbreadcrumb[] = array('url' => api_get_path(WEB_PATH).'main/social/home.php', 'name' => get_lang('Social'));
-    $interbreadcrumb[] = array('url' => 'inbox.php?f=social', 'name' => get_lang('Inbox'));
+    $interbreadcrumb[] = array('url' => api_get_path(WEB_PATH).'main/social/home.php', 'name' => get_lang('SocialNetwork'));
 } else {
     $this_section = SECTION_MYPROFILE;
     $interbreadcrumb[] = array('url' => api_get_path(WEB_PATH).'main/auth/profile.php', 'name' => get_lang('Profile'));
 }
+$interbreadcrumb[] = array('url' => 'inbox.php', 'name' => get_lang('Messages'));
 
-$social_right_content = '';
-
-if (isset($_GET['f']) && $_GET['f'] == 'social') {
-    $social_parameter = '?f=social';
-} else {
-    if (api_get_setting('extended_profile') == 'true') {
-        $social_right_content .= '<div class="actions">';
-
-        if (api_get_setting('allow_social_tool') === 'true' && api_get_setting('allow_message_tool') === 'true') {
-            $social_right_content .= '<a href="'.api_get_path(WEB_PATH).'main/social/profile.php">'.
-                Display::return_icon('shared_profile.png', get_lang('ViewSharedProfile')).'</a>';
-        }
-        if (api_get_setting('allow_message_tool') === 'true') {
-            $social_right_content .= '<a href="'.api_get_path(WEB_PATH).'main/messages/new_message.php">'.
-                Display::return_icon('message_new.png', get_lang('ComposeMessage')).'</a>';
-            $social_right_content .= '<a href="'.api_get_path(WEB_PATH).'main/messages/inbox.php">'.
-                Display::return_icon('inbox.png', get_lang('Inbox')).'</a>';
-            $social_right_content .= '<a href="'.api_get_path(WEB_PATH).'main/messages/outbox.php">'.
-                Display::return_icon('outbox.png', get_lang('Outbox')).'</a>';
-        }
-        $social_right_content .= '</div>';
-    }
+$social_right_content = '<div class="actions">';
+if ($allowSocial && $allowMessage) {
+    $social_right_content .= '<a href="'.api_get_path(WEB_PATH).'main/social/profile.php">'.
+        Display::return_icon('shared_profile.png', get_lang('ViewSharedProfile')).'</a>';
+}
+if (api_get_setting('allow_message_tool') === 'true') {
+    $social_right_content .= '<a href="'.api_get_path(WEB_PATH).'main/messages/new_message.php">'.
+        Display::return_icon('message_new.png', get_lang('ComposeMessage')).'</a>';
+    $social_right_content .= '<a href="'.api_get_path(WEB_PATH).'main/messages/inbox.php">'.
+        Display::return_icon('inbox.png', get_lang('Inbox')).'</a>';
+    $social_right_content .= '<a href="'.api_get_path(WEB_PATH).'main/messages/outbox.php">'.
+        Display::return_icon('outbox.png', get_lang('Outbox')).'</a>';
 }
+$social_right_content .= '</div>';
 
 if (empty($_GET['id'])) {
     $id_message = $_GET['id_send'];