*/ $cidReset = true; require_once __DIR__.'/../inc/global.inc.php'; api_block_anonymous_users(); if (api_get_setting('allow_social_tool') != 'true') { api_not_allowed(); } $views = ['friends', 'mygroups']; $user_id = (int) $_GET['user_id']; $userGroup = new UserGroup(); if (isset($_GET['view']) && in_array($_GET['view'], $views)) { // show all friends by user_id if ($_GET['view'] == 'friends') { echo '
'; $list_path_friends = $list_path_normal_friends = $list_path_parents = []; //SOCIALGOODFRIEND , USER_RELATION_TYPE_FRIEND, SOCIALPARENT $friends = SocialManager::get_friends( $user_id, USER_RELATION_TYPE_FRIEND ); $number_friends = count($friends); $friend_html = ''; $friend_html .= '

'.get_lang('SocialFriend').'

'; $friend_html .= '
'; $friend_html .= '
'; if ($number_friends == 1) { $friend_html .= '
'.$number_friends.' '.get_lang('Friend').'
'; } else { $friend_html .= '
'.$number_friends.' '.get_lang('Friends').'
'; } $friend_html .= '
'; // close div friend-header for ($k = 0; $k < $number_friends; $k++) { if (isset($friends[$k])) { $friend = $friends[$k]; $name_user = api_get_person_name( $friend['firstName'], $friend['lastName'] ); $friend_html .= '
'; $userPicture = UserManager::getUserPicture($friend['friend_user_id']); $friend_html .= ''; $friend_html .= ''; $friend_html .= '
'; $friend_html .= '
'.$name_user.'
'; $friend_html .= '
'; } } echo $friend_html; echo '
'; } else { // show all groups by user_id // MY GROUPS $results = $userGroup->get_groups_by_user($user_id, 0); $grid_my_groups = []; if (is_array($results) && count($results) > 0) { $i = 1; foreach ($results as $result) { $id = $result['id']; $url_open = ''; $url_close = ''; $icon = ''; $name = cut($result['name'], 20, true); if ($result['relation_type'] == GROUP_USER_PERMISSION_ADMIN) { $icon = Display::return_icon( 'social_group_admin.png', get_lang('Admin'), ['style' => 'vertical-align:middle;width:16px;height:16px;'] ); } elseif ($result['relation_type'] == GROUP_USER_PERMISSION_MODERATOR) { $icon = Display::return_icon( 'social_group_moderator.png', get_lang('Moderator'), ['style' => 'vertical-align:middle;width:16px;height:16px;'] ); } $count_users_group = count( $userGroup->get_all_users_by_group($id) ); if ($count_users_group == 1) { $count_users_group = $count_users_group.' '.get_lang('Member'); } else { $count_users_group = $count_users_group.' '.get_lang('Members'); } $picture = $userGroup->get_picture_group( $result['id'], $result['picture'], 80 ); $item_name = '
'.$url_open.api_xml_http_response_encode($name).$icon.$url_close.'
'; $item_description = ''; if (!empty($result['description'])) { $item_description = '
'; } $result['picture_uri'] = '
'; $item_actions = ''; if (api_get_user_id() == $user_id) { $item_actions = '
'. get_lang('SeeMore').$url_close.'
'; } $grid_my_groups[] = [ $item_name, $url_open.$result['picture_uri'].$url_close, $item_description.$item_actions, ]; $i++; } } if (count($grid_my_groups) > 0) { echo '
'; echo '

'.get_lang('MyGroups').'

'; $count_groups = 0; if (count($results) == 1) { $count_groups = count($results).' '.get_lang('Group'); } else { $count_groups = count($results).' '.get_lang('Groups'); } echo '
'.$count_groups.'
'; foreach ($grid_my_groups as $group) { echo Display::panel($group[0], $group[1]); } echo '
'; } } }