/** * Build the modify-column of the table * @param int The user id * @param string URL params to add to table links * @param array Row of elements to alter * @return string Some HTML-code with modify-buttons */ function modify_filter($user_id, $url_params, $row) { global $charset, $_admins_list; $is_admin = in_array($user_id, $_admins_list); $statusname = api_get_status_langvars(); $user_is_anonymous = false; $current_user_status_label = $row['7']; if ($current_user_status_label == $statusname[ANONYMOUS]) { $user_is_anonymous = true; } $result = ''; if (!$user_is_anonymous) { $icon = Display::return_icon('course.png', get_lang('Courses'), array('onmouseout' => 'clear_course_list (\'div_' . $user_id . '\')')); $result .= '<a href="javascript:void(0)" onclick="load_course_list(\'div_' . $user_id . '\',' . $user_id . ')" > ' . $icon . ' <div class="blackboard_hide" id="div_' . $user_id . '"> </div> </a>'; $icon = Display::return_icon('session.png', get_lang('Sessions'), array('onmouseout' => 'clear_session_list (\'div_s_' . $user_id . '\')')); $result .= '<a href="javascript:void(0)" onclick="load_session_list(\'div_s_' . $user_id . '\',' . $user_id . ')" > ' . $icon . ' <div class="blackboard_hide" id="div_s_' . $user_id . '"> </div> </a>'; } else { $result .= Display::return_icon('course_na.png', get_lang('Courses')) . ' '; $result .= Display::return_icon('course_na.png', get_lang('Sessions')) . ' '; } if (api_is_platform_admin()) { if (!$user_is_anonymous) { $result .= '<a href="user_information.php?user_id=' . $user_id . '">' . Display::return_icon('synthese_view.gif', get_lang('Info')) . '</a> '; } else { $result .= Display::return_icon('synthese_view_na.gif', get_lang('Info')) . ' '; } } //only allow platform admins to login_as, or session admins only for students (not teachers nor other admins) if (api_is_platform_admin() || api_is_session_admin() && $current_user_status_label == $statusname[STUDENT]) { if (!$user_is_anonymous) { if (api_global_admin_can_edit_admin($user_id)) { $result .= '<a href="user_list.php?action=login_as&user_id=' . $user_id . '&sec_token=' . $_SESSION['sec_token'] . '">' . Display::return_icon('login_as.png', get_lang('LoginAs')) . '</a> '; } else { $result .= Display::return_icon('login_as_na.png', get_lang('LoginAs')) . ' '; } } else { $result .= Display::return_icon('login_as_na.png', get_lang('LoginAs')) . ' '; } } else { $result .= Display::return_icon('login_as_na.png', get_lang('LoginAs')) . ' '; } if ($current_user_status_label != $statusname[STUDENT]) { $result .= Display::return_icon('statistics_na.gif', get_lang('Reporting')) . ' '; } else { $result .= '<a href="../mySpace/myStudents.php?student=' . $user_id . '">' . Display::return_icon('statistics.gif', get_lang('Reporting')) . '</a> '; } if (api_is_platform_admin(true)) { $editProfileUrl = Display::getProfileEditionLink($user_id, true); if (!$user_is_anonymous && api_global_admin_can_edit_admin($user_id, null, true)) { $result .= '<a href="' . $editProfileUrl . '">' . Display::return_icon('edit.png', get_lang('Edit'), array(), ICON_SIZE_SMALL) . '</a> '; } else { $result .= Display::return_icon('edit_na.png', get_lang('Edit'), array(), ICON_SIZE_SMALL) . '</a> '; } } if ($is_admin) { $result .= Display::return_icon('admin_star.png', get_lang('IsAdministrator'), array('width' => ICON_SIZE_SMALL, 'heigth' => ICON_SIZE_SMALL)); } else { $result .= Display::return_icon('admin_star_na.png', get_lang('IsNotAdministrator')); } // actions for assigning sessions, courses or users if (api_is_session_admin()) { /*if ($row[0] == api_get_user_id()) { $result .= '<a href="dashboard_add_sessions_to_user.php?user='******'">'.Display::return_icon('view_more_stats.gif', get_lang('AssignSessions')).'</a> '; }*/ } else { if ($current_user_status_label == $statusname[SESSIONADMIN]) { $result .= Display::url(Display::return_icon('view_more_stats.gif', get_lang('AssignSessions')), "dashboard_add_sessions_to_user.php?user={$user_id}"); } else { if ($current_user_status_label == $statusname[DRH] || UserManager::is_admin($user_id) || $current_user_status_label == $statusname[STUDENT_BOSS]) { $result .= Display::url(Display::return_icon('user_subscribe_course.png', get_lang('AssignUsers'), '', ICON_SIZE_SMALL), "dashboard_add_users_to_user.php?user={$user_id}"); } if ($current_user_status_label == $statusname[DRH] || UserManager::is_admin($user_id)) { $result .= Display::url(Display::return_icon('course_add.gif', get_lang('AssignCourses')), "dashboard_add_courses_to_user.php?user={$user_id}"); $result .= Display::url(Display::return_icon('view_more_stats.gif', get_lang('AssignSessions')), "dashboard_add_sessions_to_user.php?user={$user_id}"); } } } if (api_is_platform_admin()) { $result .= ' <a href="' . api_get_path(WEB_AJAX_PATH) . 'agenda.ajax.php?a=get_user_agenda&user_id=' . $user_id . '&modal_size=lg" class="agenda_opener ajax">' . Display::return_icon('month.png', get_lang('FreeBusyCalendar'), array(), ICON_SIZE_SMALL) . '</a>'; $deleteAllowed = !api_get_configuration_value('deny_delete_users'); if ($deleteAllowed) { if ($user_id != api_get_user_id() && !$user_is_anonymous && api_global_admin_can_edit_admin($user_id)) { // you cannot lock yourself out otherwise you could disable all the accounts including your own => everybody is locked out and nobody can change it anymore. $result .= ' <a href="user_list.php?action=delete_user&user_id=' . $user_id . '&' . $url_params . '&sec_token=' . $_SESSION['sec_token'] . '" onclick="javascript:if(!confirm(' . "'" . addslashes(api_htmlentities(get_lang("ConfirmYourChoice"), ENT_QUOTES, $charset)) . "'" . ')) return false;">' . Display::return_icon('delete.png', get_lang('Delete'), array(), ICON_SIZE_SMALL) . '</a>'; } else { $result .= Display::return_icon('delete_na.png', get_lang('Delete'), array(), ICON_SIZE_SMALL); } } } return $result; }
/** * 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); }
/** * @return null|string|void */ public function return_profile_block() { global $_configuration; $user_id = api_get_user_id(); if (empty($user_id)) { return; } $userGroup = new UserGroup(); $profile_content = '<ul class="nav nav-pills nav-stacked">'; // @todo Add a platform setting to add the user image. if (api_get_setting('message.allow_message_tool') == 'true') { // New messages. $number_of_new_messages = MessageManager::get_new_messages(); // New contact invitations. $number_of_new_messages_of_friend = SocialManager::get_message_number_invitation_by_user_id(api_get_user_id()); // New group invitations sent by a moderator. $group_pending_invitations = $userGroup->get_groups_by_user(api_get_user_id(), GROUP_USER_PERMISSION_PENDING_INVITATION, false); $group_pending_invitations = count($group_pending_invitations); $total_invitations = $number_of_new_messages_of_friend + $group_pending_invitations; $cant_msg = Display::badge($number_of_new_messages); $link = ''; if (api_get_setting('social.allow_social_tool') == 'true') { $link = '?f=social'; } $profile_content .= '<li class="inbox-message-social"><a href="' . api_get_path(WEB_PATH) . 'main/messages/inbox.php' . $link . '">' . Display::return_icon('inbox.png', get_lang('Inbox'), null, ICON_SIZE_SMALL) . get_lang('Inbox') . $cant_msg . ' </a></li>'; $profile_content .= '<li class="new-message-social"><a href="' . api_get_path(WEB_PATH) . 'main/messages/new_message.php' . $link . '">' . Display::return_icon('new-message.png', get_lang('Compose'), null, ICON_SIZE_SMALL) . get_lang('Compose') . ' </a></li>'; if (api_get_setting('social.allow_social_tool') == 'true') { $total_invitations = Display::badge($total_invitations); $profile_content .= '<li class="invitations-social"><a href="' . api_get_path(WEB_PATH) . 'main/social/invitations.php">' . Display::return_icon('invitations.png', get_lang('PendingInvitations'), null, ICON_SIZE_SMALL) . get_lang('PendingInvitations') . $total_invitations . '</a></li>'; } if (isset($_configuration['allow_my_files_link_in_homepage']) && $_configuration['allow_my_files_link_in_homepage']) { $profile_content .= '<li class="myfiles-social"><a href="' . api_get_path(WEB_PATH) . 'main/social/myfiles.php">' . get_lang('MyFiles') . '</a></li>'; } } $editProfileUrl = Display::getProfileEditionLink($user_id); $profile_content .= '<li class="profile-social"><a href="' . $editProfileUrl . '">' . Display::return_icon('edit-profile.png', get_lang('EditProfile'), null, ICON_SIZE_SMALL) . get_lang('EditProfile') . '</a></li>'; $profile_content .= '</ul>'; $html = self::show_right_block(get_lang('Profile'), $profile_content, 'profile_block', null, 'profile', 'profileCollapse'); return $html; }
/** * 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)); }