/** * Generate the social block for a user * @param Template $template * @param int $userId The user id * @param string $groupBlock Optional. Highlight link possible values: * group_add, home, messages, messages_inbox, messages_compose, * messages_outbox, invitations, shared_profile, friends, groups, search * @param int $groupId Optional. Group ID * @return string The HTML code with the social block */ public static function setSocialUserBlock(Template $template, $userId, $groupBlock = '', $groupId = 0) { if (api_get_setting('allow_social_tool') != 'true') { return ''; } $socialAvatarBlock = SocialManager::show_social_avatar_block($groupBlock, $groupId, $userId); $profileEditionLink = null; if (api_get_user_id() == $userId) { $profileEditionLink = Display::getProfileEditionLink($userId); } $vCardUserLink = Display::getVCardUserLink($userId); $userInfo = api_get_user_info($userId, true, false, true); $template->assign('user', $userInfo); $template->assign('social_avatar_block', $socialAvatarBlock); $template->assign('profile_edition_link', $profileEditionLink); //Added the link to export the vCard to the Template $template->assign('vcard_user_link', $vCardUserLink); if (api_get_setting('gamification_mode') === '1') { $gamificationPoints = GamificationUtils::getTotalUserPoints($userId, $userInfo['status']); $template->assign('gamification_points', $gamificationPoints); } $chatEnabled = api_is_global_chat_enabled(); $template->assign('chat_enabled', $chatEnabled); $templateName = $template->get_template('social/user_block.tpl'); if (in_array($groupBlock, ['groups', 'group_edit', 'member_list'])) { $templateName = $template->get_template('social/group_block.tpl'); } $template->assign('social_avatar_block', $template->fetch($templateName)); }
/** * Generate the social block for a user * @param Template $template * @param int $userId The user id * @param string $groupBlock Optional. Highlight link possible values: * group_add, home, messages, messages_inbox, messages_compose, * messages_outbox, invitations, shared_profile, friends, groups, search * @param int $groupId Optional. Group ID * @param boolean $show_full_profile - Optional. Shows the Full Profile or Not * @return string The HTML code with the social block */ public static function setSocialUserBlock($template, $userId, $groupBlock = '', $groupId = 0, $show_full_profile = true) { if (api_get_setting('social.allow_social_tool') != 'true') { return ''; } $socialAvatarBlock = SocialManager::show_social_avatar_block($groupBlock, $groupId, $userId); $profileEditionLink = null; if (api_get_user_id() == $userId) { $profileEditionLink = Display::getProfileEditionLink($userId); } $vCardUserLink = Display::getVCardUserLink($userId); $userInfo = api_get_user_info($userId, true, false, true, true); $template->addGlobal('user', $userInfo); $template->addGlobal('social_avatar_block', $socialAvatarBlock); $template->addGlobal('profile_edition_link', $profileEditionLink); //If not friend $show_full_profile is False and the user can't see Email Address and Vcard Download Link if ($show_full_profile) { //Added the link to export the vCard to the Template $template->addGlobal('vcard_user_link', $vCardUserLink); } if (api_get_setting('platform.gamification_mode') === '1') { $gamificationPoints = GamificationUtils::getTotalUserPoints($userId, $userInfo['status']); $template->addGlobal('gamification_points', $gamificationPoints); } $chatEnabled = api_is_global_chat_enabled(); $template->addGlobal('chat_enabled', $chatEnabled); $templateName = $template->render('@template_style/social/user_block.html.twig'); if (in_array($groupBlock, ['groups', 'group_edit', 'member_list'])) { $templateName = $template->render('@template_style/social/group_block.html.twig'); } $template->addGlobal('social_avatar_block', $templateName); }
if (array_key_exists($session->getId(), $sessionList)) { continue; } if ($currentSession && $currentSession->getId() === $session->getId()) { $allowAccess = true; } $sessionList[$session->getId()] = $session; } if ($currentSession && !$allowAccess) { api_not_allowed(true); } $template = new Template($nameTools); $template->assign('user', $user); $template->assign('user_avatar', SocialManager::show_social_avatar_block('home', 0, $user->getId())); $template->assign('gamification_stars', GamificationUtils::getTotalUserStars($user->getId(), $user->getStatus())); $template->assign('gamification_points', GamificationUtils::getTotalUserPoints($user->getId(), $user->getStatus())); $template->assign('gamification_progress', GamificationUtils::getTotalUserProgress($user->getId(), $user->getStatus())); $template->assign('sessions', $sessionList); $template->assign('current_session', $currentSession); if ($currentSession) { $sessionData = []; $sessionCourses = $currentSession->getCourses(); foreach ($sessionCourses as $sessionCourse) { $course = $sessionCourse->getCourse(); $courseData = ['title' => $course->getTitle(), 'stats' => []]; $learningPathList = new LearnpathList($user->getId(), $course->getCode(), $currentSession->getId()); foreach ($learningPathList->list as $learningPathId => $learningPath) { $courseData['stats'][] = [$learningPath['lp_name'], 'newscorm/lp_controller.php?' . http_build_query(['action' => 'stats', 'cidReq' => $course->getCode(), 'id_session' => $currentSession->getId(), 'gidReq' => 0, 'lp_id' => $learningPathId]) . api_get_cidreq()]; } $sessionData[$course->getId()] = $courseData; }