public function get_link_user_picture($username, $password, $id) { if ($this->verifyUserPass($username, $password) == "valid") { $userPic = UserManager::getUserPicture($id); if (empty($userPic)) { return "0"; } return $userPic; } return "0"; }
/** * Formats user information into a standard array * This function should be only used inside api_get_user_info() * * @param array Non-standard user array * @param bool $add_password * * @return array Standard user array */ function _api_format_user($user, $add_password = false) { $result = array(); $firstname = null; $lastname = null; if (isset($user['firstname']) && isset($user['lastname'])) { $firstname = $user['firstname']; $lastname = $user['lastname']; } elseif (isset($user['firstName']) && isset($user['lastName'])) { $firstname = isset($user['firstName']) ? $user['firstName'] : null; $lastname = isset($user['lastName']) ? $user['lastName'] : null; } $result['complete_name'] = api_get_person_name($firstname, $lastname); $result['complete_name_with_username'] = $result['complete_name']; if (!empty($user['username'])) { $result['complete_name_with_username'] = $result['complete_name'] . ' (' . $user['username'] . ')'; } $result['firstname'] = $firstname; $result['lastname'] = $lastname; // Kept for historical reasons $result['firstName'] = $firstname; $result['lastName'] = $lastname; $attributes = array('phone', 'picture_uri', 'official_code', 'status', 'active', 'auth_source', 'username', 'theme', 'language', 'creator_id', 'registration_date', 'hr_dept_id', 'expiration_date'); foreach ($attributes as $attribute) { $result[$attribute] = isset($user[$attribute]) ? $user[$attribute] : null; } if (isset($user['email'])) { $result['mail'] = isset($user['email']) ? $user['email'] : null; $result['email'] = isset($user['email']) ? $user['email'] : null; } else { $result['mail'] = isset($user['mail']) ? $user['mail'] : null; $result['email'] = isset($user['mail']) ? $user['mail'] : null; } $user_id = intval($user['user_id']); // Maintain the user_id index for backwards compatibility $result['user_id'] = $result['id'] = $user_id; $saveUserLastLogin = api_get_configuration_value('save_user_last_login'); if ($saveUserLastLogin) { $last_login = $user['last_login']; } else { if (!isset($user['lastLogin']) && !isset($user['last_login'])) { $timestamp = Tracking::get_last_connection_date($result['user_id'], false, true); // Convert the timestamp back into a datetime // NOTE: this timestamp has ALREADY been converted to the local timezone in the get_last_connection_date function $last_login = date('Y-m-d H:i:s', $timestamp); } else { if (isset($user['lastLogin'])) { $last_login = $user['lastLogin']; } else { $last_login = $user['last_login']; } } } $result['last_login'] = $last_login; // Kept for historical reasons $result['lastLogin'] = $last_login; // Getting user avatar. $originalFile = UserManager::getUserPicture($user_id, USER_IMAGE_SIZE_ORIGINAL, $result); $smallFile = UserManager::getUserPicture($user_id, USER_IMAGE_SIZE_SMALL, $result); $result['avatar'] = $originalFile; $avatarString = explode('?', $originalFile); $result['avatar_no_query'] = reset($avatarString); $result['avatar_small'] = $smallFile; //$result['avatar_sys_path'] = api_get_path(SYS_CODE_PATH).'img/unknown.jpg'; if (isset($user['user_is_online'])) { $result['user_is_online'] = $user['user_is_online'] == true ? 1 : 0; } if (isset($user['user_is_online_in_chat'])) { $result['user_is_online_in_chat'] = intval($user['user_is_online_in_chat']); } if ($add_password) { $result['password'] = $user['password']; } $result['profile_url'] = api_get_path(WEB_CODE_PATH) . 'social/profile.php?u=' . $user_id; if (isset($user['extra'])) { $result['extra'] = $user['extra']; } return $result; }
/** * @param int $userid */ public static function display_header_user($userid) { $select_cat = intval($_GET['selectcat']); $user_id = $userid; $user = api_get_user_info($user_id); $catcourse = Category::load($select_cat); $scoredisplay = ScoreDisplay::instance(); $scorecourse = $catcourse[0]->calc_score($user_id); // generating the total score for a course $allevals = $catcourse[0]->get_evaluations($user_id, true); $alllinks = $catcourse[0]->get_links($user_id, true); $evals_links = array_merge($allevals, $alllinks); $item_value = 0; $item_total = 0; for ($count = 0; $count < count($evals_links); $count++) { $item = $evals_links[$count]; $score = $item->calc_score($user_id); $my_score_denom = $score[1] == 0 ? 1 : $score[1]; $item_value += $score[0] / $my_score_denom * $item->get_weight(); $item_total += $item->get_weight(); //$row[] = $scoredisplay->display_score($score,SCORE_DIV_PERCENT); } $item_value = number_format($item_value, 2, '.', ' '); $total_score = array($item_value, $item_total); $scorecourse_display = $scoredisplay->display_score($total_score, SCORE_DIV_PERCENT); //$scorecourse_display = (isset($scorecourse) ? $scoredisplay->display_score($scorecourse,SCORE_AVERAGE) : get_lang('NoResultsAvailable')); $cattotal = Category::load(0); $scoretotal = $cattotal[0]->calc_score($user_id); $scoretotal_display = isset($scoretotal) ? $scoredisplay->display_score($scoretotal, SCORE_PERCENT) : get_lang('NoResultsAvailable'); $imageUrl = UserManager::getUserPicture($userid); $info = '<div class="row"><div class="col-md-3">'; $info .= '<div class="thumbnail"><img src="' . $imageUrl . '" /></div>'; $info .= '</div>'; $info .= '<div class="col-md-6">'; $info .= get_lang('Name') . ' : <a target="_blank" href="' . api_get_path(WEB_CODE_PATH) . 'social/profile.php?u=' . $userid . '"> ' . $user['complete_name'] . '</a><br />'; if (api_get_setting('show_email_addresses') == 'true') { $info .= get_lang('Email') . ' : <a href="mailto:' . $user['email'] . '">' . $user['email'] . '</a><br />'; } $info .= get_lang('TotalUser') . ' : <b>' . $scorecourse_display . '</b>'; $info .= '</div>'; $info .= '</div>'; echo $info; }
} $show = isset($_GET['show']) ? '&show=' . Security::remove_XSS($_GET['show']) : ''; if (isset($_GET['type']) && $_GET['type'] == 'extended') { $actions .= '<a href="profile.php?type=reduced' . $show . '">' . Display::return_icon('edit.png', get_lang('EditNormalProfile'), '', 16) . '</a>'; } else { $actions .= '<a href="profile.php?type=extended' . $show . '">' . Display::return_icon('edit.png', get_lang('EditExtendProfile'), '', 16) . '</a>'; } $actions .= '</div>'; } } $show_delete_account_button = api_get_setting('platform_unsubscribe_allowed') == 'true' ? true : false; $tpl = new Template(get_lang('ModifyProfile')); $tpl->assign('actions', $actions); SocialManager::setSocialUserBlock($tpl, $user_id, 'messages'); if (api_get_setting('social.allow_social_tool') == 'true') { SocialManager::setSocialUserBlock($tpl, api_get_user_id(), 'home'); $menu = SocialManager::show_social_menu('home', null, api_get_user_id(), false, $show_delete_account_button); $tpl->assign('social_menu_block', $menu); $tpl->assign('social_right_content', $form->returnForm()); $social_layout = $tpl->get_template('social/edit_profile.tpl'); $tpl->display($social_layout); } else { $bigImage = UserManager::getUserPicture(api_get_user_id(), USER_IMAGE_SIZE_BIG); $normalImage = UserManager::getUserPicture(api_get_user_id(), USER_IMAGE_SIZE_ORIGINAL); $imageToShow = '<div id="image-message-container">'; $imageToShow .= '<a class="expand-image" href="' . $bigImage . '" /><img src="' . $normalImage . '"></a>'; $imageToShow .= '</div>'; $content = $imageToShow . $form->returnForm(); $tpl->assign('content', $content); $tpl->display_one_col_template(); }
$info_course['tutor_name'] = implode(",", $info_tutor_name); } elseif ($session_coach_id != 0) { $session_coach_id = intval($session_info['id_coach']); $coach_info = api_get_user_info($session_coach_id); $info_course['tutor_name'] = $coach_info['complete_name']; } $coachs_name = $info_course['tutor_name']; $session_name = $session_info['name']; } // end $info_course = CourseManager::get_course_information($get_course_code); $table_title = Display::return_icon('user.png', get_lang('User'), array(), ICON_SIZE_SMALL) . $user_info['complete_name']; echo Display::page_subheader($table_title); echo '<table width="100%" border="0">'; echo '<tr>'; $userPicture = UserManager::getUserPicture($user_info['user_id']); echo '<img src="' . $userPicture . '" />'; echo '</td>'; ?> <td width="40%" valign="top"> <table width="100%" class="data_table"> <tr> <th><?php echo get_lang('Information'); ?> </th> </tr> <tr> <td><?php echo get_lang('Name') . ' : ' . $user_info['complete_name']; ?>
/** * @param string $message * @param array $_course * @param int $group_id * @param int $session_id * @param bool $preview */ function saveMessage($message, $userId, $_course, $session_id, $group_id, $preview = true) { $userInfo = api_get_user_info($userId); $fullName = $userInfo['complete_name']; $isMaster = (bool) api_is_course_admin(); $document_path = api_get_path(SYS_COURSE_PATH) . $_course['path'] . '/document'; if (!empty($group_id)) { $group_info = GroupManager::get_group_properties($group_id); $basepath_chat = $group_info['directory'] . '/chat_files'; } else { $basepath_chat = '/chat_files'; } $chat_path = $document_path . $basepath_chat . '/'; if (!is_dir($chat_path)) { if (is_file($chat_path)) { @unlink($chat_path); } } $date_now = date('Y-m-d'); $message = trim($message); $timeNow = date('d/m/y H:i:s'); if (!empty($group_id)) { $basename_chat = 'messages-' . $date_now . '_gid-' . $group_id; } elseif (!empty($session_id)) { $basename_chat = 'messages-' . $date_now . '_sid-' . $session_id; } else { $basename_chat = 'messages-' . $date_now; } if (!api_is_anonymous()) { if (!empty($message)) { Emojione\Emojione::$imagePathPNG = api_get_path(WEB_LIBRARY_PATH) . 'javascript/emojione/png/'; Emojione\Emojione::$ascii = true; // Parsing emojis $message = Emojione\Emojione::toImage($message); // Parsing text to understand markdown (code highlight) $message = MarkdownExtra::defaultTransform($message); // Security XSS $message = Security::remove_XSS($message); if ($preview == true) { return $message; } if (!file_exists($chat_path . $basename_chat . '.log.html')) { $doc_id = add_document($_course, $basepath_chat . '/' . $basename_chat . '.log.html', 'file', 0, $basename_chat . '.log.html'); api_item_property_update($_course, TOOL_DOCUMENT, $doc_id, 'DocumentAdded', $userId, $group_id, null, null, null, $session_id); api_item_property_update($_course, TOOL_DOCUMENT, $doc_id, 'invisible', $userId, $group_id, null, null, null, $session_id); item_property_update_on_folder($_course, $basepath_chat, $userId); } else { $doc_id = DocumentManager::get_document_id($_course, $basepath_chat . '/' . $basename_chat . '.log.html'); } $fp = fopen($chat_path . $basename_chat . '.log.html', 'a'); $userPhoto = UserManager::getUserPicture($userId, USER_IMAGE_SIZE_MEDIUM); $filePhoto = '<img class="chat-image" src="' . $userPhoto . '"/>'; if ($isMaster) { fputs($fp, '<div class="message-teacher"><div class="content-message"><div class="chat-message-block-name">' . $fullName . '</div><div class="chat-message-block-content">' . $message . '</div><div class="message-date">' . $timeNow . '</div></div><div class="icon-message"></div>' . $filePhoto . '</div>' . "\n"); } else { fputs($fp, '<div class="message-student">' . $filePhoto . '<div class="icon-message"></div><div class="content-message"><div class="chat-message-block-name">' . $fullName . '</div><div class="chat-message-block-content">' . $message . '</div><div class="message-date">' . $timeNow . '</div></div></div>' . "\n"); } fclose($fp); $chat_size = filesize($chat_path . $basename_chat . '.log.html'); update_existing_document($_course, $doc_id, $chat_size); item_property_update_on_folder($_course, $basepath_chat, $userId); } } }
$social_right_content .= get_lang('YouNeedToHaveFriendsInYourSocialNetwork'); } else { $social_right_content .= get_lang('YouAlreadyInviteAllYourContacts'); } $social_right_content .= '<div>'; $social_right_content .= '<a href="search.php">' . get_lang('TryAndFindSomeFriends') . '</a>'; $social_right_content .= '</div>'; } $form = new FormValidator('invitation', 'post', api_get_self() . '?id=' . $group_id); $form->addHidden('form_sent', 1); $form->addHidden('id', $group_id); $group_members_element = $form->addElement('advmultiselect', 'invitation', get_lang('Friends'), $nosessionUsersList, 'style="width: 280px;"'); $form->addButtonSave(get_lang('InviteUsersToGroup')); $social_right_content .= $form->returnForm(); // Current group members $members = $usergroup->get_users_by_group($group_id, false, array(GROUP_USER_PERMISSION_PENDING_INVITATION)); if (is_array($members) && count($members) > 0) { foreach ($members as &$member) { $image = UserManager::getUserPicture($member['user_id']); $member['image'] = '<img src="' . $image . '" width="50px" height="50px" />'; } $social_right_content .= '<h3>' . get_lang('UsersAlreadyInvited') . '</h3>'; $social_right_content .= Display::return_sortable_grid('invitation_profile', array(), $members, array('hide_navigation' => true, 'per_page' => 100), array(), false, array(true, false, true, true)); } $tpl = \Chamilo\CoreBundle\Framework\Container::getTwig(); SocialManager::setSocialUserBlock($tpl, api_get_user_id(), 'groups', $group_id); $social_menu_block = SocialManager::show_social_menu('member_list', $group_id); $tpl->addGlobal('social_menu_block', $social_menu_block); //$tpl->setHelp('Groups'); $tpl->addGlobal('social_right_content', $social_right_content); echo $tpl->render('@template_style/social/add_groups.html.twig');
/** * Get the users to display on the current page (fill the sortable-table) * @param int offset of first user to recover * @param int Number of users to get * @param int Column to sort on * @param string Order (ASC,DESC) * @return array A list of users with their data * @see SortableTable#get_table_data($from) */ function get_user_data($from, $number_of_items, $column, $direction) { $user_table = Database::get_main_table(TABLE_MAIN_USER); if (api_is_western_name_order()) { $col34 = "u.firstname AS col3,\n u.lastname AS col4,"; } else { $col34 = "u.lastname AS col3,\n u.firstname AS col4,"; } $sql = "SELECT\n u.user_id AS col0,\n u.official_code AS col2,\n {$col34}\n u.username AS col5,\n u.email AS col6,\n u.status AS col7,\n u.active AS col8,\n u.user_id AS col9 ,\n u.expiration_date AS exp\n FROM {$user_table} u "; if (isset($_GET['keyword'])) { $keyword = Database::escape_string(trim($_GET['keyword'])); $sql .= " WHERE (u.firstname LIKE '%{$keyword}%' OR\n u.lastname LIKE '%{$keyword}%' OR\n concat(u.firstname,' ',u.lastname) LIKE '%{$keyword}%' OR\n concat(u.lastname,' ',u.firstname) LIKE '%{$keyword}%' OR\n u.username LIKE '%{$keyword}%' OR\n u.official_code LIKE '%{$keyword}%' OR\n u.email LIKE '%{$keyword}%' )"; } if (!in_array($direction, array('ASC', 'DESC'))) { $direction = 'ASC'; } $column = intval($column); $from = intval($from); $number_of_items = intval($number_of_items); $sql .= " ORDER BY col{$column} {$direction} "; $sql .= " LIMIT {$from}, {$number_of_items}"; $res = Database::query($sql); $users = array(); while ($user = Database::fetch_row($res)) { $user_id = $user[0]; $userPicture = UserManager::getUserPicture($user_id); $photo = '<img src="' . $userPicture . '" alt="' . api_get_person_name($user[2], $user[3]) . '" title="' . api_get_person_name($user[2], $user[3]) . '" />'; $button = '<a href="javascript:void(0)" onclick="load_course_list(\'div_' . $user_id . '\',' . $user_id . ', \'' . $user[5] . '\')">' . Display::return_icon('view_more_stats.gif', get_lang('Info')) . '</a> '; $users[] = array($photo, $user_id, $user[2], $user[3], $user[4], $user[5], $button); } return $users; }
/** * Formats user information into a standard array * This function should be only used inside api_get_user_info() * * @param array Non-standard user array * @param bool $add_password * * @return array Standard user array */ function _api_format_user($user, $add_password = false) { $result = array(); $firstname = null; $lastname = null; if (isset($user['firstname']) && isset($user['lastname'])) { $firstname = $user['firstname']; $lastname = $user['lastname']; } elseif (isset($user['firstName']) && isset($user['lastName'])) { $firstname = isset($user['firstName']) ? $user['firstName'] : null; $lastname = isset($user['lastName']) ? $user['lastName'] : null; } $result['complete_name'] = api_get_person_name($firstname, $lastname); $result['complete_name_with_username'] = $result['complete_name']; if (!empty($user['username'])) { $result['complete_name_with_username'] = $result['complete_name'] . ' (' . $user['username'] . ')'; } $result['firstname'] = $firstname; $result['lastname'] = $lastname; // Kept for historical reasons $result['firstName'] = $firstname; $result['lastName'] = $lastname; $attributes = array('phone', 'picture_uri', 'official_code', 'status', 'active', 'auth_source', 'username', 'theme', 'language', 'creator_id', 'registration_date', 'hr_dept_id', 'expiration_date', 'last_login'); foreach ($attributes as $attribute) { $result[$attribute] = isset($user[$attribute]) ? $user[$attribute] : null; } if (isset($user['email'])) { $result['mail'] = isset($user['email']) ? $user['email'] : null; $result['email'] = isset($user['email']) ? $user['email'] : null; } else { $result['mail'] = isset($user['mail']) ? $user['mail'] : null; $result['email'] = isset($user['mail']) ? $user['mail'] : null; } $user_id = intval($user['user_id']); // Maintain the user_id index for backwards compatibility $result['user_id'] = $result['id'] = $user_id; $result['last_login'] = $user['last_login']; // Getting user avatar. $originalFile = UserManager::getUserPicture($user_id, USER_IMAGE_SIZE_ORIGINAL, $result); $smallFile = UserManager::getUserPicture($user_id, USER_IMAGE_SIZE_SMALL, $result); $result['avatar'] = $originalFile; $avatarString = explode('?', $originalFile); $result['avatar_no_query'] = reset($avatarString); $result['avatar_small'] = $smallFile; if (isset($user['user_is_online'])) { $result['user_is_online'] = $user['user_is_online'] == true ? 1 : 0; } if (isset($user['user_is_online_in_chat'])) { $result['user_is_online_in_chat'] = intval($user['user_is_online_in_chat']); } if ($add_password) { $result['password'] = $user['password']; } $result['profile_url'] = api_get_path(WEB_CODE_PATH) . 'social/profile.php?u=' . $user_id; if (isset($user['extra'])) { $result['extra'] = $user['extra']; } return $result; }
$friend_html = ''; $number_of_images = 8; $number_friends = count($friends); if ($number_friends != 0) { $number_loop = $number_friends / $number_of_images; $loop_friends = ceil($number_loop); $j = 0; for ($k = 0; $k < $loop_friends; $k++) { if ($j == $number_of_images) { $number_of_images = $number_of_images * 2; } while ($j < $number_of_images) { if (isset($friends[$j])) { $friend = $friends[$j]; $user_name = api_xml_http_response_encode($friend['firstName'] . ' ' . $friend['lastName']); $userPicture = UserManager::getUserPicture($friend['friend_user_id']); $friend_html .= ' <div class="col-md-3"> <div class="thumbnail text-center" id="div_' . $friends[$j]['friend_user_id'] . '"> <img src="' . $userPicture . '" class="img-responsive" id="imgfriend_' . $friend['friend_user_id'] . '" title="$user_name"> <div class="caption"> <h3> <a href="profile.php?u=' . $friend['friend_user_id'] . '">' . $user_name . '</a> </h3> <p> <button class="btn btn-danger" onclick="delete_friend(this)" id=img_' . $friend['friend_user_id'] . '> ' . get_lang('Delete') . ' </button> </p> </div> </div>
/** * Function wizard individual assignment * @author Juan Carlos Raña <*****@*****.**> */ public function auto_add_page_users($values) { $assignment_type = $values['assignment']; $session_id = $this->session_id; $groupId = api_get_group_id(); if ($groupId == 0) { //extract course members if (!empty($session_id)) { $a_users_to_add = CourseManager::get_user_list_from_course_code(api_get_course_id(), $session_id); } else { $a_users_to_add = CourseManager::get_user_list_from_course_code(api_get_course_id(), 0); } } else { //extract group members $subscribed_users = GroupManager::get_subscribed_users($groupId); $subscribed_tutors = GroupManager::get_subscribed_tutors($groupId); $a_users_to_add_with_duplicates = array_merge($subscribed_users, $subscribed_tutors); //remove duplicates $a_users_to_add = $a_users_to_add_with_duplicates; //array_walk($a_users_to_add, create_function('&$value,$key', '$value = json_encode($value);')); $a_users_to_add = array_unique($a_users_to_add); //array_walk($a_users_to_add, create_function('&$value,$key', '$value = json_decode($value, true);')); } $all_students_pages = array(); // Data about teacher $userId = api_get_user_id(); $userinfo = api_get_user_info($userId); $username = api_htmlentities(sprintf(get_lang('LoginX'), $userinfo['username'], ENT_QUOTES)); $name = $userinfo['complete_name'] . " - " . $username; $photo = '<img src="' . $userinfo['avatar'] . '" alt="' . $name . '" width="40" height="50" align="top" title="' . $name . '" />'; // teacher assignment title $title_orig = $values['title']; // teacher assignment reflink $link2teacher = $values['title'] = $title_orig . "_uass" . $userId; // first: teacher name, photo, and assignment description (original content) $content_orig_A = '<div align="center" style="background-color: #F5F8FB; border:solid; border-color: #E6E6E6"> <table border="0"> <tr><td style="font-size:24px">' . get_lang('AssignmentDesc') . '</td></tr> <tr><td>' . $photo . '<br />' . Display::tag('span', api_get_person_name($userinfo['firstname'], $userinfo['lastname']), array('title' => $username)) . '</td></tr> </table></div>'; $content_orig_B = '<br/><div align="center" style="font-size:24px">' . get_lang('AssignmentDescription') . ': ' . $title_orig . '</div><br/>' . $_POST['content']; //Second: student list (names, photo and links to their works). //Third: Create Students work pages. foreach ($a_users_to_add as $o_user_to_add) { if ($o_user_to_add['user_id'] != $userId) { // except that puts the task $assig_user_id = $o_user_to_add['user_id']; // identifies each page as created by the student, not by teacher $userPicture = UserManager::getUserPicture($assig_user_id); $username = api_htmlentities(sprintf(get_lang('LoginX'), $o_user_to_add['username'], ENT_QUOTES)); $name = api_get_person_name($o_user_to_add['firstname'], $o_user_to_add['lastname']) . " . " . $username; $photo = '<img src="' . $userPicture . '" alt="' . $name . '" width="40" height="50" align="bottom" title="' . $name . '" />'; $is_tutor_of_group = GroupManager::is_tutor_of_group($assig_user_id, $groupId); //student is tutor $is_tutor_and_member = GroupManager::is_tutor_of_group($assig_user_id, $groupId) && GroupManager::is_subscribed($assig_user_id, $groupId); // student is tutor and member if ($is_tutor_and_member) { $status_in_group = get_lang('GroupTutorAndMember'); } else { if ($is_tutor_of_group) { $status_in_group = get_lang('GroupTutor'); } else { $status_in_group = " "; //get_lang('GroupStandardMember') } } if ($assignment_type == 1) { $values['title'] = $title_orig; $values['content'] = '<div align="center" style="background-color: #F5F8FB; border:solid; border-color: #E6E6E6"> <table border="0"> <tr><td style="font-size:24px">' . get_lang('AssignmentWork') . '</td></tr> <tr><td>' . $photo . '<br />' . $name . '</td></tr></table> </div>[[' . $link2teacher . ' | ' . get_lang('AssignmentLinktoTeacherPage') . ']] '; //If $content_orig_B is added here, the task written by the professor was copied to the page of each student. TODO: config options // AssignmentLinktoTeacherPage $all_students_pages[] = '<li>' . Display::tag('span', strtoupper($o_user_to_add['lastname']) . ', ' . $o_user_to_add['firstname'], array('title' => $username)) . ' [[' . $_POST['title'] . "_uass" . $assig_user_id . ' | ' . $photo . ']] ' . $status_in_group . '</li>'; //don't change this line without guaranteeing that users will be ordered by last names in the following format (surname, name) $values['assignment'] = 2; } $this->assig_user_id = $assig_user_id; self::save_new_wiki($values); } } foreach ($a_users_to_add as $o_user_to_add) { if ($o_user_to_add['user_id'] == $userId) { $assig_user_id = $o_user_to_add['user_id']; if ($assignment_type == 1) { $values['title'] = $title_orig; $values['comment'] = get_lang('AssignmentDesc'); sort($all_students_pages); $values['content'] = $content_orig_A . $content_orig_B . '<br/> <div align="center" style="font-size:18px; background-color: #F5F8FB; border:solid; border-color:#E6E6E6"> ' . get_lang('AssignmentLinkstoStudentsPage') . ' </div><br/> <div style="background-color: #F5F8FB; border:solid; border-color:#E6E6E6"> <ol>' . implode($all_students_pages) . '</ol> </div> <br/>'; $values['assignment'] = 1; } $this->assig_user_id = $assig_user_id; self::save_new_wiki($values); } } }
exit; break; } } Display::display_header($tool_name); echo '<div class="actions"> <a href="' . api_get_path(WEB_CODE_PATH) . 'mySpace/myStudents.php?student=' . intval($_GET['user_id']) . '" title="' . get_lang('Reporting') . '">' . Display::return_icon('statistics.png', get_lang('Reporting'), '', ICON_SIZE_MEDIUM) . ' </a> ' . $login_as_icon . ' ' . $editUser . ' ' . $exportLink . ' ' . $vCardExportLink . ' </div>'; echo Display::page_header($tool_name); $fullUrlBig = UserManager::getUserPicture($user['user_id'], USER_IMAGE_SIZE_BIG); $fullUrl = UserManager::getUserPicture($user['user_id'], USER_IMAGE_SIZE_ORIGINAL); echo '<div class="row">'; echo '<div class="col-md-2">'; echo '<a class="expand-image" href="' . $fullUrlBig . '">' . '<img src="' . $fullUrl . '" /></a><br />'; echo '</div>'; echo $message; echo '<div class="col-md-5">'; echo $userInformation; echo '</div>'; echo '<div class="col-md-5">'; echo $trackingInformation; echo '</div>'; echo '</div>'; echo Display::page_subheader(get_lang('SessionList')); echo $sessionInformation; echo $courseInformation;
/** * @param array $work * @return array */ function getWorkComments($work) { $commentTable = Database::get_course_table(TABLE_STUDENT_PUBLICATION_ASSIGNMENT_COMMENT); $userTable = Database::get_main_table(TABLE_MAIN_USER); $courseId = intval($work['c_id']); $workId = intval($work['id']); if (empty($courseId) || empty($workId)) { return array(); } $sql = "SELECT\n c.id, c.user_id, u.firstname, u.lastname, u.username, u.picture_uri\n FROM {$commentTable} c\n INNER JOIN {$userTable} u ON (u.user_id = c.user_id)\n WHERE c_id = {$courseId} AND work_id = {$workId}\n ORDER BY sent_at\n "; $result = Database::query($sql); $comments = Database::store_result($result, 'ASSOC'); if (!empty($comments)) { foreach ($comments as &$comment) { $comment['picture'] = UserManager::getUserPicture($comment['user_id']); $commentInfo = getWorkComment($comment['id']); if (!empty($commentInfo)) { $comment = array_merge($comment, $commentInfo); } } } return $comments; }
$fieldTagsRepo = $entityManager->getRepository('ChamiloCoreBundle:ExtraFieldRelTag'); $userRepo = $entityManager->getRepository('ChamiloUserBundle:User'); $sequenceResourceRepo = $entityManager->getRepository('ChamiloCoreBundle:SequenceResource'); $tagField = $fieldsRepo->findOneBy(['extraFieldType' => ExtraField::COURSE_FIELD_TYPE, 'variable' => 'tags']); $courseValues = new ExtraFieldValue('course'); $userValues = new ExtraFieldValue('user'); $sessionValues = new ExtraFieldValue('session'); foreach ($sessionCourses as $sessionCourse) { $courseTags = []; if (!is_null($tagField)) { $courseTags = $fieldTagsRepo->getTags($tagField, $sessionCourse->getId()); } $courseCoaches = $userRepo->getCoachesForSessionCourse($session, $sessionCourse); $coachesData = []; foreach ($courseCoaches as $courseCoach) { $coachData = ['complete_name' => $courseCoach->getCompleteName(), 'image' => UserManager::getUserPicture($courseCoach->getId(), USER_IMAGE_SIZE_ORIGINAL), 'extra_fields' => $userValues->getAllValuesForAnItem($courseCoach->getId(), true)]; $coachesData[] = $coachData; } $courseDescriptionTools = $entityManager->getRepository('ChamiloCourseBundle:CCourseDescription')->findBy(['cId' => $sessionCourse->getId(), 'sessionId' => 0], ['id' => 'DESC', 'descriptionType' => 'ASC']); $courseDescription = $courseObjectives = $courseTopics = null; foreach ($courseDescriptionTools as $descriptionTool) { switch ($descriptionTool->getDescriptionType()) { case CCourseDescription::TYPE_DESCRIPTION: $courseDescription = $descriptionTool; break; case CCourseDescription::TYPE_OBJECTIVES: $courseObjectives = $descriptionTool; break; case CCourseDescription::TYPE_TOPICS: $courseTopics = $descriptionTool; break;
if (in_array($user_role, array(GROUP_USER_PERMISSION_ADMIN, GROUP_USER_PERMISSION_MODERATOR))) { $user['link'] = '<a href="group_members.php?id=' . $group_id . '&u=' . $user['id'] . '&action=delete">' . Display::return_icon('delete.png', get_lang('DeleteFromGroup')) . '</a>' . '<a href="group_members.php?id=' . $group_id . '&u=' . $user['id'] . '&action=set_moderator">' . Display::return_icon('social_moderator_add.png', get_lang('AddModerator')) . '</a>'; } break; case GROUP_USER_PERMISSION_PENDING_INVITATION: $user['link'] = '<a href="group_members.php?id=' . $group_id . '&u=' . $user['id'] . '&action=add">' . Display::return_icon('pending_invitation.png', get_lang('PendingInvitation')) . '</a>'; break; case GROUP_USER_PERMISSION_MODERATOR: $user['link'] = Display::return_icon('social_group_moderator.png', get_lang('Moderator')); //only group admin can manage moderators if ($user_role == GROUP_USER_PERMISSION_ADMIN) { $user['link'] .= '<a href="group_members.php?id=' . $group_id . '&u=' . $user['id'] . '&action=delete_moderator">' . Display::return_icon('social_moderator_delete.png', get_lang('DeleteModerator')) . '</a>'; } break; } $userPicture = UserManager::getUserPicture($user['id']); $user['image'] = '<img src="' . $userPicture . '" width="50px" height="50px" />'; $new_member_list[] = $user; } if (count($new_member_list) > 0) { $social_right_content .= Display::return_sortable_grid('list_members', array(), $new_member_list, array('hide_navigation' => true, 'per_page' => 100), array(), false, array(true, false, true, true, false, true, true)); } $tpl = \Chamilo\CoreBundle\Framework\Container::getTwig(); //$tpl->setHelp('Groups'); $tpl->addGlobal('social_avatar_block', $social_avatar_block); $tpl->addGlobal('social_menu_block', $social_menu_block); $tpl->addGlobal('social_right_content', $social_right_content); $tpl->addGlobal('social_search_block', ''); $tpl->addGlobal('social_skill_block', ''); $tpl->addGlobal('social_group_block', ''); $tpl->addGlobal('social_auto_extend_link', '');
/** * Get the users to display on the current page (fill the sortable-table) * @param int offset of first user to recover * @param int Number of users to get * @param int Column to sort on * @param string Order (ASC,DESC) * @see SortableTable#get_table_data($from) */ function get_user_data($from, $number_of_items, $column, $direction) { $sql = prepare_user_sql_query(false); /* @todo will not work because now we use the salt field $checkPassStrength = isset($_GET['check_easy_passwords']) && $_GET['check_easy_passwords'] == 1 ? true : false; if ($checkPassStrength) { $easyPasswordList = api_get_easy_password_list(); $easyPasswordList = array_map('api_get_encrypted_password', $easyPasswordList); $easyPasswordList = array_map(array('Database', 'escape_string'), $easyPasswordList); $easyPassword = implode("' OR password LIKE '", $easyPasswordList); $sql .= "AND password LIKE '$easyPassword' "; }*/ if (!in_array($direction, array('ASC', 'DESC'))) { $direction = 'ASC'; } $column = intval($column); $from = intval($from); $number_of_items = intval($number_of_items); $preventSessionAdminsToManageAllUsers = api_get_setting('prevent_session_admins_to_manage_all_users'); if (api_is_session_admin() && $preventSessionAdminsToManageAllUsers === 'true') { $sql .= " WHERE u.creator_id = " . api_get_user_id(); } $sql .= " ORDER BY col{$column} {$direction} "; $sql .= " LIMIT {$from},{$number_of_items}"; $res = Database::query($sql); $users = array(); $t = time(); while ($user = Database::fetch_row($res)) { $userPicture = UserManager::getUserPicture($user[0], USER_IMAGE_SIZE_SMALL); $photo = '<img src="' . $userPicture . '" width="22" height="22" alt="' . api_get_person_name($user[2], $user[3]) . '" title="' . api_get_person_name($user[2], $user[3]) . '" />'; if ($user[7] == 1 && !empty($user[10])) { // check expiration date $expiration_time = convert_sql_date($user[10]); // if expiration date is passed, store a special value for active field if ($expiration_time < $t) { $user[7] = '-1'; } } // forget about the expiration date field $users[] = array($user[0], $photo, $user[1], $user[2], $user[3], $user[4], $user[5], $user[6], $user[7], api_get_local_time($user[9]), $user[0]); } return $users; }
/** * @param int $user_id * @param $link_shared * @param $show_full_profile * @return string */ public static function listMyFriendsBlock($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); $number_of_images = 30; $number_friends = count($friends); $friendHtml = ''; if ($number_friends != 0) { $friendHtml .= '<div class="list-group">'; $j = 1; for ($k = 0; $k < $number_friends; $k++) { if ($j > $number_of_images) { break; } if (isset($friends[$k])) { $friend = $friends[$k]; $name_user = api_get_person_name($friend['firstName'], $friend['lastName']); $user_info_friend = api_get_user_info($friend['friend_user_id'], true); if ($user_info_friend['user_is_online']) { $statusIcon = Display::return_icon('statusonline.png', get_lang('Online')); $status = 1; } else { $statusIcon = Display::return_icon('statusoffline.png', get_lang('Offline')); $status = 0; } $friendAvatarMedium = UserManager::getUserPicture($friend['friend_user_id'], USER_IMAGE_SIZE_MEDIUM); $friendAvatarSmall = UserManager::getUserPicture($friend['friend_user_id'], USER_IMAGE_SIZE_SMALL); $friend_avatar = '<img src="' . $friendAvatarMedium . '" id="imgfriend_' . $friend['friend_user_id'] . '" title="' . $name_user . '" class="user-image"/>'; $showLinkToChat = api_is_global_chat_enabled() && $friend['friend_user_id'] != api_get_user_id(); if ($showLinkToChat) { $friendHtml .= '<a onclick="javascript:chatWith(\'' . $friend['friend_user_id'] . '\', \'' . $name_user . '\', \'' . $status . '\',\'' . $friendAvatarSmall . '\')" href="javascript:void(0);" class="list-group-item">'; $friendHtml .= $friend_avatar . ' <span class="username">' . $name_user . '</span>'; $friendHtml .= '<span class="status">' . $statusIcon . '</span>'; } else { $link_shared = empty($link_shared) ? '' : '&' . $link_shared; $friendHtml .= '<a href="profile.php?' . 'u=' . $friend['friend_user_id'] . $link_shared . '" class="list-group-item">'; $friendHtml .= $friend_avatar . ' <span class="username-all">' . $name_user . '</span>'; } $friendHtml .= '</a>'; } $j++; } $friendHtml .= '</div>'; } else { $friendHtml .= '<div class="help">' . get_lang('NoFriendsInYourContactList') . ' ' . '<a href="' . api_get_path(WEB_PATH) . 'whoisonline.php"><em class="fa fa-search"></em> ' . get_lang('TryAndFindSomeFriends') . '</a></div>'; } return $friendHtml; }
?> <?php echo get_lang('Connected'); ?> </div> <div class="scrollbar"><div class="track"><div class="thumb"><div class="end"></div></div></div></div> <div class="viewport"><div id="hidden" class="overview"> <ul class="profile list-group"> <?php foreach ($users as &$user) { if (empty($session_id)) { $status = $user['status']; } else { $status = CourseManager::is_course_teacher($user['user_id'], api_get_course_id()) ? 1 : 5; } $fileUrl = UserManager::getUserPicture($user['user_id'], USER_IMAGE_SIZE_MEDIUM); $url_user_profile = api_get_path(WEB_CODE_PATH) . 'social/profile.php?u=' . $user['user_id'] . '&'; ?> <li class="list-group-item"> <img src="<?php echo $fileUrl; ?> " border="0" width="50" alt="" class="user-image-chat" /> <div class="user-name"> <a href="<?php echo $url_user_profile; ?> " target="_blank"> <?php echo api_get_person_name($user['firstname'], $user['lastname']); ?>
/** * @return null|string */ public function return_user_image_block() { $html = null; if (!api_is_anonymous()) { $userPicture = UserManager::getUserPicture(api_get_user_id()); $content = null; if (api_get_setting('social.allow_social_tool') == 'true') { $content .= '<a style="text-align:center" href="' . api_get_path(WEB_PATH) . 'main/social/home.php"> <img class="img-circle" src="' . $userPicture . '" ></a>'; } else { $content .= '<a style="text-align:center" href="' . api_get_path(WEB_PATH) . 'main/auth/profile.php"> <img class="img-circle" title="' . get_lang('EditProfile') . '" src="' . $userPicture . '" ></a>'; } $html = self::show_right_block(null, $content, 'user_image_block', array('style' => 'text-align:center;')); } return $html; }
/** * Gets the group's members * @param int group id * @param bool show image or not of the group * @param array list of relation type use constants * @param int from value * @param int limit * @param array image configuration, i.e array('height'=>'20px', 'size'=> '20px') * @return array list of users in a group */ public function get_users_by_group($group_id, $with_image = false, $relation_type = array(), $from = null, $limit = null, $image_conf = array('size' => USER_IMAGE_SIZE_MEDIUM, 'height' => 80)) { $table_group_rel_user = $this->usergroup_rel_user_table; $tbl_user = Database::get_main_table(TABLE_MAIN_USER); $group_id = intval($group_id); if (empty($group_id)) { return array(); } $limit_text = ''; if (isset($from) && isset($limit)) { $from = intval($from); $limit = intval($limit); $limit_text = "LIMIT {$from}, {$limit}"; } if (count($relation_type) == 0) { $where_relation_condition = ''; } else { $new_relation_type = array(); foreach ($relation_type as $rel) { $rel = intval($rel); $new_relation_type[] = "'{$rel}'"; } $relation_type = implode(',', $new_relation_type); if (!empty($relation_type)) { $where_relation_condition = "AND gu.relation_type IN ({$relation_type}) "; } } $sql = "SELECT picture_uri as image, u.id, u.firstname, u.lastname, relation_type\n \t\t FROM {$tbl_user} u\n \t\t INNER JOIN {$table_group_rel_user} gu\n \t\t\tON (gu.user_id = u.id)\n \t\t\tWHERE\n \t\t\t gu.usergroup_id= {$group_id}\n \t\t\t {$where_relation_condition}\n \t\t\tORDER BY relation_type, firstname\n \t\t\t{$limit_text}"; $result = Database::query($sql); $array = array(); while ($row = Database::fetch_array($result, 'ASSOC')) { if ($with_image) { $userInfo = api_get_user_info($row['id']); $userPicture = UserManager::getUserPicture($row['id']); $row['image'] = '<img src="' . $userPicture . '" />'; $row['user_info'] = $userInfo; } $array[$row['id']] = $row; } return $array; }
if ($platform_admin == 1) { UserManager::add_user_as_admin($userEntity); } else { UserManager::remove_user_admin($userEntity); } } $extraFieldValue = new ExtraFieldValue('user'); $extraFieldValue->saveFieldValues($user); $tok = Security::get_token(); Display::addFlash(Display::return_message(get_lang('UserUpdated'))); header('Location: user_list.php?sec_token=' . $tok); exit; } } $message = null; if ($error_drh) { $err_msg = get_lang('StatusCanNotBeChangedToHumanResourcesManager'); $message = Display::return_message($err_msg, 'error'); } $content = null; $bigImage = UserManager::getUserPicture($user_id, USER_IMAGE_SIZE_BIG); $normalImage = UserManager::getUserPicture($user_id, USER_IMAGE_SIZE_ORIGINAL); $content .= '<div class="row">'; $content .= '<div class="col-md-10">'; // Display form $content .= $form->returnForm(); $content .= '</div>'; $content .= '<div class="col-md-2">'; $content .= '<a class="thumbnail expand-image" href="' . $bigImage . '" /><img src="' . $normalImage . '"></a>'; $content .= '</div>'; echo $content;