function search_users($needle, $type) { global $_configuration, $tbl_access_url_rel_user, $tbl_user, $user_anonymous, $current_user_id, $user_id; $xajax_response = new XajaxResponse(); $return = ''; if (!empty($needle) && !empty($type)) { // xajax send utf8 datas... datas in db can be non-utf8 datas $charset = api_get_system_encoding(); $needle = api_convert_encoding($needle, $charset, 'utf-8'); $assigned_users_to_hrm = UserManager::get_users_followed_by_drh($user_id); $assigned_users_id = array_keys($assigned_users_to_hrm); $without_assigned_users = ''; if (count($assigned_users_id) > 0) { $without_assigned_users = " AND user.user_id NOT IN(" . implode(',', $assigned_users_id) . ")"; } if ($_configuration['multiple_access_urls']) { $sql = "SELECT user.user_id, username, lastname, firstname FROM {$tbl_user} user LEFT JOIN {$tbl_access_url_rel_user} au ON (au.user_id = user.user_id)\n\t\t\tWHERE " . (api_sort_by_first_name() ? 'firstname' : 'lastname') . " LIKE '{$needle}%' AND status NOT IN(" . DRH . ", " . SESSIONADMIN . ") AND user.user_id NOT IN ({$user_anonymous}, {$current_user_id}, {$user_id}) {$without_assigned_users} AND access_url_id = " . api_get_current_access_url_id() . ""; } else { $sql = "SELECT user_id, username, lastname, firstname FROM {$tbl_user} user\n\t\t\tWHERE " . (api_sort_by_first_name() ? 'firstname' : 'lastname') . " LIKE '{$needle}%' AND status NOT IN(" . DRH . ", " . SESSIONADMIN . ") AND user_id NOT IN ({$user_anonymous}, {$current_user_id}, {$user_id}) {$without_assigned_users}"; } $rs = Database::query($sql); $return .= '<select id="origin" name="NoAssignedUsersList[]" multiple="multiple" size="20" style="width:340px;">'; while ($user = Database::fetch_array($rs)) { $person_name = api_get_person_name($user['firstname'], $user['lastname']); $return .= '<option value="' . $user['user_id'] . '" title="' . htmlspecialchars($person_name, ENT_QUOTES) . '">' . $person_name . ' (' . $user['username'] . ')</option>'; } $return .= '</select>'; $xajax_response->addAssign('ajax_list_users_multiple', 'innerHTML', api_utf8_encode($return)); } return $xajax_response; }
/** * Constructor */ public function __construct($user_id) { $this->user_id = $user_id; $this->path = 'block_student'; if ($this->is_block_visible_for_user($user_id)) { $this->students = UserManager::get_users_followed_by_drh($user_id, STUDENT); } }
/** * Controller */ public function __construct($user_id) { $this->user_id = $user_id; $this->path = 'block_teacher'; if ($this->is_block_visible_for_user($user_id)) { $this->teachers = UserManager::get_users_followed_by_drh($user_id, COURSEMANAGER); } }
/** * Constructor */ public function __construct($user_id) { $this->user_id = $user_id; $this->path = 'block_student'; if ($this->is_block_visible_for_user($user_id)) { /*if (api_is_platform_admin()) { $this->students = UserManager::get_user_list(array('status' => STUDENT)); } else {*/ $this->students = UserManager::get_users_followed_by_drh($user_id, STUDENT); //} } }
/** * Controller */ public function __construct($user_id) { $this->user_id = $user_id; $this->path = 'block_teacher'; if ($this->is_block_visible_for_user($user_id)) { /*if (api_is_platform_admin()) { $this->teachers = UserManager::get_user_list(array('status' => COURSEMANAGER)); } else {*/ $this->teachers = UserManager::get_users_followed_by_drh($user_id, COURSEMANAGER); //} } }
function search_users($needle, $type) { global $tbl_access_url_rel_user, $tbl_user, $user_anonymous, $current_user_id, $user_id, $userStatus; $xajax_response = new xajaxResponse(); $return = ''; if (!empty($needle) && !empty($type)) { $assigned_users_to_hrm = array(); switch ($userStatus) { case DRH: //no break; //no break; case PLATFORM_ADMIN: $assigned_users_to_hrm = UserManager::get_users_followed_by_drh($user_id); break; case STUDENT_BOSS: $assigned_users_to_hrm = UserManager::getUsersFollowedByStudentBoss($user_id); break; } $assigned_users_id = array_keys($assigned_users_to_hrm); $without_assigned_users = ''; $westernOrder = api_is_western_name_order(); if ($westernOrder) { $order_clause = " ORDER BY firstname, lastname"; } else { $order_clause = " ORDER BY lastname, firstname"; } if (count($assigned_users_id) > 0) { $without_assigned_users = " AND user.user_id NOT IN(" . implode(',', $assigned_users_id) . ")"; } if (api_is_multiple_url_enabled()) { $sql = "SELECT user.user_id, username, lastname, firstname\n FROM {$tbl_user} user\n LEFT JOIN {$tbl_access_url_rel_user} au ON (au.user_id = user.user_id)\n WHERE\n " . (api_sort_by_first_name() ? 'firstname' : 'lastname') . " LIKE '{$needle}%' AND\n status NOT IN(" . DRH . ", " . SESSIONADMIN . ", " . STUDENT_BOSS . ") AND\n user.user_id NOT IN ({$user_anonymous}, {$current_user_id}, {$user_id})\n {$without_assigned_users} AND\n access_url_id = " . api_get_current_access_url_id() . "\n {$order_clause}\n "; } else { $sql = "SELECT user_id, username, lastname, firstname\n FROM {$tbl_user} user\n WHERE\n " . (api_sort_by_first_name() ? 'firstname' : 'lastname') . " LIKE '{$needle}%' AND\n status NOT IN(" . DRH . ", " . SESSIONADMIN . ", " . STUDENT_BOSS . ") AND\n user_id NOT IN ({$user_anonymous}, {$current_user_id}, {$user_id})\n {$without_assigned_users}\n {$order_clause}\n "; } $rs = Database::query($sql); $xajax_response->addAssign('ajax_list_users_multiple', 'innerHTML', api_utf8_encode($return)); if ($type == 'single') { $tbl_user_rel_access_url = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER); $access_url_id = api_get_current_access_url_id(); $sql = 'SELECT user.user_id, username, lastname, firstname FROM ' . $tbl_user . ' user INNER JOIN ' . $tbl_user_rel_access_url . ' url_user ON (url_user.user_id=user.user_id) WHERE access_url_id = ' . $access_url_id . ' AND ( username LIKE "' . $needle . '%" OR firstname LIKE "' . $needle . '%" OR lastname LIKE "' . $needle . '%" ) AND '; switch ($userStatus) { case DRH: $sql .= " user.status <> 6 AND user.status <> " . DRH; break; case STUDENT_BOSS: $sql .= " user.status <> 6 AND user.status <> " . STUDENT_BOSS; break; } $sql .= " {$order_clause} LIMIT 11"; $rs = Database::query($sql); $i = 0; while ($user = Database::fetch_array($rs)) { $i++; if ($i <= 10) { $person_name = api_get_person_name($user['firstname'], $user['lastname']); $return .= '<a href="javascript: void(0);" onclick="javascript: add_user_to_user(\'' . $user['user_id'] . '\',\'' . $person_name . ' (' . $user['username'] . ')' . '\')">' . $person_name . ' (' . $user['username'] . ')</a><br />'; } else { $return .= '...<br />'; } } $xajax_response->addAssign('ajax_list_users_single', 'innerHTML', api_utf8_encode($return)); } else { $return .= '<select id="origin" class="form-control" name="NoAssignedUsersList[]" multiple="multiple" size="15" ">'; while ($user = Database::fetch_array($rs)) { $person_name = api_get_person_name($user['firstname'], $user['lastname']); $return .= '<option value="' . $user['user_id'] . '" title="' . htmlspecialchars($person_name, ENT_QUOTES) . '">' . $person_name . ' (' . $user['username'] . ')</option>'; } $return .= '</select>'; $xajax_response->addAssign('ajax_list_users_multiple', 'innerHTML', api_utf8_encode($return)); } } return $xajax_response; }
if (api_is_drh()) { if (api_drh_can_access_all_session_content()) { $userList = SessionManager::getAllUsersFromCoursesFromAllSessionFromStatus('drh_all', api_get_user_id()); if (!empty($userList)) { foreach ($userList as $user) { $userIdList[] = $user['user_id']; } } $courseList = SessionManager::getAllCoursesFollowedByUser(api_get_user_id(), null); if (!empty($courseList)) { foreach ($courseList as $course) { $courseCodeList[] = $course['code']; } } } else { $userList = UserManager::get_users_followed_by_drh(api_get_user_id()); if (!empty($userList)) { $userIdList = array_keys($userList); } $courseList = CourseManager::get_courses_followed_by_drh(api_get_user_id()); if (!empty($courseList)) { $courseCodeList = array_keys($courseList); } } if (empty($userIdList) || empty($courseCodeList)) { exit; } } elseif (api_is_student_boss()) { $searchByGroups = true; } elseif (api_is_platform_admin()) { if ($sessionId == -1) {
} echo '</div>'; $sessions = array(); if (empty($session_id)) { // Getting courses followed by a coach (No session courses) $courses = CourseManager::get_course_list_as_coach($user_id, false); if (isset($courses[0])) { $courses = $courses[0]; } //Getting students from courses and courses in sessions (To show the total students that the user follows) $students = CourseManager::get_user_list_from_courses_as_coach($user_id); // Sessions for the coach $sessions = SessionManager::get_sessions_coached_by_user($user_id); //If is drh if ($is_drh) { $students = array_keys(UserManager::get_users_followed_by_drh($user_id, STUDENT)); $courses_of_the_platform = CourseManager::get_courses_followed_by_drh($user_id); foreach ($courses_of_the_platform as $course) { $courses[$course['real_id']] = $course['real_id']; } $sessions = SessionManager::get_sessions_followed_by_drh($user_id); } //Courses for the user $count_courses = count($courses); //Sessions for the user $count_sessions = count($sessions); //Students $nb_students = count($students); $total_time_spent = 0; $total_courses = 0; $avg_total_progress = 0;
/** * Get teachers followed by a user * @param int $userId * @param int $active * @param string $lastConnectionDate * @param bool $getCount * @param array $sessionIdList * @return array|int */ public static function getTeacherTracking($userId, $active = 1, $lastConnectionDate = null, $getCount = false, $sessionIdList = array()) { $teacherListId = array(); if (api_is_drh() || api_is_platform_admin()) { // Followed teachers by drh if (api_drh_can_access_all_session_content()) { if (empty($sessionIdList)) { $sessions = SessionManager::get_sessions_followed_by_drh($userId); $sessionIdList = array(); foreach ($sessions as $session) { $sessionIdList[] = $session['id']; } } $sessionIdList = array_map('intval', $sessionIdList); $sessionToString = implode("', '", $sessionIdList); $course = Database::get_main_table(TABLE_MAIN_COURSE); $sessionCourse = Database::get_main_table(TABLE_MAIN_SESSION_COURSE); $courseUser = Database::get_main_table(TABLE_MAIN_COURSE_USER); // Select the teachers. $sql = "SELECT DISTINCT(cu.user_id) FROM {$course} c\n INNER JOIN {$sessionCourse} src ON c.id = src.c_id\n INNER JOIN {$courseUser} cu ON (cu.c_id = c.id)\n\t\t WHERE src.session_id IN ('{$sessionToString}') AND cu.status = 1"; $result = Database::query($sql); while ($row = Database::fetch_array($result, 'ASSOC')) { $teacherListId[$row['user_id']] = $row['user_id']; } } else { $teacherResult = UserManager::get_users_followed_by_drh($userId, COURSEMANAGER); foreach ($teacherResult as $userInfo) { $teacherListId[] = $userInfo['user_id']; } } } if (!empty($teacherListId)) { $tableUser = Database::get_main_table(TABLE_MAIN_USER); $select = "SELECT DISTINCT u.* "; if ($getCount) { $select = "SELECT count(DISTINCT(u.user_id)) as count"; } $sql = "{$select} FROM {$tableUser} u"; if (!empty($lastConnectionDate)) { $tableLogin = Database::get_main_table(TABLE_STATISTIC_TRACK_E_LOGIN); //$sql .= " INNER JOIN $tableLogin l ON (l.login_user_id = u.user_id) "; } $active = intval($active); $teacherListId = implode("','", $teacherListId); $where = " WHERE u.active = {$active} AND u.user_id IN ('{$teacherListId}') "; if (!empty($lastConnectionDate)) { $lastConnectionDate = Database::escape_string($lastConnectionDate); //$where .= " AND l.login_date <= '$lastConnectionDate' "; } $sql .= $where; $result = Database::query($sql); if (Database::num_rows($result)) { if ($getCount) { $row = Database::fetch_array($result); return $row['count']; } else { return Database::store_result($result, 'ASSOC'); } } } return 0; }
*/ ob_start(); // names of the language file that needs to be included $language_file = array('registration', 'index', 'trad4all', 'tracking', 'admin'); $cidReset = true; //require_once '../inc/global.inc.php'; require_once 'myspace.lib.php'; $this_section = SECTION_TRACKING; $nameTools = get_lang('Teachers'); api_block_anonymous_users(); $interbreadcrumb[] = array("url" => "index.php", "name" => get_lang('MySpace')); Display::display_header($nameTools); $formateurs = array(); if (api_is_drh() || api_is_platform_admin()) { // followed teachers by drh $formateurs = UserManager::get_users_followed_by_drh($_user['user_id'], COURSEMANAGER); $menu_items = array(); $menu_items[] = Display::url(Display::return_icon('stats.png', get_lang('MyStats'), '', ICON_SIZE_MEDIUM), api_get_path(WEB_CODE_PATH) . "auth/my_progress.php"); $menu_items[] = Display::url(Display::return_icon('user.png', get_lang('Students'), array(), 32), "index.php?view=drh_students&display=yourstudents"); $menu_items[] = Display::return_icon('teacher_na.png', get_lang('Trainers'), array(), 32); $menu_items[] = Display::url(Display::return_icon('course.png', get_lang('Courses'), array(), 32), 'course.php'); $menu_items[] = Display::url(Display::return_icon('session.png', get_lang('Sessions'), array(), 32), 'session.php'); echo '<div class="actions">'; $nb_menu_items = count($menu_items); if ($nb_menu_items > 1) { foreach ($menu_items as $key => $item) { echo $item; } } if (count($formateurs) > 0) { echo '<span style="float:right">';