//$scormData[$value['users_LOGIN']] = $value; } //$smarty -> assign("T_SCORM_DATA", $scormData); if (isset($_GET['ajax']) && $_GET['ajax'] == 'scormUsersTable') { isset($_GET['limit']) && eF_checkParameter($_GET['limit'], 'uint') ? $limit = $_GET['limit'] : ($limit = G_DEFAULT_TABLE_SIZE); if (isset($_GET['sort']) && eF_checkParameter($_GET['sort'], 'text')) { $sort = $_GET['sort']; isset($_GET['order']) && $_GET['order'] == 'desc' ? $order = 'desc' : ($order = 'asc'); } else { $sort = 'login'; } $scormData = eF_multiSort($scormData, $sort, $order); if ($_SESSION['s_type'] != 'administrator' && $_SESSION['s_current_branch']) { //this applies to branch urls $currentBranch = new EfrontBranch($_SESSION['s_current_branch']); $branchTreeUsers = array_keys($currentBranch->getBranchTreeUsers()); foreach ($scormData as $key => $value) { if ($value['type'] != 'global' && !in_array($value['users_LOGIN'], $branchTreeUsers)) { unset($scormData[$key]); } } $scormData = array_values($scormData); } $smarty->assign("T_USERS_SIZE", sizeof($scormData)); if (isset($_GET['filter'])) { $scormData = eF_filterData($scormData, $_GET['filter']); } if (isset($_GET['limit']) && eF_checkParameter($_GET['limit'], 'int')) { isset($_GET['offset']) && eF_checkParameter($_GET['offset'], 'int') ? $offset = $_GET['offset'] : ($offset = 0); $scormData = array_slice($scormData, $offset, $limit); }
/** * Get the list of users that are currently online * * This function is used to get a list of the users that are currently online * In addition, it logs out any inactive users, based on global setting * <br>Example: * <code> * $online = EfrontUser :: getUsersOnline(); * </code> * * @param boolean $userType Return only users of the basic type $user_type * @param int $interval The idle interval above which a user is logged out. If it's not specified, no logging out takes place * @return array The list of online users * @since 3.5.0 * @access public */ public static function getUsersOnline($interval = false) { $usersOnline = array(); //A user may have multiple active entries on the user_times table, one for system, one for unit etc. Pick the most recent $result = eF_getTableData("user_times,users", "users.login, users.name, users.surname, users.user_type, timestamp_now, session_timestamp, session_id", "users.login=user_times.users_LOGIN and session_expired=0", "timestamp_now desc"); foreach ($result as $value) { if (!isset($parsedUsers[$value['login']])) { if (time() - $value['timestamp_now'] < $interval || !$interval) { $usersOnline[] = array('login' => $value['login'], 'formattedLogin' => formatLogin($value['login'], $value), 'user_type' => $value['user_type'], 'timestamp_now' => $value['timestamp_now'], 'session_timestamp' => $value['session_timestamp'], 'time' => EfrontTimes::formatTimeForReporting(time() - $value['session_timestamp'])); } else { //pr($result); //pr("interval: $interval, time: ".time().", timestamp_now:".$value['timestamp_now']); EfrontUserFactory::factory($value['login'])->logout($value['session_id']); //exit; } $parsedUsers[$value['login']] = true; } } $online_users = sizeof($result); if (G_VERSIONTYPE != 'community') { #cpp#ifndef COMMUNITY if (G_VERSIONTYPE != 'standard') { #cpp#ifndef STANDARD $threshold = $GLOBALS['configuration']['max_online_users_threshold']; if ($threshold > 0 && $online_users > $threshold && time() > $GLOBALS['configuration']['max_online_users_threshold_timestamp'] + 24 * 60 * 60) { $admin = EfrontSystem::getAdministrator(); eF_mail($GLOBALS['configuration']['system_email'], $admin->user['email'], _ONLINEUSERSMAIL, str_replace(array('%w', '%x', '%y', '%z'), array($admin->user['name'], $threshold, $GLOBALS['configuration']['site_name'], G_SERVERNAME), _ONLINEUSERSMAILBODY)); EfrontConfiguration::setValue('max_online_users_threshold_timestamp', time()); } } #cpp#endif } #cpp#endif if ($GLOBALS['configuration']['max_online_users'] < $online_users) { EfrontConfiguration::setValue('max_online_users', $online_users); EfrontConfiguration::setValue('max_online_users_timestamp', time()); } if (G_VERSIONTYPE == 'enterprise' && defined("G_BRANCH_URL") && G_BRANCH_URL && $_SESSION['s_current_branch']) { $branch = new EfrontBranch($_SESSION['s_current_branch']); $branchUsers = $branch->getBranchTreeUsers(); foreach ($usersOnline as $key => $value) { if (!isset($branchUsers[$value['login']]) && $value['user_type'] != 'administrator') { unset($usersOnline[$key]); } } } return $usersOnline; }
$form->addRule('login', _INVALIDLOGIN, 'checkParameter', 'login'); $form->addElement('password', 'password', _PASSWORD, 'class = "inputText" tabindex = "0"'); $form->addRule('password', _THEFIELD . ' "' . _PASSWORD . '" ' . _ISMANDATORY, 'required', null, 'client'); $form->addElement('checkbox', 'remember', _KEEPMELOGGEDIN, null, 'class = "inputCheckbox" style = "vertical-align:middle"'); $form->addElement('submit', 'submit_login', _ENTER, 'class = "flatButton"'); $form->disable_csrf = true; if ($form->isSubmitted() && $form->validate()) { try { $user = EfrontUserFactory::factory(trim($form->exportValue('login'))); if ($GLOBALS['configuration']['lock_down'] && $user->user['user_type'] != 'administrator') { eF_redirect("index.php?message=" . urlencode(_LOCKDOWNONLYADMINISTRATORSCANLOGIN) . "&message_type=failure"); exit; } if ($_SESSION['s_current_branch']) { $branch = new EfrontBranch($_SESSION['s_current_branch']); $branchUsers = $branch->getBranchTreeUsers(); if ($user->user['user_type'] != 'administrator' && (empty($branchUsers) || in_array($user->user['login'], array_keys($branchUsers)) === false)) { if (!$user->user['active']) { eF_redirect("index.php?message=" . urlencode(_USERINACTIVE)); } else { eF_redirect("index.php?message=" . urlencode(_YOUARENOTAMEMBEROFTHISBRANCH)); } } } else { if ($user->user['user_type'] != 'administrator' && !$GLOBALS['configuration']['allow_direct_login']) { eF_redirect("index.php?message=" . urlencode(_YOUCANONLYLOGINFROMYOURBRANCHURL)); } } $user->login($form->exportValue('password')); //Check whether there are any fields that must be filled in by the user $result = eF_getTableData("user_profile", "name,type", "active=1 and mandatory = 2");
/** * Get course information * * This function returns the course information in an array * with attributes: 'general_description', 'assessment', * 'objectives', 'lesson_topics', 'resources', 'other_info', * as well as other information, including professors, lessons, etc. * * <br/>Example: * <code> * $info = $course -> getInformation(); //Get course information * </code> * * @return array The lesson information * @since 3.5.0 * @access public * @todo refactor */ public function getInformation() { $information = array(); if ($this->course['info']) { $order = array("general_description", "objectives", "assessment", "lesson_topics", "resources", "other_info", "learning_method"); // for displaying fiels sorted $infoSorted = array(); $unserialized = unserialize($this->course['info']); foreach ($order as $value) { if ($unserialized[$value] != "") { $infoSorted[$value] = $unserialized[$value]; } } $information = $infoSorted; } foreach ($this->getUsers() as $key => $user) { if ($user['role'] == 'professor') { $information['professors'][$key] = $user; } } if ($_SESSION['s_type'] != 'administrator' && $_SESSION['s_current_branch']) { //this applies to supervisors only require_once 'module_hcd_tools.php'; $currentBranch = new EfrontBranch($_SESSION['s_current_branch']); $branchTreeUsers = array_keys($currentBranch->getBranchTreeUsers()); foreach ($information['professors'] as $key => $value) { if (!in_array($value['login'], $branchTreeUsers)) { unset($information['professors'][$key]); } } } if (sizeof($instances = $this->getInstances()) > 1) { $information['instances'] = sizeof($instances); } else { $information['lessons_number'] = $this->countCourseLessons(); $information['price_string'] = $this->course['price_string']; } $information['language'] = $this->course['languages_NAME']; $information['created'] = $this->course['created']; return $information; }
/** * Get lesson information * * This function returns the lesson information in an array * with attributes: 'general_description', 'assessment', * 'objectives', 'lesson_topics', 'resources', 'other_info', * as well as other information, including professors, projects * etc. * If a user is specified, the information is customized on this * user. * * <br/>Example: * <code> * $info = $lesson -> getInformation(); //Get lesson information * $info = $lesson -> getInformation('jdoe'); //Get lesson information, customizable for user 'jdoe' * </code> * * @param string $user The user login to customize lesson information for * @return array The lesson information * @since 3.5.0 * @access public */ public function getInformation($user = false, $information = false) { $lessonContent = new EFrontContentTree($this->lesson['id'], array('id', 'previous_content_ID', 'parent_content_ID', 'active', 'publish', 'ctg_type')); foreach (new EfrontNodeFilterIterator(new RecursiveIteratorIterator(new RecursiveArrayIterator($lessonContent->tree), RecursiveIteratorIterator::SELF_FIRST), array('active' => 1, 'publish' => 1)) as $key => $value) { switch ($value['ctg_type']) { case 'tests': case 'scorm_test': $testIds[$key] = $key; break; case 'theory': case 'scorm': $theoryIds[$key] = $key; break; case 'examples': $exampleIds[$key] = $key; break; default: break; } } /* $testIds = array(); foreach (new EfrontNodeFilterIterator(new RecursiveIteratorIterator(new RecursiveArrayIterator($lessonContent -> tree), RecursiveIteratorIterator :: SELF_FIRST), array('active' => 1, 'publish' => 1, 'ctg_type' => 'tests')) as $key => $value) { $testIds[$key] = $key; //Count tests } foreach (new EfrontNodeFilterIterator(new RecursiveIteratorIterator(new RecursiveArrayIterator($lessonContent -> tree), RecursiveIteratorIterator :: SELF_FIRST), array('active' => 1, 'ctg_type' => 'scorm_test')) as $key => $value) { $testIds[$key] = $key; //Count tests } $theoryIds = array(); foreach (new EfrontTheoryFilterIterator(new EfrontVisitableFilterIterator(new EfrontNodeFilterIterator(new RecursiveIteratorIterator(new RecursiveArrayIterator($lessonContent -> tree), RecursiveIteratorIterator :: SELF_FIRST)))) as $key => $value) { $theoryIds[$key] = $key; //Count theory } // foreach (new EfrontNodeFilterIterator(new RecursiveIteratorIterator(new RecursiveArrayIterator($lessonContent -> tree), RecursiveIteratorIterator :: SELF_FIRST), array('ctg_type' => 'scorm', 'active' => 1)) as $key => $value) { // $theoryIds[$key] = $key; //Count theory // } $exampleIds = array(); foreach (new EfrontVisitableFilterIterator(new EfrontNodeFilterIterator(new RecursiveIteratorIterator(new RecursiveArrayIterator($lessonContent -> tree), RecursiveIteratorIterator :: SELF_FIRST), array('ctg_type' => 'examples'))) as $key => $value) { $exampleIds[$key] = $key; //Count examples } */ $user ? $projects = $this->getProjects(false, $user, false) : ($projects = $this->getProjects()); $direction = $this->getDirection(); //$info['students'] = $this -> getUsers('student'); //commented out periklis for performance/memory reasons $info['professors'] = $this->getUsers('professor'); if ($_SESSION['s_type'] != 'administrator' && $_SESSION['s_current_branch']) { //this applies to supervisors only require_once 'module_hcd_tools.php'; $currentBranch = new EfrontBranch($_SESSION['s_current_branch']); $branchTreeUsers = array_keys($currentBranch->getBranchTreeUsers()); foreach ($info['students'] as $key => $value) { if (!in_array($value['login'], $branchTreeUsers)) { unset($info['students'][$key]); } } foreach ($info['professors'] as $key => $value) { if (!in_array($value['login'], $branchTreeUsers)) { unset($info['professors'][$key]); } } } $info['tests'] = sizeof($testIds); $info['theory'] = sizeof($theoryIds); $info['examples'] = sizeof($exampleIds); $info['content'] = $info['examples'] + $info['theory']; $info['projects'] = sizeof($projects); $info['direction'] = $direction['name']; $info['active'] = $this->lesson['active']; $info['active_string'] = $this->lesson['active'] == 1 ? _YES : _NO; $info['price'] = $this->lesson['price']; $info['price_string'] = $this->lesson['price_string']; $info['language'] = $this->lesson['languages_NAME']; $info['from_timestamp'] = $this->lesson['from_timestamp']; $info['to_timestamp'] = $this->lesson['to_timestamp']; $info['created'] = $this->lesson['created']; //$info['shift'] = $this -> lesson['shift']; if ($info['professors']) { foreach ($info['professors'] as $value) { $professorsString[] = $value['name'] . ' ' . $value['surname']; } $info['professors_string'] = implode(", ", $professorsString); } if ($this->lesson['info']) { $order = array("general_description", "objectives", "assessment", "lesson_topics", "resources", "other_info", "learning_method"); // for displaying fiels sorted $infoSorted = array(); $unserialized = unserialize($this->lesson['info']); foreach ($order as $value) { if ($unserialized[$value] != "") { $infoSorted[$value] = $unserialized[$value]; } } !is_array($this->lesson['info']) && unserialize($this->lesson['info']) !== false ? $info = array_merge($infoSorted, $info) : ($info = array_merge($infoSorted, $info)); } return $info; }
function askUsers() { if (G_VERSIONTYPE == 'enterprise') { #cpp#ifdef ENTERPRISE if (!isset($_SESSION['supervises_branches'])) { include_once $path . "module_hcd_tools.php"; //Automatically fix missing branch assignments for supervisors eF_assignSupervisorMissingSubBranchesRecursive(); //discover employee role in the hierarchy eF_getRights(); } } #cpp#endif // $_POST['preffix'] = "%"; // Useful for debugging if (isset($_POST['preffix'])) { if (mb_strpos($_POST['preffix'], ";") === false) { $user = $_POST['preffix']; } else { $user = trim(mb_substr(strrchr($_POST['preffix'], ";"), 1)); } } //pr($_SESSION); $users = array(); if (isset($user) && $user) { $preffix = $user; // Return active users for statistics: // - admins: all // - supervisors: all supervised (in Enterprise) // - professors: students if (isset($_GET['supervisors'])) { $users = eF_getTableData("users u, module_hcd_employee_works_at_branch wb", "distinct u.login,u.name,u.surname,u.user_type,u.user_types_ID", "u.login=wb.users_LOGIN and wb.supervisor=1 and u.active = 1 and (login like '{$preffix}%' OR name like '{$preffix}%' OR surname like '{$preffix}%' OR user_type like '{$preffix}%')", "login"); } elseif (!isset($_GET['messaging'])) { if ($_SESSION['s_type'] == "administrator") { $users = eF_getTableData("users", "login,name,surname,user_type,user_types_ID", "active = 1 and (login like '{$preffix}%' OR name like '{$preffix}%' OR surname like '{$preffix}%' OR user_type like '{$preffix}%')", "login"); } else { // Get students of professor $user = EfrontUserFactory::factory($_SESSION['s_login']); $students = $user->getProfessorStudents(); $logins = array(); $size = sizeof($students); for ($i = 0; $i < $size; $i++) { if (!isset($logins[$students[$i]])) { $logins[$students[$i]] = $students[$i]; } } $logins[] = $_SESSION['s_login']; if (G_VERSIONTYPE == 'enterprise') { #cpp#ifdef ENTERPRISE // Append to logins array the employees of supervisor if (isset($user->aspects['hcd']) && $user->aspects['hcd']->isSupervisor()) { include_once $path . "module_hcd_tools.php"; $supervised_employees = eF_getTableData("users LEFT OUTER JOIN module_hcd_employee_has_job_description ON users.login = module_hcd_employee_has_job_description.users_LOGIN LEFT OUTER JOIN module_hcd_employee_works_at_branch ON users.login = module_hcd_employee_works_at_branch.users_LOGIN", "users.login", "(users.user_type <> 'administrator' AND ((module_hcd_employee_works_at_branch.branch_ID IN (" . $_SESSION['supervises_branches'] . " ) AND module_hcd_employee_works_at_branch.assigned='1'))) AND active = 1 GROUP BY login", "login"); foreach ($supervised_employees as $employee) { if (!isset($logins[$employee['login']])) { $logins[$employee['login']] = $employee['login']; } } } } #cpp#endif $students_list = "'" . implode("','", $logins) . "'"; if (sizeof($logins) > 100) { // for performance reason $users = eF_getTableData("users", "login,name,surname,user_type,user_types_ID", "login like '{$preffix}%' OR name like '{$preffix}%' OR surname like '{$preffix}%' OR user_type like '{$preffix}%'", "login"); $logins2 = array(); foreach ($users as $value) { $logins2[$value['login']] = $value; } $users = array_values(array_intersect_key($logins2, $logins)); } else { $users = eF_getTableData("users", "login,name,surname,user_type,user_types_ID", "login IN ({$students_list}) AND (login like '{$preffix}%' OR name like '{$preffix}%' OR surname like '{$preffix}%' OR user_type like '{$preffix}%')", "login"); } } // Return active users for messaging: // - admins: all // - supervisors: all // - users: other users with common group, lesson, course (or branch in Enterprise) } else { if ($_SESSION['s_type'] == "administrator") { $users = eF_getTableData("users", "login,name,surname,user_type,user_types_ID", "active = 1 and (login like '{$preffix}%' OR name like '{$preffix}%' OR surname like '{$preffix}%')", "login"); $users[] = array('login' => "[*]", 'name' => _ALLUSERS, 'surname' => _ALLUSERS); } else { $currentUser = EfrontUserFactory::factory($_SESSION['s_login']); $grant_full_access = false; if (G_VERSIONTYPE == 'enterprise') { #cpp#ifdef ENTERPRISE $currentEmployee = $currentUser->aspects['hcd']; if ($currentEmployee->isSupervisor()) { $grant_full_access = true; } } #cpp#endif if (!$grant_full_access) { // Used for correct handling in Enterprise and non-Enterprise editions $myGroupsIds = array_keys($currentUser->getGroups()); //echo "Groups<BR><BR><BR>";pr($myGroupsIds); if (!empty($myGroupsIds)) { $result = eF_getTableDataFlat("users JOIN users_to_groups", "distinct users_LOGIN", "users.active = 1 and users.login = users_to_groups.users_LOGIN AND groups_ID IN ('" . implode("','", $myGroupsIds) . "')"); $logins = $result['users_LOGIN']; } $myLessonsIds = array_keys($currentUser->getLessons()); //pr($result);echo "Lessons<BR><BR><BR>";pr($myLessonsIds); if (!empty($myLessonsIds)) { $result = eF_getTableDataFlat("users JOIN users_to_lessons", "distinct users_LOGIN", "users.active = 1 and users.archive=0 and users_to_lessons.archive=0 and users.login = users_to_lessons.users_LOGIN AND lessons_ID IN ('" . implode("','", $myLessonsIds) . "')"); $logins = array(); foreach ($result['users_LOGIN'] as $login) { if (!isset($logins[$login])) { $logins[$login] = $login; } } } $myCoursesIds = eF_getTableDataFlat("users_to_courses", "courses_ID", "archive = 0 and users_LOGIN = '******'login'] . "'"); $myCoursesIds = $myCoursesIds['courses_ID']; //echo "Courses<BR><BR><BR>";pr($myCoursesIds); if (!empty($myCoursesIds)) { $result = eF_getTableDataFlat("users JOIN users_to_courses", "distinct users_LOGIN", "users.active = 1 and users.login = users_to_courses.users_LOGIN AND users.archive=0 and users_to_courses.archive=0 AND courses_ID IN ('" . implode("','", $myCoursesIds) . "')"); foreach ($result['users_LOGIN'] as $login) { if (!isset($logins[$login])) { $logins[$login] = $login; } } } if (G_VERSIONTYPE == 'enterprise') { #cpp#ifdef ENTERPRISE $branches = $currentEmployee->getBranches(true); // pr($branches); if (!empty($branches)) { $result = eF_getTableDataFlat("users JOIN module_hcd_employee_works_at_branch", "users_LOGIN", "users.login = module_hcd_employee_works_at_branch.users_LOGIN AND branch_ID IN ('" . implode("','", $branches) . "')"); foreach ($result['users_LOGIN'] as $login) { if (!isset($logins[$login])) { $logins[$login] = $login; } } } } #cpp#endif $related_users_list = "'" . implode("','", $logins) . "'"; $users = eF_getTableData("users", "distinct login,name,surname,user_type,user_types_ID", "login IN (" . $related_users_list . ") AND (login like '{$preffix}%' OR name like '{$preffix}%' OR surname like '{$preffix}%')", "login"); } else { $users = eF_getTableData("users", "distinct login,name,surname,user_type,user_types_ID", "login like '{$preffix}%' OR name like '{$preffix}%' OR surname like '{$preffix}%'", "login"); } } if ($_SESSION['s_type'] == "professor") { $users[] = array('login' => "[*]", 'name' => _MYSTUDENTS, 'surname' => _MYSTUDENTS, 'user_type' => '[*]'); } //pr($users); } } if (G_VERSIONTYPE == 'enterprise' && $_SESSION['s_current_branch'] && $_SESSION['s_type'] != 'administrator') { $currentBranch = new EfrontBranch($_SESSION['s_current_branch']); $branchTreeUsers = array_keys($currentBranch->getBranchTreeUsers()); foreach ($users as $key => $value) { if (!in_array($value['login'], $branchTreeUsers)) { unset($users[$key]); } } $users = array_values($users); } for ($k = 0; $k < sizeof($users); $k++) { /*$hilogin = highlightSearch($users[$k]['login'], $preffix); $hiname = highlightSearch($users[$k]['name'], $preffix); $hisurname = highlightSearch($users[$k]['surname'], $preffix); */ $hilogin = $users[$k]['login']; $hiname = $users[$k]['name']; $hisurname = $users[$k]['surname']; $hiusertype = $users[$k]['user_types_ID'] ? $users[$k]['user_types_ID'] : $users[$k]['user_type']; if ($users[$k]['login'] == '[*]') { $formattedLogins[$users[$k]['login']] = $hiname; } else { $formattedLogins[$users[$k]['login']] = formatLogin($hilogin, array('login' => $hilogin, 'name' => $hiname, 'surname' => $hisurname, 'user_type' => $hiusertype)); } //$str = $str.'<li id='.$users[$k]['login'].'>'.$formattedLogin.'</li>'; } //changed for case that two users (without common appearance) returned but one of them have common appearance with a third user (#1741) if ($GLOBALS['configuration']['username_format_resolve']) { formatLogin($_SESSION['s_login']); foreach ($formattedLogins as $key => $value) { if (isset($GLOBALS['_usernames'][$key])) { $formattedLogins[$key] = $GLOBALS['_usernames'][$key]; } } } $strs = array(); $strs[] = '<ul>'; for ($k = 0; $k < sizeof($users); $k++) { $strs[] = '<li id="' . htmlentities($users[$k]['login'], ENT_COMPAT | ENT_HTML401, 'UTF-8') . '">' . htmlentities($formattedLogins[$users[$k]['login']], ENT_COMPAT | ENT_HTML401, 'UTF-8') . '</li>'; } $strs[] = '</ul>'; echo implode("", $strs); }