*/
/**
* Initialization
*/
$language_file = array('registration','messages','userInfo','admin');
$cidReset=true;
require_once '../inc/global.inc.php';
api_block_anonymous_users();
if (api_get_setting('allow_social_tool') !='true') {
api_not_allowed();
}
require_once api_get_path(LIBRARY_PATH).'group_portal_manager.lib.php';
$views = array('friends','mygroups');
$user_id = intval($_GET['user_id']);
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.='
';
// the height = 92 must be the sqme in the image_friend_network span style in default.css
$friends_profile = SocialManager::get_picture_user($friend['friend_user_id'], $friend['image'], 92, USER_IMAGE_SIZE_MEDIUM , 'width="85" height="90" ');
$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 = GroupPortalManager::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(GroupPortalManager::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 = GroupPortalManager::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 '
';
}
}
}