* @author Isaac Flores Paz * * @todo use Display::panel() * * @package chamilo.social */ $cidReset = true; require_once __DIR__.'/../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; } $user_id = api_get_user_id(); $friendId = isset($_GET['u']) ? (int) $_GET['u'] : api_get_user_id(); $show_full_profile = true; //social tab $this_section = SECTION_SOCIAL; // Initialize blocks $social_course_block = null; $social_group_info_block = null; $social_rss_block = null; $social_session_block = null; SocialManager::handlePosts(api_get_self().'?u='.$friendId); if (isset($_GET['u'])) { //I'm your friend? I can see your profile? $user_id = (int) $_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 = api_get_user_info($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, [ 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, [ 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; } } } } api_block_anonymous_users(); $countPost = SocialManager::getCountWallMessagesByUser($friendId); SocialManager::getScrollJs($countPost, $htmlHeadXtra); $link_shared = ''; if (isset($_GET['shared'])) { $link_shared = 'shared='.Security::remove_XSS($_GET['shared']); } $interbreadcrumb[] = [ 'url' => 'home.php', 'name' => get_lang('Social network'), ]; if (isset($_GET['u']) && is_numeric($_GET['u']) && $_GET['u'] != api_get_user_id()) { $info_user = api_get_user_info($_GET['u']); $interbreadcrumb[] = [ 'url' => '#', 'name' => $info_user['complete_name'], ]; } Session::write('social_user_id', (int) $user_id); // Setting some course info /*$course_list_code = []; $personal_course_list = UserManager::get_personal_session_course_list($friendId, 50); $i = 1; $list = []; 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[] = ['code' => $my_course['code']]; } else { break; } $i++; } //to avoid repeted courses $course_list_code = array_unique_dimensional($course_list_code); }*/ // Social Block Menu $menu = SocialManager::show_social_menu( 'shared_profile', null, $user_id, $show_full_profile ); //Setting some session info $user_info = api_get_user_info($friendId); //$sessionList = SessionManager::getSessionsFollowedByUser($friendId, $user_info['status']); $sessionList = []; // My friends $friend_html = SocialManager::listMyFriendsBlock($user_id, $link_shared); $addPostForm = SocialManager::getWallForm(api_get_self()); $posts = SocialManager::getWallMessagesByUser($friendId); $socialAutoExtendLink = SocialManager::getAutoExtendLink($user_id, $countPost); // Added a Jquery Function to return the Preview of OpenGraph URL Content $htmlHeadXtra[] = SocialManager::getScriptToGetOpenGraph(); $socialRightInformation = ''; $listInvitations = ''; if ($show_full_profile) { $social_group_info_block = SocialManager::getGroupBlock($friendId); /* $my_courses = null; // COURSES LIST if (is_array($list)) { $i = 1; foreach ($list as $key => $value) { if (empty($value[2])) { //if out of any session $my_courses .= $value[1]; $i++; } } $social_course_block .= $my_courses; }*/ // Block Social Sessions if (count($sessionList) > 0) { $social_session_block = $sessionList; } // Block Social User Feeds $user_feeds = SocialManager::getUserRssFeed($user_id); if (!empty($user_feeds)) { $social_rss_block = Display::panel($user_feeds, get_lang('RSS feed')); } // 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'], '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 = ''; $listInvitations = Display::panelCollapse( get_lang('Pending invitations'), $invitations, 'invitations', null, 'invitations-acordion', 'invitations-collapse' ); } } // Productions $production_list = UserManager::build_production_list($user_id); $product_content = ''; if (!empty($production_list)) { $product_content .= '

'.get_lang('My productions').'

'; $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('Uploaded images').'

'; $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('More information').'

'; if (!empty($user_info['competences'])) { $more_info .= '
'; $more_info .= '
'.get_lang('My competences').'
'; $more_info .= '
'.$user_info['competences'].'
'; $more_info .= '
'; } if (!empty($user_info['diplomas'])) { $more_info .= '
'.get_lang('My diplomas').'
'; $more_info .= '
'.$user_info['diplomas'].'
'; $more_info .= '
'; } if (!empty($user_info['openarea'])) { $more_info .= '
'.get_lang('My personal open area').'
'; $more_info .= '
'.$user_info['openarea'].'
'; $more_info .= '
'; } if (!empty($user_info['teach'])) { $more_info .= '
'.get_lang('What I am able to teach').'
'; $more_info .= '
'.$user_info['teach'].'
'; $more_info .= '
'; } $socialRightInformation .= SocialManager::social_wrapper_div($more_info, 4); } } $tpl = new Template(get_lang('Social')); // Block Avatar Social SocialManager::setSocialUserBlock( $tpl, $friendId, 'shared_profile', 0, $show_full_profile ); $tpl->assign('social_friend_block', $friend_html); $tpl->assign('social_menu_block', $menu); $tpl->assign('add_post_form', $addPostForm); $tpl->assign('posts', $posts); $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', SocialManager::getSkillBlock($friendId, 'vertical')); $tpl->assign('session_list', $social_session_block); $tpl->assign('invitations', $listInvitations); $tpl->assign('social_right_information', $socialRightInformation); $tpl->assign('social_auto_extend_link', $socialAutoExtendLink); $formModalTpl = new Template(); $formModalTpl->assign('invitation_form', MessageManager::generate_invitation_form()); $template = $formModalTpl->get_template('social/form_modals.tpl'); $formModals = $formModalTpl->fetch($template); $tpl->assign('form_modals', $formModals); $social_layout = $tpl->get_template('social/profile.tpl'); $tpl->display($social_layout);