*/
$cidReset = true;
require_once '../inc/global.inc.php';
api_block_anonymous_users();
if (api_get_setting('allow_social_tool') != 'true') {
api_not_allowed();
}
$views = array('friends', 'mygroups');
$user_id = intval($_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 = array();
//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 .= ''; // 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 .= '
';
}
}
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 = array();
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'),
array('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'),
array('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_uri'],
80
);
$item_name = '
' . $url_open . api_xml_http_response_encode($name) . $icon . $url_close . '
';
$item_description = '';
if (!empty($result['description'])) {
$item_description = '
' .
api_xml_http_response_encode(get_lang('Description')) . '' .
cut(api_xml_http_response_encode($result['description']), 120, true ) . '
';
}
$result['picture_uri'] = '
';
$item_actions = '';
if (api_get_user_id() == $user_id) {
$item_actions = '
';
}
$grid_my_groups[] = array(
$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 . '
';
Display::display_sortable_grid(
'shared_profile_mygroups',
array(),
$grid_my_groups,
array('hide_navigation' => true, 'per_page' => 2),
$query_vars,
false,
array(true, true, true, false)
);
echo '
';
}
}
}