* @author Isaac Flores Paz * @package chamilo.social */ $language_file = array('userInfo', 'index'); $cidReset = true; require_once '../inc/global.inc.php'; if (api_get_setting('allow_social_tool') !='true') { $url = api_get_path(WEB_PATH).'whoisonline.php?id='.intval($_GET['u']); header('Location: '.$url); exit; //api_not_allowed(); } $user_id = api_get_user_id(); $show_full_profile = true; //social tab $this_section = SECTION_SOCIAL; //I'm your friend? I can see your profile? if (isset($_GET['u'])) { $user_id = (int) Database::escape_string($_GET['u']); if (api_is_anonymous($user_id, true)) { api_not_allowed(true); } // It's me! if (api_get_user_id() != $user_id) { $user_info = UserManager::get_user_info_by_id($user_id); $show_full_profile = false; if (!$user_info) { // user does no exist !! api_not_allowed(true); } else { //checking the relationship between me and my friend $my_status= SocialManager::get_relation_between_contacts(api_get_user_id(), $user_id); if (in_array($my_status, array(USER_RELATION_TYPE_PARENT, USER_RELATION_TYPE_FRIEND, USER_RELATION_TYPE_GOODFRIEND))) { $show_full_profile = true; } //checking the relationship between my friend and me $my_friend_status = SocialManager::get_relation_between_contacts($user_id, api_get_user_id()); if (in_array($my_friend_status, array(USER_RELATION_TYPE_PARENT, USER_RELATION_TYPE_FRIEND, USER_RELATION_TYPE_GOODFRIEND))) { $show_full_profile = true; } else { // im probably not a good friend $show_full_profile = false; } } } else { $user_info = UserManager::get_user_info_by_id($user_id); } } else { $user_info = UserManager::get_user_info_by_id($user_id); } $libpath = api_get_path(LIBRARY_PATH); require_once api_get_path(SYS_CODE_PATH).'calendar/myagenda.inc.php'; require_once api_get_path(SYS_CODE_PATH).'announcements/announcements.inc.php'; require_once $libpath.'magpierss/rss_fetch.inc'; $ajax_url = api_get_path(WEB_AJAX_PATH).'message.ajax.php'; api_block_anonymous_users(); $htmlHeadXtra[] = ''; $nametool = get_lang('ViewMySharedProfile'); if (isset($_GET['shared'])) { $my_link='../social/profile.php'; $link_shared='shared='.Security::remove_XSS($_GET['shared']); } else { $my_link='../social/profile.php'; $link_shared=''; } $interbreadcrumb[]= array ('url' =>'home.php','name' => get_lang('SocialNetwork') ); if (isset($_GET['u']) && is_numeric($_GET['u']) && $_GET['u'] != api_get_user_id()) { $info_user = api_get_user_info($_GET['u']); $interbreadcrumb[]= array ('url' => '#','name' => api_get_person_name($info_user['firstName'], $info_user['lastName'])); $nametool = ''; } if (isset($_GET['u'])) { $param_user='u='.Security::remove_XSS($_GET['u']); }else { $info_user = api_get_user_info(api_get_user_id()); $param_user = ''; } $_SESSION['social_user_id'] = intval($user_id); /** * Display */ //Setting some course info $my_user_id=isset($_GET['u']) ? Security::remove_XSS($_GET['u']) : api_get_user_id(); $personal_course_list = UserManager::get_personal_session_course_list($my_user_id); $course_list_code = array(); $i=1; if (is_array($personal_course_list)) { foreach ($personal_course_list as $my_course) { if ($i<=10) { $list[] = SocialManager::get_logged_user_course_html($my_course, $i); $course_list_code[] = array('code'=>$my_course['code']); } else { break; } $i++; } //to avoid repeted courses $course_list_code = array_unique_dimensional($course_list_code); } $social_left_content = SocialManager::show_social_menu('shared_profile', null, $user_id, $show_full_profile); $personal_info = null; if (!empty($user_info['firstname']) || !empty($user_info['lastname'])) { $personal_info .= '

'.api_get_person_name($user_info['firstname'], $user_info['lastname']).'

'; } else { //--- Basic Information $personal_info .= '

'.get_lang('Profile').'

'; } if ($show_full_profile) { $personal_info .= '
'; $personal_info .= '
'.get_lang('UserName').'
'. $user_info['username'].'
'; if (!empty($user_info['firstname']) || !empty($user_info['lastname'])) $personal_info .= '
'.get_lang('Name').'
'. api_get_person_name($user_info['firstname'], $user_info['lastname']).'
'; if (!empty($user_info['official_code'])) $personal_info .= '
'.get_lang('OfficialCode').'
'.$user_info['official_code'].'
'; if (!empty($user_info['email'])) if (api_get_setting('show_email_addresses')=='true') $personal_info .= '
'.get_lang('Email').'
'.$user_info['email'].'
'; if (!empty($user_info['phone'])) $personal_info .= '
'.get_lang('Phone').'
'. $user_info['phone'].'
'; $personal_info .= '
'; } else { $personal_info .= '
'; if (!empty($user_info['username'])) $personal_info .= '
'.get_lang('UserName').'
'. $user_info['username'].'
'; $personal_info .= '
'; } $social_right_content = SocialManager::social_wrapper_div($personal_info, 4); if ($show_full_profile) { //SOCIALGOODFRIEND , USER_RELATION_TYPE_FRIEND, USER_RELATION_TYPE_PARENT $friends = SocialManager::get_friends($user_id, USER_RELATION_TYPE_FRIEND); $friend_html = ''; $number_of_images = 6; $number_friends = 0; $number_friends = count($friends); if ($number_friends != 0) { $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').'
'; } if ($number_friends > $number_of_images) { if (api_get_user_id() == $user_id) { $friend_html.= '
'.get_lang('SeeAll').'
'; } else { $friend_html.= '
'.get_lang('SeeAll').'
'; } } $friend_html.= '
'; // close div friend-header $friend_html.=''; } else { // No friends!! :( $friend_html .= '

'.get_lang('SocialFriend').'

'; $friend_html.= ''; $social_right_content .= SocialManager::social_wrapper_div($friend_html, 5); } // Extra information if ($show_full_profile) { //-- Extra Data $t_uf = Database :: get_main_table(TABLE_MAIN_USER_FIELD); $t_ufo = Database :: get_main_table(TABLE_MAIN_USER_FIELD_OPTIONS); $extra_user_data = UserManager::get_extra_user_data($user_id); $extra_information = ''; if (is_array($extra_user_data) && count($extra_user_data)>0 ) { $extra_information .= '

'.get_lang('ExtraInformation').'

'; $extra_information .=''; //social-profile-info } // if there are information to show if (!empty($extra_information_value)) $social_right_content .= SocialManager::social_wrapper_div($extra_information, 9); } if ($show_full_profile) { // MY GROUPS $results = GroupPortalManager::get_groups_by_user($my_user_id, 0); $grid_my_groups = array(); $max_numbers_of_group = 4; if (is_array($results) && count($results) > 0) { $i = 1; foreach ($results as $result) { if ($i > $max_numbers_of_group) break; $id = $result['id']; $url_open = ''; $url_close = ''; $icon = ''; $name = cut($result['name'],CUT_GROUP_NAME,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.$name.$icon.$url_close; if ($result['description'] != '') { //$item_description = '
'; } else { //$item_description = '
'; } //$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_actions); $i++; } } if (count($grid_my_groups) > 0) { $my_groups = ''; $count_groups = 0; if (count($results) == 1 ) { $count_groups = count($results); } else { $count_groups = count($results); } $my_groups .= '

'.get_lang('MyGroups').' ('.$count_groups.')

'; if ($i > $max_numbers_of_group) { if (api_get_user_id() == $user_id) { $my_groups .= '
'; } else { $my_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)); $total = count($grid_my_groups); $i = 1; foreach($grid_my_groups as $group) { $my_groups .= $group[0]; if ($i < $total) { $my_groups .= ', '; } $i++; } $social_right_content .= SocialManager::social_wrapper_div($my_groups, 9); } // COURSES LIST if ( is_array($list) ) { $my_courses .= '

'.api_ucfirst(get_lang('MyCourses')).'

'; $my_courses .= ''; //social-content-training $social_right_content .= SocialManager::social_wrapper_div($my_courses, 9); } // user feeds $user_feeds = SocialManager::get_user_feeds($user_id); if (!empty($user_feeds)) { $rss = '

'.get_lang('RSSFeeds').'

'; $rss .= ''; $social_right_content .= SocialManager::social_wrapper_div($rss, 9); } //--Productions $production_list = UserManager::build_production_list($user_id); // Images uploaded by course $file_list = ''; if (is_array($course_list_code) && count($course_list_code)>0) { foreach ($course_list_code as $course) { $file_list.= UserManager::get_user_upload_files_by_course($user_id, $course['code'], $resourcetype='images'); } } $count_pending_invitations = 0; 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()); $list_get_path_web = SocialManager::get_list_web_path_user_invitation_by_user_id(api_get_user_id()); $count_pending_invitations = count($pending_invitations); } if (!empty($production_list) || !empty($file_list) || $count_pending_invitations > 0) { //Pending invitations if (!isset($_GET['u']) || (isset($_GET['u']) && $_GET['u']==api_get_user_id())) { if ($count_pending_invitations > 0) { $invitations .= '

'.get_lang('PendingInvitations').'

'; for ($i=0;$i<$count_pending_invitations;$i++) { $user_invitation_id = $pending_invitations[$i]['user_sender_id']; $invitations .= '
'; $invitations .= '
'; $invitations .= ''; $invitations .= '
'; $invitations .= '
'; $user_invitation_info = api_get_user_info($user_invitation_id); $invitations .= ''.api_get_person_name($user_invitation_info['firstname'], $user_invitation_info['lastname']).''; $invitations .= '
'; $invitations .= Security::remove_XSS(cut($pending_invitations[$i]['content'], 50), STUDENT, true); $invitations .= '
'; $invitations .= ''.get_lang('SocialAddToFriends').''; $invitations .= '
'; $invitations .= '
'; $invitations .= '
'; } $social_right_content .= SocialManager::social_wrapper_div($invitations, 4); } } //--Productions $production_list = UserManager::build_production_list($user_id); $product_content = ''; if (!empty($production_list)) { $product_content .= '

'.get_lang('MyProductions').'

'; $product_content .= $production_list; $social_right_content .= SocialManager::social_wrapper_div($product_content, 5); } $images_uploaded = null; // Images uploaded by course if (!empty($file_list)) { $images_uploaded .= '

'.get_lang('ImagesUploaded').'

'; $images_uploaded .= ''; $social_right_content .= SocialManager::social_wrapper_div($images_uploaded, 9); } } if (!empty($user_info['competences']) || !empty($user_info['diplomas']) || !empty($user_info['openarea']) || !empty($user_info['teach']) ) { $more_info .= '

'.get_lang('MoreInformation').'

'; $cut_size = 220; if (!empty($user_info['competences'])) { $more_info .= '
'; $more_info .= ''; $more_info .= ''; $more_info .= '
'; } if (!empty($user_info['diplomas'])) { $more_info .= ''; $more_info .= ''; $more_info .= '
'; } if (!empty($user_info['openarea'])) { $more_info .= ''; $more_info .= ''; $more_info .= '
'; } if (!empty($user_info['teach'])) { $more_info .= ''; $more_info .= ''; $more_info .= '
'; } $social_right_content .= SocialManager::social_wrapper_div($more_info, 9); } } $social_right_content .= MessageManager::generate_message_form('send_message'); $social_right_content .= MessageManager::generate_invitation_form('send_invitation'); $tpl = new Template(get_lang('Social')); $tpl->assign('social_left_content', $social_left_content); $tpl->assign('social_left_menu', $social_left_menu); $tpl->assign('social_right_content', $social_right_content); $social_layout = $tpl->get_template('layout/social_layout.tpl'); $content = $tpl->fetch($social_layout); $tpl->assign('actions', $actions); $tpl->assign('message', $message); $tpl->assign('content', $content); $tpl->display_one_col_template();