/** * 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); }