* @author Isaac Flores Paz * @package chamilo.social */ $language_file = array('userInfo', 'index'); $cidReset = true; require_once '../inc/global.inc.php'; // Include OpenGraph NOT AVAILABLE require_once api_get_path(LIBRARY_PATH).'opengraph/OpenGraph.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; } $user_id = api_get_user_id(); $friendId = isset($_GET['u']) ? Security::remove_XSS($_GET['u']) : api_get_user_id(); $isAdmin = api_is_platform_admin($user_id); $show_full_profile = true; //social tab $this_section = SECTION_SOCIAL; if (!empty($_POST['social_wall_new_msg_main']) || !empty($_FILES['picture']['tmp_name'])) { $messageId = 0; $idMessage = SocialManager::sendWallMessage(api_get_user_id(), $friendId, $_POST['social_wall_new_msg_main'], $messageId, MESSAGE_STATUS_WALL_POST); if (!empty($_FILES['picture']['tmp_name']) && $idMessage > 0) { $error = SocialManager::sendWallMessageAttachmentFile(api_get_user_id(), $_FILES['picture'], $idMessage, $fileComment = ''); } $url = api_get_path(WEB_CODE_PATH) . 'social/profile.php'; $url .= empty($_SERVER['QUERY_STRING']) ? '' : '?'.Security::remove_XSS($_SERVER['QUERY_STRING']); header('Location: ' . $url); exit; } else if (!empty($_POST['social_wall_new_msg']) && !empty($_POST['messageId'])) { $messageId = intval($_POST['messageId']); $res = SocialManager::sendWallMessage(api_get_user_id(), $friendId, $_POST['social_wall_new_msg'], $messageId , MESSAGE_STATUS_WALL); $url = api_get_path(WEB_CODE_PATH) . 'social/profile.php'; $url .= empty($_SERVER['QUERY_STRING']) ? '' : '?'.Security::remove_XSS($_SERVER['QUERY_STRING']); header('Location: ' . $url); exit; } else if (isset($_GET['messageId'])) { $messageId = Security::remove_XSS($_GET['messageId']); $status = SocialManager::deleteMessage($messageId); header('Location: ' . api_get_path(WEB_CODE_PATH) . 'social/profile.php'); exit; } else if (isset($_GET['u'])) { //I'm your friend? I can see your profile? $user_id = intval($_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); } if ($user_info['user_id'] == api_get_user_id()) { $isSelfUser = true; } else { $isSelfUser = false; } $userIsOnline = user_is_online($user_id); $libpath = api_get_path(LIBRARY_PATH); require_once api_get_path(SYS_CODE_PATH).'calendar/myagenda.inc.php'; require_once $libpath.'magpierss/rss_fetch.inc'; $ajax_url = api_get_path(WEB_AJAX_PATH).'message.ajax.php'; $socialAjaxUrl = api_get_path(WEB_AJAX_PATH).'social.ajax.php'; $javascriptDir = api_get_path(LIBRARY_PATH) . 'javascript/'; api_block_anonymous_users(); $locale = _api_get_locale_from_language(); // Add Jquery scroll pagination plugin $htmlHeadXtra[] = api_get_js('jscroll/jquery.jscroll.js'); // Add Jquery Time ago plugin $htmlHeadXtra[] = api_get_js('jquery-timeago/jquery.timeago.js'); $timeAgoLocaleDir = $javascriptDir . 'jquery-timeago/locales/jquery.timeago.' . $locale . '.js'; if (file_exists($timeAgoLocaleDir)) { $htmlHeadXtra[] = api_get_js('jquery-timeago/locales/jquery.timeago.' . $locale . '.js'); } $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); } //Block Avatar Social $social_avatar_block = '
'; $social_avatar_block .= SocialManager::show_social_avatar_block('home'); $social_avatar_block .= '
'.$user_info['lastname'].'
'; $social_avatar_block .= '
'.$user_info['firstname'].'
'; /* $social_avatar_block .= '
'.Display::return_icon('user.png','','',ICON_SIZE_TINY).$user_info['username'].'
'; */ $social_avatar_block .= ''; $chat_status = $user_info['extra']; if(!empty($chat_status['user_chat_status'])){ $social_avatar_block.= '
'.Display::return_icon('online.png').get_lang('Chat')." (".get_lang('Online').')
'; }else{ $social_avatar_block.= '
'.Display::return_icon('offline.png').get_lang('Chat')." (".get_lang('Offline').')
'; } $editProfileUrl = api_get_path(WEB_CODE_PATH) . 'auth/profile.php'; if (api_get_setting('sso_authentication') === 'true') { $subSSOClass = api_get_setting('sso_authentication_subclass'); $objSSO = null; if (!empty($subSSOClass)) { require_once api_get_path(SYS_CODE_PATH) . 'auth/sso/sso.' . $subSSOClass . '.class.php'; $subSSOClass = 'sso' . $subSSOClass; $objSSO = new $subSSOClass(); } else { $objSSO = new sso(); } $editProfileUrl = $objSSO->generateProfileEditingURL(); } $social_avatar_block .= ''; $social_avatar_block .= '
'; //Social Block Menu $social_menu_block = SocialManager::show_social_menu('shared_profile', null, $user_id, $show_full_profile); //Setting some session info $user_info = api_get_user_info($my_user_id); $sessionList = SessionManager::getSessionsFollowedByUser($my_user_id, $user_info['status']); $htmlSessionList = null; foreach ($sessionList as $session) { $htmlSessionList .= '
'; $htmlSessionList .= Display::return_icon('session.png', get_lang('Session')); $htmlSessionList .= $session['name']; $htmlSessionList .= '
'; } // My friends $friend_html = listMyFriends($user_id, $link_shared ,$show_full_profile); $social_left_content = ''; /* $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 .= '
'; if ($isAdmin || $isSelfUser) { $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 (($isAdmin || $isSelfUser) && !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'])) { if ($isAdmin || $isSelfUser) { $personal_info .= '
'.get_lang('UserName').'
'. $user_info['username'].'
'; } } $personal_info .= '
'; } */ //Social Block Wall $wallSocialAddPost = wallSocialAddPost(); $social_wall_block = $wallSocialAddPost; //Social Post Wall $post_wall = wallSocialPost($my_user_id,$friendId) ; $social_post_wall_block = '
'; $social_post_wall_block .= '
Mis publicaciones
'; $social_post_wall_block .='
'; if(empty($post_wall)){ $social_post_wall_block .= '

'.get_lang("NingunaPublicacion").'

'; }else{ $social_post_wall_block .= $post_wall; } $social_post_wall_block .= '
'; $socialAutoExtendLink = Display::url( get_lang('SeeMore'), $socialAjaxUrl . '?u='. $my_user_id . '&a=listWallMessage&start=10&length=5', array( 'class' => 'nextPage next', ) ); /* $socialRightInformation = SocialManager::social_wrapper_div($personal_info, 4); */ //$social_right_content .= SocialManager::social_wrapper_div($wallSocial, 5); if ($show_full_profile) { // Block Extra information $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 .= '
'; $extra_information .= '
'.get_lang('ExtraInformation').'
'; $extra_information .='
'; $extra_information_value = ''; foreach($extra_user_data as $key=>$data) { //Avoding parameters if (in_array($key, array('mail_notify_invitation','mail_notify_message', 'mail_notify_group_message' ))) { continue; } // get display text, visibility and type from user_field table $field_variable = str_replace('extra_','',$key); $sql = "SELECT field_display_text,field_visible,field_type,id " ." FROM $t_uf WHERE field_variable ='$field_variable'"; $res_field = Database::query($sql); $row_field = Database::fetch_row($res_field); $field_display_text = $row_field[0]; $field_visible = $row_field[1]; $field_type = $row_field[2]; $field_id = $row_field[3]; if ($field_visible == 1) { if (is_array($data)) { $extra_information_value .= '
'.ucfirst($field_display_text).'
' .'
'.implode(',',$data).'
'; } else { if ($field_type == UserManager::USER_FIELD_TYPE_DOUBLE_SELECT) { $id_options = explode(';',$data); $value_options = array(); // get option display text from user_field_options table foreach ($id_options as $id_option) { $sql = "SELECT option_display_text FROM $t_ufo WHERE id = '$id_option'"; $res_options = Database::query($sql); $row_options = Database::fetch_row($res_options); $value_options[] = $row_options[0]; } $extra_information_value .= '
'.ucfirst($field_display_text).':
' .'
'.implode(' ',$value_options).'
'; } elseif ($field_type == UserManager::USER_FIELD_TYPE_TAG ) { $user_tags = UserManager::get_user_tags($user_id, $field_id); $tag_tmp = array(); foreach ($user_tags as $tags) { $tag_tmp[] = '' .$tags['tag'] .''; } if (is_array($user_tags) && count($user_tags)>0) { $extra_information_value .= '
'.ucfirst($field_display_text).':
' .'
'.implode('', $tag_tmp).'
'; } } elseif ($field_type == UserManager::USER_FIELD_TYPE_SOCIAL_PROFILE) { $icon_path = UserManager::get_favicon_from_url($data); $bottom = '0.2'; //quick hack for hi5 $domain = parse_url($icon_path, PHP_URL_HOST); if ($domain == 'www.hi5.com' or $domain == 'hi5.com') { $bottom = '-0.8'; } $data = '' .'icon' .$field_display_text .''; $extra_information_value .= '
'.$data.'
'; } else { if (!empty($data)) { $extra_information_value .= '
'.ucfirst($field_display_text).':
'.$data.'
'; } } } } } // if there are information to show if (!empty($extra_information_value)) { $extra_information .= $extra_information_value; } $extra_information .= '
'; //social-profile-info } //If there are information to show Block Extra Information if (!empty($extra_information_value)) { $social_extra_info_block .= $extra_information; } // 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 = '
' //.get_lang('SeeMore').$url_close.'
'; //} $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 .= '
'; $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 .= ''; } } $total = count($grid_my_groups); $i = 1; foreach($grid_my_groups as $group) { $my_groups .= '
'; $my_groups .= $group[0]; $my_groups .= '
'; if ($i < $total) { $my_groups .= ', '; } $i++; } $my_groups .= '
'; //Block My Groups $social_group_info_block .= $my_groups; } $my_courses = null; // COURSES LIST if ( is_array($list) ) { $my_courses .= '
'; $my_courses .= '
'.api_ucfirst(get_lang('MyCourses')).'
'; $my_courses .= '
'; //Courses without sessions $i=1; foreach ($list as $key => $value) { if ( empty($value[2]) ) { //if out of any session $my_courses .= $value[1]; $my_courses .= ''; $i++; } } $my_courses .= '
'; //Block Social Course $social_course_block .= $my_courses; } //Block Social Sessions $sessions = '
'; $sessions .= '
'.api_ucfirst(get_lang('MySessions')).'
'; $sessions .= '
'.$htmlSessionList.'
'; $sessions .= '
'; $social_session_block .= $sessions; // Block Social User Feeds $user_feeds = SocialManager::get_user_feeds($user_id); if (!empty($user_feeds)) { $rss = '
'; $rss .= '
'.get_lang('RSSFeeds').'
'; $rss .= '
'.$user_feeds.'
'; $social_rss_block .= $rss; } //BLock Social Skill if (api_get_setting('allow_skills_tool') == 'true') { $social_skill_block = '
'; $social_skill_block .= '
' . get_lang('Skills'); $social_skill_block .= '
'; $skill = new Skill(); $ranking = $skill->get_user_skill_ranking(api_get_user_id()); $skills = $skill->get_user_skills(api_get_user_id(), true); $lis = ''; if (!empty($skills)) { foreach ($skills as $skill) { $badgeImage = null; if (!empty($skill['icon'])) { $badgeImage = Display::img( api_get_path(WEB_DATA_PATH) . $skill['icon'], $skill['name'] ); } else { $badgeImage = Display::return_icon( 'award_red.png', $skill['name'], array('title' => $skill['name']) ); } $lis .= Display::tag( 'li', $badgeImage . '
' . $skill['name'] . '
' ); } $social_skill_block .= '
'; $social_skill_block .= Display::tag('ul', $lis, array('class' => 'list-badges')); $social_skill_block .= '
'; }else{ $social_skill_block .= '
'; $social_skill_block .= '

'. get_lang("SinCompetencias"); $social_skill_block .= Display::url(get_lang('SkillsWheel'),api_get_path(WEB_CODE_PATH) . 'social/skills_wheel.php').'

'; $social_skill_block .= '
'; } $social_skill_block.='
'; } //--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 .= '
'; } $socialRightInformation .= 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; $socialRightInformation .= SocialManager::social_wrapper_div($product_content, 4); } $images_uploaded = null; // Images uploaded by course if (!empty($file_list)) { $images_uploaded .= '

'.get_lang('ImagesUploaded').'

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

'.get_lang('MoreInformation').'

'; if (!empty($user_info['competences'])) { $more_info .= '
'; $more_info .= '
'.get_lang('MyCompetences').'
'; $more_info .= '
'.$user_info['competences'].'
'; $more_info .= '
'; } if (!empty($user_info['diplomas'])) { $more_info .= '
'.get_lang('MyDiplomas').'
'; $more_info .= '
'.$user_info['diplomas'].'
'; $more_info .= '
'; } if (!empty($user_info['openarea'])) { $more_info .= '
'.get_lang('MyPersonalOpenArea').'
'; $more_info .= '
'.$user_info['openarea'].'
'; $more_info .= '
'; } if (!empty($user_info['teach'])) { $more_info .= '
'.get_lang('MyTeach').'
'; $more_info .= '
'.$user_info['teach'].'
'; $more_info .= '
'; } $socialRightInformation .= SocialManager::social_wrapper_div($more_info, 4); } } $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_avatar_block', $social_avatar_block); $tpl->assign('social_menu_block', $social_menu_block); $tpl->assign('social_wall_block', $social_wall_block); $tpl->assign('social_post_wall_block', $social_post_wall_block); $tpl->assign('social_extra_info_block', $social_extra_info_block); $tpl->assign('social_course_block', $social_course_block); $tpl->assign('social_group_info_block', $social_group_info_block); $tpl->assign('social_rss_block', $social_rss_block); $tpl->assign('social_skill_block', $social_skill_block); $tpl->assign('social_session_block', $social_session_block); $tpl->assign('socialRightInformation', $socialRightInformation); $tpl->assign('socialAutoExtendLink', $socialAutoExtendLink); $social_layout = $tpl->get_template('social/profile.tpl'); $tpl->display($social_layout); /* * function list my friends */ function listMyFriends($user_id, $link_shared, $show_full_profile) { //SOCIALGOODFRIEND , USER_RELATION_TYPE_FRIEND, USER_RELATION_TYPE_PARENT $friends = SocialManager::get_friends($user_id, USER_RELATION_TYPE_FRIEND); $friendHtml = ''; $number_of_images = 30; $number_friends = 0; $number_friends = count($friends); $friendHtml = ''; if ($number_friends != 0) { if ($number_friends > $number_of_images) { if (api_get_user_id() == $user_id) { $friendHtml.= ' : '.get_lang('SeeAll').''; } else { $friendHtml.= ' : ' .''.get_lang('SeeAll').''; } } $friendHtml.= ''; } else { $friendHtml.= '
'.get_lang('NoFriendsInYourContactList').'
' .''. get_lang('TryAndFindSomeFriends').'
'; } return $friendHtml; } function wallSocialAddPost() { $html = '
'; $html .= '
' . get_lang('SocialWall') . '
'; $html .= '
'; $html .= '

'; $html.= '
'; return $html; } function wallSocialPost($userId, $friendId) { $array = SocialManager::getWallMessagesPostHTML($userId, $friendId); $html = ''; for($i = 0; $i < count($array); $i++) { $post = $array[$i]['html']; $comment = SocialManager::getWallMessagesHTML($userId, $friendId, $array[$i]['id']); $html .= $post.$comment; } return $html; }