Browse Source

fix tpl social - refs #2681

Alex Aragón 6 years ago
parent
commit
439e4154f3

+ 1 - 1
main/auth/profile.php

@@ -697,7 +697,7 @@ SocialManager::setSocialUserBlock($tpl, api_get_user_id(), 'messages');
 
 if (api_get_setting('allow_social_tool') === 'true') {
     SocialManager::setSocialUserBlock($tpl, api_get_user_id(), 'home');
-    $menu = SocialManager::show_social_menu(
+    $menu = SocialManager::getMenuSocial(
         'home',
         null,
         api_get_user_id(),

+ 10 - 0
main/inc/lib/display.lib.php

@@ -2722,4 +2722,14 @@ HTML;
             $show_learnpath
         );
     }
+
+    public static function dropdownMenu($items=[]){
+        $html = null;
+        foreach ($items as $row){
+            $icon = self::tag('img',$row['icon']);
+            $link = self::url($icon . $row['item'], $row['url']);
+            $html.= self::tag('li',$link);
+        }
+        return  $html;
+    }
 }

+ 83 - 101
main/inc/lib/social.lib.php

@@ -207,7 +207,7 @@ class SocialManager extends UserManager
      */
     public static function get_list_web_path_user_invitation_by_user_id($user_id)
     {
-        $list_ids = self::get_list_invitation_of_friends_by_user_id($user_id);
+        $list_ids = self::get_list_invitation_of_friends_by_user_id($user_id, null);
         $list = [];
         foreach ($list_ids as $values_ids) {
             $list[] = UserManager::get_user_picture_path_by_id(
@@ -417,7 +417,7 @@ class SocialManager extends UserManager
                 WHERE
                     user_receiver_id = '.$userId.' AND
                     msg_status = '.MESSAGE_STATUS_INVITATION_PENDING;
-        if ($limit > 0) {
+        if ($limit != null && $limit > 0) {
             $sql .= ' LIMIT '.$limit;
         }
         $res = Database::query($sql);
@@ -872,7 +872,7 @@ class SocialManager extends UserManager
     /**
      * Shows the right menu of the Social Network tool.
      *
-     * @param string $show                       highlight link possible values:
+     * @param string $show highlight link possible values:
      *                                           group_add,
      *                                           home,
      *                                           messages,
@@ -883,12 +883,12 @@ class SocialManager extends UserManager
      *                                           shared_profile,
      *                                           friends,
      *                                           groups search
-     * @param int    $group_id                   group id
-     * @param int    $user_id                    user id
-     * @param bool   $show_full_profile          show profile or not (show or hide the user image/information)
-     * @param bool   $show_delete_account_button
+     * @param int $group_id group id
+     * @param int $user_id user id
+     * @param bool $show_full_profile show profile or not (show or hide the user image/information)
+     * @param bool $show_delete_account_button
      */
-    public static function show_social_menu(
+    public static function getMenuSocial(
         $show = '',
         $group_id = 0,
         $user_id = 0,
@@ -938,113 +938,95 @@ class SocialManager extends UserManager
         $portfolioIcon = Display::return_icon('wiki_task.png', get_lang('Portfolio'));
         $personalDataIcon = Display::return_icon('database.png', get_lang('PersonalDataReport'));
 
-        $html = '';
+        $html = null;
         $active = null;
+        $links = null;
+
+
         if (!in_array(
             $show,
             ['shared_profile', 'groups', 'group_edit', 'member_list', 'waiting_list', 'invite_friends']
         )) {
-            $links = '<ul class="nav navbar-nav">';
-            $active = $show == 'home' ? 'active' : null;
-            $links .= '
-                <li class="home-icon '.$active.'">
-                    <a href="'.api_get_path(WEB_CODE_PATH).'social/home.php">
-                        '.$homeIcon.' '.get_lang('Home').'
-                    </a>
-                </li>';
-            $active = $show == 'messages' ? 'active' : null;
-            $links .= '
-                <li class="messages-icon '.$active.'">
-                    <a href="'.api_get_path(WEB_CODE_PATH).'messages/inbox.php">
-                        '.$messagesIcon.' '.get_lang('Messages').$count_unread_message.'
-                    </a>
-                </li>';
-
-            //Invitations
-            $active = $show == 'invitations' ? 'active' : null;
-            $links .= '
-                <li class="invitations-icon '.$active.'">
-                    <a href="'.api_get_path(WEB_CODE_PATH).'social/invitations.php">
-                        '.$invitationsIcon.' '.get_lang('Invitations').$total_invitations.'
-                    </a>
-                </li>';
-
-            //Shared profile and groups
-            $active = $show == 'shared_profile' ? 'active' : null;
-            $links .= '
-                <li class="shared-profile-icon'.$active.'">
-                    <a href="'.api_get_path(WEB_CODE_PATH).'social/profile.php">
-                        '.$sharedProfileIcon.' '.get_lang('ViewMySharedProfile').'
-                    </a>
-                </li>';
-            $active = $show == 'friends' ? 'active' : null;
-            $links .= '
-                <li class="friends-icon '.$active.'">
-                    <a href="'.api_get_path(WEB_CODE_PATH).'social/friends.php">
-                        '.$friendsIcon.' '.get_lang('Friends').'
-                    </a>
-                </li>';
-            $active = $show == 'browse_groups' ? 'active' : null;
-            $links .= '
-                <li class="browse-groups-icon '.$active.'">
-                    <a href="'.api_get_path(WEB_CODE_PATH).'social/groups.php">
-                        '.$groupsIcon.' '.get_lang('SocialGroups').'
-                    </a>
-                </li>';
-
-            //Search users
-            $active = $show == 'search' ? 'active' : null;
-            $links .= '
-                <li class="search-icon '.$active.'">
-                    <a href="'.api_get_path(WEB_CODE_PATH).'social/search.php">
-                        '.$searchIcon.' '.get_lang('Search').'
-                    </a>
-                </li>';
-
-            //My files
-            $active = $show == 'myfiles' ? 'active' : null;
-
-            $myFiles = '
-                <li class="myfiles-icon '.$active.'">
-                    <a href="'.api_get_path(WEB_CODE_PATH).'social/myfiles.php">
-                        '.$filesIcon.' '.get_lang('MyFiles').'
-                    </a>
-                </li>';
+
+            $itemMenu = [];
+
+            $itemMenu [0]= [
+                'item' => get_lang('Home'),
+                'url' => api_get_path(WEB_CODE_PATH) . 'social/home.php',
+                'icon' => $homeIcon,
+                'active' => ($show == 'home' ? 'active' : null)
+            ];
+
+            $itemMenu [1]= [
+                'item' => get_lang('Messages') . $count_unread_message,
+                'url' => api_get_path(WEB_CODE_PATH) . 'social/inbox.php',
+                'icon' => $messagesIcon,
+                'active' => ($show == 'messages' ? 'active' : null)
+            ];
+
+            $itemMenu [2]= [
+                'item' => get_lang('Invitations') .$total_invitations,
+                'url' => api_get_path(WEB_CODE_PATH) . 'social/invitations.php',
+                'icon' => $invitationsIcon,
+                'active' => ($show == 'invitations' ? 'active' : null)
+            ];
+
+            $itemMenu [3]= [
+                'item' => get_lang('ViewMySharedProfile'),
+                'url' => api_get_path(WEB_CODE_PATH) . 'social/profiles.php',
+                'icon' => $sharedProfileIcon,
+                'active' => ($show == 'shared_profile' ? 'active' : null)
+            ];
+
+            $itemMenu [4]= [
+                'item' => get_lang('Friends'),
+                'url' => api_get_path(WEB_CODE_PATH) . 'social/friends.php',
+                'icon' => $friendsIcon,
+                'active' => ($show == 'friends' ? 'active' : null)
+            ];
+
+            $itemMenu [5]= [
+                'item' => get_lang('SocialGroups'),
+                'url' => api_get_path(WEB_CODE_PATH) . 'social/groups.php',
+                'icon' => $groupsIcon,
+                'active' => ($show == 'browse_groups' ? 'active' : null)
+            ];
+
+            $itemMenu [6]= [
+                'item' => get_lang('Search'),
+                'url' => api_get_path(WEB_CODE_PATH) . 'social/search.php',
+                'icon' => $searchIcon,
+                'active' => ($show == 'search' ? 'active' : null)
+            ];
 
             if (api_get_setting('allow_my_files') === 'false') {
-                $myFiles = '';
+                $itemMenu [7]= [
+                    'item' => get_lang('MyFiles'),
+                    'url' => api_get_path(WEB_CODE_PATH) . 'social/myfiles.php',
+                    'icon' => $filesIcon,
+                    'active' => ($show == 'myfiles' ? 'active' : null)
+                ];
             }
-            $links .= $myFiles;
+
             if (api_get_configuration_value('allow_portfolio_tool')) {
-                $links .= '
-                    <li class="portoflio-icon '.($show == 'portfolio' ? 'active' : '').'">
-                        <a href="'.api_get_path(WEB_CODE_PATH).'portfolio/index.php">
-                            '.$portfolioIcon.' '.get_lang('Portfolio').'
-                        </a>
-                    </li>
-                ';
+                $itemMenu [8]= [
+                    'item' => get_lang('Portfolio'),
+                    'url' => api_get_path(WEB_CODE_PATH) . 'portfolio/index.php',
+                    'icon' => $portfolioIcon,
+                    'active' => ($show == 'portfolio' ? 'active' : null)
+                ];
             }
 
             if (!api_get_configuration_value('disable_gdpr')) {
-                $active = $show == 'personal-data' ? 'active' : null;
-                $personalData = '
-                    <li class="personal-data-icon '.$active.'">
-                        <a href="'.api_get_path(WEB_CODE_PATH).'social/personal_data.php">
-                            '.$personalDataIcon.' '.get_lang('PersonalDataReport').'
-                        </a>
-                    </li>';
-                $links .= $personalData;
-                $links .= '</ul>';
+                $itemMenu [9]= [
+                    'item' => get_lang('PersonalDataReport'),
+                    'url' => api_get_path(WEB_CODE_PATH) . 'social/personal_data.php',
+                    'icon' => $personalDataIcon,
+                    'active' => ($show == 'personal-data' ? 'active' : null)
+                ];
             }
 
-            $html .= Display::panelCollapse(
-                get_lang('SocialNetwork'),
-                $links,
-                'social-network-menu',
-                null,
-                'sn-sidebar',
-                'sn-sidebar-collapse'
-            );
+            return Display::dropdownMenu($itemMenu);
         }
 
         if (in_array($show, $show_groups) && !empty($group_id)) {

+ 1 - 1
main/social/friends.php

@@ -70,7 +70,7 @@ $interbreadcrumb[] = ['url' => 'profile.php', 'name' => get_lang('SocialNetwork'
 $interbreadcrumb[] = ['url' => '#', 'name' => get_lang('Friends')];
 
 //Block Social Menu
-$social_menu_block = SocialManager::show_social_menu('friends');
+$social_menu_block = SocialManager::getMenuSocial('friends');
 $user_id = api_get_user_id();
 $name_search = isset($_POST['search_name_q']) ? $_POST['search_name_q'] : null;
 $number_friends = 0;

+ 1 - 1
main/social/group_add.php

@@ -43,7 +43,7 @@ $interbreadcrumb[] = ['url' => 'groups.php', 'name' => get_lang('Groups')];
 $interbreadcrumb[] = ['url' => '#', 'name' => $nameTools];
 
 $social_avatar_block = SocialManager::show_social_avatar_block('group_add');
-$social_menu_block = SocialManager::show_social_menu('group_add');
+$social_menu_block = SocialManager::getMenuSocial('group_add');
 $social_right_content = $form->returnForm();
 
 $tpl = new Template(null);

+ 1 - 1
main/social/group_edit.php

@@ -54,7 +54,7 @@ if ($form->validate()) {
     exit();
 }
 
-$social_left_content = SocialManager::show_social_menu('group_edit', $group_id);
+$social_left_content = SocialManager::getMenuSocial('group_edit', $group_id);
 $social_right_content = $form->returnForm();
 
 $tpl = new Template(get_lang('Edit'));

+ 2 - 2
main/social/group_invitation.php

@@ -143,7 +143,7 @@ if (is_array($Users) && count($Users) > 0) {
     }
 }
 
-$social_left_content = SocialManager::show_social_menu('invite_friends', $group_id);
+$social_left_content = SocialManager::getMenuSocial('invite_friends', $group_id);
 $social_right_content = '<h3 class="group-title">'.Security::remove_XSS($group_info['name'], STUDENT, true).'</h3>';
 
 if (count($nosessionUsersList) == 0) {
@@ -201,7 +201,7 @@ if (is_array($members) && count($members) > 0) {
 
 $tpl = new Template(null);
 SocialManager::setSocialUserBlock($tpl, api_get_user_id(), 'groups', $group_id);
-$social_menu_block = SocialManager::show_social_menu('member_list', $group_id);
+$social_menu_block = SocialManager::getMenuSocial('member_list', $group_id);
 $tpl->assign('social_menu_block', $social_menu_block);
 $tpl->setHelp('Groups');
 $tpl->assign('social_right_content', $social_right_content);

+ 1 - 1
main/social/group_members.php

@@ -116,7 +116,7 @@ $social_avatar_block = SocialManager::show_social_avatar_block(
     'member_list',
     $group_id
 );
-$social_menu_block = SocialManager::show_social_menu('member_list', $group_id);
+$social_menu_block = SocialManager::getMenuSocial('member_list', $group_id);
 $social_right_content = '<h2>'.$group_info['name'].'</h2>';
 
 foreach ($users as $user) {

+ 2 - 2
main/social/group_topics.php

@@ -183,7 +183,7 @@ $interbreadcrumb[] = ['url' => 'groups.php', 'name' => get_lang('Groups')];
 $interbreadcrumb[] = ['url' => 'group_view.php?id='.$group_id, 'name' => Security::remove_XSS($group_info['name'])];
 $interbreadcrumb[] = ['url' => '#', 'name' => get_lang('Discussions')];
 
-$social_left_content = SocialManager::show_social_menu('member_list', $group_id);
+$social_left_content = SocialManager::getMenuSocial('member_list', $group_id);
 $show_message = null;
 if (!empty($show_message)) {
     $social_right_content .= Display::return_message($show_message, 'confirmation');
@@ -195,7 +195,7 @@ $group_message = MessageManager::display_message_for_group(
     $message_id
 );
 
-$social_menu_block = SocialManager::show_social_menu('member_list', $group_id);
+$social_menu_block = SocialManager::getMenuSocial('member_list', $group_id);
 
 $tpl = new Template(null);
 $tpl->setHelp('Groups');

+ 1 - 1
main/social/group_view.php

@@ -320,7 +320,7 @@ $tpl = new Template(null);
 // Block Social Avatar
 SocialManager::setSocialUserBlock($tpl, api_get_user_id(), 'groups', $group_id);
 //Block Social Menu
-$social_menu_block = SocialManager::show_social_menu('groups', $group_id);
+$social_menu_block = SocialManager::getMenuSocial('groups', $group_id);
 $tpl->setHelp('Groups');
 $tpl->assign('create_link', $create_thread_link);
 $tpl->assign('is_group_member', $is_group_member);

+ 2 - 2
main/social/group_waiting_list.php

@@ -86,7 +86,7 @@ $users = $usergroup->get_users_by_group(
 );
 
 $new_member_list = [];
-$social_left_content = SocialManager::show_social_menu('waiting_list', $group_id);
+$social_left_content = SocialManager::getMenuSocial('waiting_list', $group_id);
 
 // Display form
 foreach ($users as $user) {
@@ -112,7 +112,7 @@ if (empty($new_member_list) > 0) {
 $tpl = new Template(null);
 
 SocialManager::setSocialUserBlock($tpl, api_get_user_id(), 'groups', $group_id);
-$social_menu_block = SocialManager::show_social_menu('member_list', $group_id);
+$social_menu_block = SocialManager::getMenuSocial('member_list', $group_id);
 $tpl->assign('social_menu_block', $social_menu_block);
 $tpl->setHelp('Groups');
 $tpl->assign('members', $new_member_list);

+ 1 - 1
main/social/groups.php

@@ -380,7 +380,7 @@ if (isset($_GET['view']) && $_GET['view'] == 'mygroups') {
     $show_menu = $_GET['view'];
 }
 
-$social_menu_block = SocialManager::show_social_menu($show_menu);
+$social_menu_block = SocialManager::getMenuSocial($show_menu);
 $templateName = 'social/groups.tpl';
 
 $tpl->setHelp('Groups');

+ 5 - 3
main/social/home.php

@@ -78,7 +78,7 @@ if (api_get_setting('profile', 'picture') == 'true') {
 }
 
 //Block Menu
-$social_menu_block = SocialManager::show_social_menu('home');
+$MenuSocial = SocialManager::getMenuSocial('home');
 
 $social_search_block = Display::panel(
     UserManager::get_search_form(''),
@@ -232,11 +232,13 @@ $tpl = new Template(get_lang('SocialNetwork'));
 
 SocialManager::setSocialUserBlock($tpl, api_get_user_id(), 'home');
 
-$tpl->assign('social_menu_block', $social_menu_block);
+$tpl->assign('social_menu_block', $MenuSocial);
 $tpl->assign('social_friend_block', $friend_html);
 $tpl->assign('session_list', $social_session_block);
 $tpl->assign('social_search_block', $social_search_block);
 $tpl->assign('social_skill_block', SocialManager::getSkillBlock($user_id));
 $tpl->assign('social_group_block', $social_group_block);
 $social_layout = $tpl->get_template('social/home.tpl');
-$tpl->display($social_layout);
+$content = $tpl->fetch($social_layout);
+$tpl->assign('content', $content);
+$tpl->display_one_col_template();

+ 1 - 1
main/social/invitations.php

@@ -84,7 +84,7 @@ if (is_array($_GET) && count($_GET) > 0) {
 $content = null;
 
 // Block Menu Social
-$social_menu_block = SocialManager::show_social_menu('invitations');
+$social_menu_block = SocialManager::getMenuSocial('invitations');
 // Block Invitations
 $socialInvitationsBlock = '<div id="id_response" align="center"></div>';
 

+ 1 - 1
main/social/myfiles.php

@@ -76,7 +76,7 @@ $(document).on("ready", function () {
 </script>';
 
 // Social Menu Block
-$social_menu_block = SocialManager::show_social_menu('myfiles');
+$social_menu_block = SocialManager::getMenuSocial('myfiles');
 $actions = null;
 
 if (isset($_GET['cidReq'])) {

+ 1 - 1
main/social/personal_data.php

@@ -233,7 +233,7 @@ $interbreadcrumb[] = ['url' => '#', 'name' => get_lang('PersonalDataReport')];
 $socialMenuBlock = '';
 if ($allowSocial) {
     // Block Social Menu
-    $socialMenuBlock = SocialManager::show_social_menu('personal-data');
+    $socialMenuBlock = SocialManager::getMenuSocial('personal-data');
 }
 
 // MAIN CONTENT

+ 5 - 3
main/social/profile.php

@@ -240,7 +240,7 @@ if (is_array($personal_course_list)) {
 }
 
 //Social Block Menu
-$social_menu_block = SocialManager::show_social_menu(
+$social_menu_block = SocialManager::getMenuSocial(
     'shared_profile',
     null,
     $user_id,
@@ -601,7 +601,7 @@ if ($show_full_profile) {
     if (!isset($_GET['u']) ||
         (isset($_GET['u']) && $_GET['u'] == api_get_user_id())
     ) {
-        $pending_invitations = SocialManager::get_list_invitation_of_friends_by_user_id(api_get_user_id());
+        $pending_invitations = SocialManager::get_list_invitation_of_friends_by_user_id(api_get_user_id(), null);
         $list_get_path_web = SocialManager::get_list_web_path_user_invitation_by_user_id(api_get_user_id());
         $count_pending_invitations = count($pending_invitations);
     }
@@ -729,4 +729,6 @@ $formModals = $formModalTpl->fetch($template);
 
 $tpl->assign('form_modals', $formModals);
 $social_layout = $tpl->get_template('social/profile.tpl');
-$tpl->display($social_layout);
+$content = $tpl->fetch($social_layout);
+$tpl->assign('content', $content);
+$tpl->display_one_col_template();

+ 1 - 1
main/social/search.php

@@ -37,7 +37,7 @@ if (!empty($extra_fields)) {
 }
 
 //Block Social Menu
-$social_menu_block = SocialManager::show_social_menu('search');
+$social_menu_block = SocialManager::getMenuSocial('search');
 $block_search = '';
 $searchForm = UserManager::get_search_form($query);
 

+ 1 - 1
main/social/terms.php

@@ -45,7 +45,7 @@ $allowSocial = api_get_setting('allow_social_tool') === 'true';
 
 if ($allowSocial) {
     // Block Social Menu
-    $socialMenuBlock = SocialManager::show_social_menu('personal-data');
+    $socialMenuBlock = SocialManager::getMenuSocial('personal-data');
 }
 
 $tpl = new Template(null);

+ 1 - 1
main/template/default/social/home.html.twig

@@ -1,4 +1,4 @@
-{% extends "@ChamiloTheme/Layout/layout_one_col.html.twig" %}
+
 {% import '@ChamiloTheme/Macros/box.html.twig' as macro %}
 
 {% block content %}

+ 1 - 1
main/template/default/social/profile.html.twig

@@ -1,4 +1,4 @@
-{% extends "@ChamiloTheme/Layout/layout_one_col.html.twig" %}
+
 {% import '@ChamiloTheme/Macros/box.html.twig' as macro %}
 
 {% block content %}