foreach ($result as $value) { //$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);
$form->accept($renderer); $smarty->assign('T_RESET_PASSWORD_FORM', $renderer->toArray()); } /* -------------------------------------------------------End of Reset Password part--------------------------------------------------------- */ /* -----------------------------------------------------Sign up part--------------------------------------------------------- */ if (isset($_GET['ctg']) && $_GET['ctg'] == "signup" && $configuration['signup']) { if (eF_checkSpam() == true) { $message = _SPAMDETECTION; $message_type = 'failure'; eF_redirect(basename($_SERVER['PHP_SELF']) . '?message=' . urlencode($message) . '&message_type=' . $message_type); } if (G_VERSIONTYPE == 'enterprise') { #cpp#ifdef ENTERPRISE if (isset($_GET['postAjaxRequest'])) { try { $currentBranch = new EfrontBranch($_GET['branch']); if (isset($_GET['getJobSelect'])) { $ar = $currentBranch->createJobDescriptionsSelect($attributes); } else { if (isset($_GET['getSupervisorsSelect'])) { $ar = $currentBranch->createSupervisorsSelect($_GET['only_existing']); } } foreach ($ar as $val => $element) { echo $val . "<option>" . $element . "<option>"; } exit; } catch (Exception $e) { } } }
/** * 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; }
protected function importData($line, $type, $data) { //pr($line);exit; try { switch ($type) { case "users": $newUser = EfrontUser::createUser($data); $this->log["success"][] = _LINE . " {$line}: " . _IMPORTEDUSER . " " . $newUser->login; break; case "users_to_courses": //Check if a user exists and whether it has the same case $userFound = false; if (!in_array($data['users_login'], $this->allUserLogins)) { //For case-insensitive matches foreach ($this->allUserLogins as $login) { if (mb_strtolower($data['users_login']) == mb_strtolower($login)) { $data['users_login'] = $login; $userFound = true; } } } else { $userFound = true; } if ($userFound) { $courses_name = trim($data['course_name']); $courses_ID = $this->getCourseByName($courses_name); unset($data['course_name']); if ($courses_ID) { foreach ($courses_ID as $course_ID) { $data['courses_ID'] = $course_ID; $course = new EfrontCourse($course_ID); if (is_null($this->course_users[$course_ID])) { $result = eF_getTableDataFlat("users_to_courses", "users_LOGIN", "courses_ID={$course_ID} AND archive=0"); $this->course_users[$course_ID] = array_combine($result['users_LOGIN'], $result['users_LOGIN']); } if (isset($this->course_users[$course_ID][$data['users_login']])) { throw new Exception("User is already assigned to the course", self::USER_TO_COURSE_EXISTS); } //$course -> addUsers($data['users_login'], (isset($data['user_type']) && $data['user_type']?$data['user_type']:"student")); $course->addUsers($data['users_login'], isset($data['user_type']) ? $data['user_type'] : "student"); $where = "users_login = '******'users_login'] . "' AND courses_ID = " . $data['courses_ID']; $data['completed'] ? $data['completed'] = 1 : ($data['completed'] = 0); EfrontCourse::persistCourseUsers($data, $where, $data['courses_ID'], $data['users_login']); if ($data['active']) { $course->confirm($data['users_login']); } else { $course->unconfirm($data['users_login']); } $this->course_users[$course_ID][$data['users_login']] = $data['users_login']; $this->log["success"][] = _LINE . " {$line}: " . _NEWCOURSEASSIGNMENT . " " . $courses_name . " - " . $data['users_login']; } } else { if ($courses_name != "") { $course = EfrontCourse::createCourse(array("name" => $courses_name)); $this->log["success"][] = _LINE . " {$line}: " . _NEWCOURSE . " " . $courses_name; $course->addUsers($data['users_login'], isset($data['user_type']) ? $data['user_type'] : "student"); $courses_ID = $course->course['id']; $this->courseNamesToIds[$courses_name] = array($courses_ID); $where = "users_login = '******'users_login'] . "' AND courses_ID = " . $courses_ID; EfrontCourse::persistCourseUsers($data, $where, $courses_ID, $data['users_login']); if ($data['active']) { $course->confirm($data['users_login']); } else { $course->unconfirm($data['users_login']); } $this->log["success"][] = _LINE . " {$line}: " . _NEWCOURSEASSIGNMENT . " " . $courses_name . " - " . $data['users_login']; } else { $this->log["failure"][] = _LINE . " {$line}: " . _COULDNOTFINDCOURSE . " " . $courses_name; } } } else { $this->log["failure"][] = _LINE . " {$line}: " . _USERDOESNOTEXIST . ": " . $data['users_login']; } break; case "users_to_lessons": //Check if a user exists and whether it has the same case $userFound = false; if (!in_array($data['users_login'], $this->allUserLogins)) { //For case-insensitive matches foreach ($this->allUserLogins as $login) { if (mb_strtolower($data['users_login']) == mb_strtolower($login)) { $data['users_login'] = $login; $userFound = true; } } } else { $userFound = true; } if ($userFound) { $lessons_name = trim($data['lesson_name']); $lessons_ID = $this->getLessonByName($lessons_name); unset($data['lesson_name']); if ($lessons_ID) { foreach ($lessons_ID as $lesson_ID) { $data['lessons_ID'] = $lesson_ID; $lesson = new EfrontLesson($lesson_ID); if (is_null($this->lesson_users[$lesson_ID])) { $result = eF_getTableDataFlat("users_to_lessons", "users_LOGIN", "lessons_ID={$lesson_ID} AND archive=0"); $this->lesson_users[$lesson_ID] = array_combine($result['users_LOGIN'], $result['users_LOGIN']); } if (isset($this->lesson_users[$lesson_ID][$data['users_login']])) { throw new Exception("User is already assigned to the lesson", self::USER_TO_LESSON_EXISTS); } if (!$lesson->lesson['course_only']) { $lesson->addUsers($data['users_login'], isset($data['user_type']) ? $data['user_type'] : "student"); } $data['completed'] ? $data['completed'] = 1 : ($data['completed'] = 0); eF_updateTableData("users_to_lessons", $data, "users_login = '******'users_login'] . "' AND lessons_ID = " . $data['lessons_ID']); if (!$lesson->lesson['course_only']) { if ($data['active']) { $lesson->confirm($data['users_login']); } else { $lesson->unconfirm($data['users_login']); } } $this->log["success"][] = _LINE . " {$line}: " . _NEWLESSONASSIGNMENT . " " . $lessons_name . " - " . $data['users_login']; } } else { if ($lessons_name != "") { $lesson = EfrontLesson::createLesson(array("name" => $lessons_name, 'course_only' => false)); $this->log["success"][] = _LINE . " {$line}: " . _NEWLESSON . " " . $lessons_name; $lesson->addUsers($data['users_login'], isset($data['user_type']) ? $data['user_type'] : "student"); $lessons_ID = $lesson->lesson['id']; $this->lessonNamesToIds[$lessons_name] = array($lessons_ID); eF_updateTableData("users_to_lessons", $data, "users_login = '******'users_login'] . "' AND lessons_ID = " . $lessons_ID); if ($data['active']) { $lesson->confirm($data['users_login']); } else { $lesson->unconfirm($data['users_login']); } $this->log["success"][] = _LINE . " {$line}: " . _NEWLESSONASSIGNMENT . " " . $lessons_name . " - " . $data['users_login']; } else { $this->log["failure"][] = _LINE . " {$line}: " . _COULDNOTFINDLESSON . " " . $lessons_name; } } } else { $this->log["failure"][] = _LINE . " {$line}: " . _USERDOESNOTEXIST . ": " . $data['users_login']; } break; case "users_to_groups": //debug(); $groups_ID = $this->getGroupByName($data['groups.name']); $group_name = $data['groups.name']; unset($data['groups.name']); foreach ($groups_ID as $group_ID) { $data['groups_ID'] = $group_ID; $group = new EfrontGroup($group_ID); $group->addUsers(array($data['users_login'])); $this->log["success"][] = _LINE . " {$line}: " . _NEWGROUPASSIGNMENT . " " . $group_name . " - " . $data['users_login']; } break; //debug(false); #cpp#ifdef ENTERPRISE //debug(false); #cpp#ifdef ENTERPRISE case "employees": $this->cleanUpEmptyValues($data); // a bit customized here, based on the fact that employees are always created together AFTER users (so the object should exist) eF_updateTableData("module_hcd_employees", $data, "users_login='******'users_login'] . "'"); break; case "branches": // If no father defined - root, else we may need to create the father first $data['father_branch_ID'] = $this->getFatherBranchId($data['father_branch_name']); $father_name = $data['father_branch_name']; $branch_ID = $this->getBranchByName($data['name']); $branch_name = $data['name']; if (sizeof($branch_ID) > 0 && $data['name'] != $data['father_branch_name']) { //TODO unset($data['father_branch_name']); $data['branch_ID'] = $branch_ID[0]; throw new EfrontBranchException(_BRANCHALREADYEXISTS, EfrontBranchException::BRANCH_EXISTS); } else { unset($data['father_branch_name']); $data['url'] = EfrontBranch::getBranchUrl($data['name']); $branch = EfrontBranch::createBranch($data); $this->setBranchByName($branch_name, $branch->branch['branch_ID']); } $this->log["success"][] = _LINE . " {$line}: " . _NEWBRANCH . " " . $branch_name; break; case "job_descriptions": if ($data['branch_name'] == "") { $data['branch_ID'] = "all"; // this denotes to the createJob class to put the job in all branches } else { $data['branch_ID'] = $this->getBranchByName($data['branch_name']); if (sizeof($data['branch_ID']) > 0) { //TODO: maybe different handling when multiple branches are found $data['branch_ID'] = $data['branch_ID'][0]; } else { throw new EfrontJobException(_BRANCHDESIGNATEDFORTHISJOBDESCRIPTIONDOESNOTEXIST, EfrontJobException::BRANCH_NOT_EXISTS); } } unset($data['branch_name']); if ($data['description'] != "") { $job_ID = $this->getJobByName($data['description']); if (sizeof($job_ID) > 0) { $data['job_description_ID'] = $job_ID[0]; throw new EfrontJobException(_JOBDESCRIPTIONEXISTSALREADY, EfrontJobException::JOB_ALREADY_EXISTS); } else { EfrontJob::createJob($data); $this->log["success"][] = _LINE . " {$line}: " . _NEWJOB . " " . $data['description']; } } else { $this->log["failure"][] = _LINE . " {$line}: " . _NOTITLEPROVIDEDFORNEWJOB; } break; case "skills": if ($data['skill_category'] == "") { throw new EfrontSkillException(_MISSINGSKILLCATEGORY, EfrontSkillException::INVALID_SKILL_CATEGORY); } else { $data['categories_ID'] = $this->getSkillCategoryByName($data['skill_category']); if ($data['categories_ID'][0] != "") { $data['categories_ID'] = $data['categories_ID'][0]; } else { // create skill category $data['categories_ID'] = eF_insertTableData("module_hcd_skill_categories", array('description' => $data['skill_category'])); $this->setSkillCategoryByName($data['skill_category'], $data['categories_ID']); } } unset($data['skill_category']); $skill_ID = $this->getSkillByName($data['description']); if ($skill_ID) { //TODO: another double issue $data['skill_ID'] = $skill_ID[0]; throw new EfrontSkillException(_SKILLALREADYEXISTS, EfrontSkillException::SKILL_EXISTS); } else { EfrontSkill::createSkill($data); $this->log["success"][] = _LINE . " {$line}: " . _NEWSKILL . " " . $data['description']; } break; case "users_to_jobs": // Get user $user = EfrontUserFactory::factory($data["users_login"]); // Get branch id $branch_ID = $this->getBranchByName($data['branch_name']); $branch_name = $data['branch_name']; if ($branch_ID[0] != "") { if (sizeof($branch_ID) == 1) { $branch_ID = $branch_ID[0]; } else { throw new EfrontBranchException(_BRANCHNAMEAMBIGUOUS, EfrontBranchException::BRANCH_AMBIGUOUS); } } else { throw new EfrontBranchException(_BRANCHDOESNOTEXIST, EfrontBranchException::BRANCH_NOT_EXISTS); } // Get job id $job_name = $data['description']; if ($job_name != "") { $new_job_description_ID = eF_getJobDescriptionId($job_name, $branch_ID); } else { throw new EfrontJobException(_MISSING_JOB_DESCRIPTION, EfrontJobException::MISSING_JOB_DESCRIPTION); } // Get hcd employee object if ($data['supervisor']) { $employee = new EfrontSupervisor(array("users_login" => $data["users_login"])); $position = 1; } else { $employee = new EfrontEmployee(array("users_login" => $data["users_login"])); $position = 0; } // Assign job try { $employee->addJob($user, $new_job_description_ID, $branch_ID, $position); $this->log["success"][] = _LINE . " {$line}: " . _NEWJOBASSIGNMENT . " " . $data["users_login"] . " - (" . $branch_name . " - " . $job_name . ") "; } catch (Exception $e) { if ($this->options['replace_existing']) { $employee->removeJob($new_job_description_ID); $employee->addJob($user, $new_job_description_ID, $branch_ID, $position); $this->log["success"][] = _LINE . " {$line}: " . _NEWJOBASSIGNMENT . " " . $data["users_login"] . " - (" . $branch_name . " - " . $job_name . ") "; } } break; case "users_to_skills": $skill_ID = $this->getSkillByName($data['description']); $skill_name = $data['description']; if ($skill_ID[0] != "") { if (sizeof($skill_ID) == 1) { $skill_ID = $skill_ID[0]; } else { throw new EfrontSkillException(_SKILLNAMEAMBIGUOUS, EfrontSkillException::SKILL_AMBIGUOUS); } } else { throw new EfrontSkillException(_SKILLDOESNOTEXIST, EfrontSkillException::SKILL_NOT_EXISTS); } $skill = new EfrontSkill($skill_ID); $skill->assignToEmployee($data['users_login'], $data['specification']); $this->log["success"][] = _LINE . " {$line}: " . _NEWSKILLASSIGNMENT . " " . $data["users_login"] . " - " . $skill_name; break; case "courses_to_branches": $branchId = $this->getBranchByName($data['branch_name']); if (!$branchId[0]) { $fields = array('name' => $data['branch_name'], 'url' => EfrontBranch::getBranchUrl($data['branch_name'])); $branch = EfrontBranch::createBranch($fields); } else { $branch = new EfrontBranch($branchId[0]); } $courseId = $this->getCourseByName($data['course_name']); if ($courseId[0]) { $branch->addCoursesToBranch($courseId[0]); } $this->log["success"][] = _LINE . " {$line}: " . _NEWCOURSETOBRANCHASSIGNMENT . " " . $data['course_name'] . " - " . $data['branch_name']; break; #cpp#endif } } catch (Exception $e) { if ($this->options['replace_existing']) { if ($this->isAlreadyExistsException($e->getCode(), $type)) { $this->updateExistingData($line, $type, $data); } else { $this->log["failure"][] = _LINE . " {$line}: " . $e->getMessage(); // ." ". str_replace("\n", "<BR>", $e->getTraceAsString()); } } else { $this->log["failure"][] = _LINE . " {$line}: " . $e->getMessage(); // ." ". str_replace("\n", "<BR>", $e->getTraceAsString()); } } }
/** * Assign a branch to this course * * This function is used to correlate a branch to the course * All users of the branch should be assigned to this course * * <br/>Example: * <code> * $course -> assignBranch(2); // The course will be assigned to branch with id 2 * </code> * * @param $branch_ID the id of the branch to be assigned * @return boolean true/false * @since 3.6.0 * @access public */ public function assignBranch($branch_ID) { $this->getBranches(); // Check if the branch is not assigned as offered by this course if ($this->branches[$branch_ID]['courses_ID'] == "") { eF_insertTableData("module_hcd_course_to_branch", array("branches_ID" => $branch_ID, "courses_ID" => $this->course['id'])); $this->branches[$branch_ID]['courses_ID'] = $this->course['id']; $newBranch = new EfrontBranch($branch_ID); $employees = $newBranch->getEmployees(false, true); //get data flat $this->addUsers($employees['login'], $employees['user_type']); } return true; }
private function doUnenrollUsers() { $smarty = $this->getSmartyVar(); $currentUser = $this->getCurrentUser(); if ($_GET['type'] == 'job') { foreach (EfrontJob::getAllJobs() as $key => $value) { $entities[$value['job_description_ID']] = $value['description']; } if ($_GET['entry']) { $entity = new EfrontJob($_GET['entry']); $courses = $entity->getJobCourses(array('archive' => false)); $users = $entity->getEmployees(); } } elseif ($_GET['type'] == 'branch') { foreach (EfrontBranch::getAllBranches() as $key => $value) { $entities[$value['branch_ID']] = $value['name']; } if ($_GET['entry']) { $entity = new EfrontBranch($_GET['entry']); $courses = $entity->getBranchCourses(array('archive' => false)); $users = $entity->getEmployees(); } } elseif ($_GET['type'] == 'group') { foreach (EfrontGroup::getGroups() as $key => $value) { $entities[$value['id']] = $value['name']; } if ($_GET['entry']) { $entity = new EfrontGroup($_GET['entry']); $courses = $entity->getGroupCourses(array('archive' => false)); $users = $entity->getGroupUsers(); } } if ($_GET['ajax'] && $_GET['remove_users_from_courses']) { try { foreach ($courses as $course) { $course->removeUsers($users); } exit; } catch (Exception $e) { handleAjaxExceptions($e); } } $smarty->assign("T_ENTITIES_LIST", $entities); }
/** * Assign a branch to this lesson * * This function is used to correlate a branch to the lesson * All users of the branch should be assigned to this lesson * * <br/>Example: * <code> * $lesson -> assignBranch(2); // The lesson will be assigned to branch with id 2 * </code> * * @param $branch_ID the id of the branch to be assigned * @return boolean true/false * @since 3.6.0 * @access public */ public function assignBranch($branch_ID) { $this->getBranches(); // Check if the branch is not assigned as offered by this lesson if ($this->branches[$branch_ID]['lessons_ID'] == "") { if ($ok = eF_insertTableData("module_hcd_lesson_to_branch", array("branches_ID" => $branch_ID, "lessons_ID" => $this->lesson['id']))) { $this->branches[$branch_ID]['lessons_ID'] = $this->lesson['id']; $newBranch = new EfrontBranch($branch_ID); $employees = $newBranch->getEmployees(false, true); //get data flat $this->addUsers($employees['login'], $employees['user_type']); } else { throw new EfrontLessonException(_EMPLOYEESRECORDCOULDNOTBEUPDATED, EfrontLessonException::DATABASE_ERROR); } } return true; }
} } else { if (!empty($skills)) { $smarty->assign("T_SKILLS", $skills); $smarty->assign("T_SKILLS_SIZE", sizeof($skills)); } } } #cpp#endif } $roles = EfrontLessonUser::getLessonsRoles(true); $smarty->assign("T_ROLES", $roles); if (isset($_GET['ajax']) && $_GET['ajax'] == 'usersTable') { $constraints = array('archive' => false, 'active' => 1, 'return_objects' => false) + createConstraintsFromSortedTable(); if ($_SESSION['s_current_branch']) { $branch = new EfrontBranch($_SESSION['s_current_branch']); $branches = $branch->getAllSubbranches(); $branches[] = $_SESSION['s_current_branch']; $constraints['branch'] = $branches; } $users = $editLesson->getLessonUsersIncludingUnassigned($constraints); $totalEntries = $editLesson->countLessonUsersIncludingUnassigned($constraints); foreach ($users as $key => $user) { if (!$user['has_lesson']) { $user['user_types_ID'] ? $users[$key]['role'] = $user['user_types_ID'] : ($users[$key]['role'] = $user['user_type']); } } $dataSource = $users; $tableName = $_GET['ajax']; $alreadySorted = 1; $smarty->assign("T_TABLE_SIZE", $totalEntries);
$selectedAvatar = $avatarsFileSystemTree->seekNode(G_SYSTEMAVATARSPATH . $selectedAvatar); $newList = FileSystemTree::importFiles($selectedAvatar['path']); //Import the file to the database, so we can access it with view_file $editedUser->user['avatar'] = key($newList); } } EfrontEvent::triggerEvent(array("type" => EfrontEvent::AVATAR_CHANGE, "users_LOGIN" => $editedUser->user['login'], "users_name" => $editedUser->user['name'], "users_surname" => $editedUser->user['surname'], "lessons_ID" => 0, "lessons_name" => "", "entity_ID" => $editedUser->user['avatar'])); } $editedUser->persist(); if (G_VERSIONTYPE == 'enterprise') { #cpp#ifdef ENTERPRISE if (isset($_GET['add_user'])) { $editedEmployee = EfrontHcdUser::createUser(array('users_login' => $editedUser->user['login'])); if ($currentEmployee->isSupervisor() && !EfrontUser::isOptionVisible('show_unassigned_users_to_supervisors')) { //if supervisors can't see unassigned users, then attach this new user to the supervisor's firts branch and job $branch = new EfrontBranch(current($currentEmployee->getSupervisedBranchesRecursive())); $nospecific = false; foreach ($branch->getJobDescriptions() as $value) { if ($value['description'] == _NOSPECIFICJOB) { $nospecific = $value['job_description_ID']; } } if (!$nospecific) { $nospecific = EfrontJob::createJob(array('description' => _NOSPECIFICJOB, 'branch_ID' => $branch->branch['branch_ID'])); } $editedEmployee->addJob($editedUser, $nospecific, $branch->branch['branch_ID'], 0); } } } #cpp#endif if (isset($_SESSION['missing_fields'])) {
$instances[$course->course['id']] = $course; } foreach ($instances as $key => $instance) { if (!$instance->course['show_catalog']) { unset($instances[$key]); } } $smarty->assign("T_COURSE_INSTANCES", $instances); $courseInfo = new LearningObjectInformation(unserialize($course->course['info'])); $smarty->assign("T_COURSE_INFO", $courseInfo); $additionalInfo = $course->getInformation(); $smarty->assign("T_ADDITIONAL_COURSE_INFO", $additionalInfo); } } if (isset($_SESSION['s_current_branch'])) { $branch = new EfrontBranch($_SESSION['s_current_branch']); $constraints = array('active' => true, 'archive' => false, 'instance' => false, 'sort' => 'name'); $courses = $branch->getBranchCoursesIncludingParentBranches($constraints); //$courses = $branch->getBranchCoursesIncludingSubbranches($constraints); $lessons = array(); } if ($GLOBALS['configuration']['enable_cart']) { $smarty->assign("T_LAYOUT_CLASS", $currentTheme->options['toolbar_position'] == "left" ? "hideRight" : "hideLeft"); //Whether to show the sidemenu on the left or on the right } if (strpos($_SERVER['PHP_SELF'], 'index.php') !== false) { $options = array('lessons_link' => basename($_SERVER['PHP_SELF']) . '?ctg=lesson_info&lessons_ID=', 'courses_link' => basename($_SERVER['PHP_SELF']) . '?ctg=lesson_info&courses_ID=', 'search' => true, 'catalog' => true, 'url' => $_SERVER['PHP_SELF'], 'collapse' => $GLOBALS['configuration']['collapse_catalog'], 'buy_link' => true, 'course_lessons' => false); } else { $options = array('lessons_link' => basename($_SERVER['PHP_SELF']) . '?ctg=lessons&catalog=1&info_lesson=', 'courses_link' => basename($_SERVER['PHP_SELF']) . '?ctg=lessons&catalog=1&info_course=', 'search' => true, 'catalog' => true, 'url' => $_SERVER['PHP_SELF'] . '?ctg=lessons&catalog=1', 'collapse' => $GLOBALS['configuration']['collapse_catalog'], 'buy_link' => true, 'course_lessons' => false); } //if (!empty($courses) || !empty($lessons)) { //wtf
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); }
$_SERVER['PHP_SELF'] = strip_tags($_SERVER['PHP_SELF']); if (php_sapi_name() != 'cli' && !is_file(basename($_SERVER['PHP_SELF']))) { exit; } // for something like this index.php/"onmouseover=prompt(1234)> if ($GLOBALS['configuration']['eliminate_post_xss']) { foreach ($_POST as $key => $value) { if (is_string($value)) { $_POST[$key] = strip_script_tags($value); } } } #cpp#ifdef ENTERPRISE if (defined('G_BRANCH_URL')) { try { $branch = EfrontBranch::getBranchByUrl(G_BRANCH_URL); $_SESSION['s_current_branch'] = $branch->branch['branch_ID']; if ($branch->branch['languages_NAME'] && in_array($branch->branch['languages_NAME'], array_keys(EfrontSystem::getLanguages(true, true)))) { $_SESSION['s_language'] = $branch->branch['languages_NAME']; } if ($theme = $branch->branch['themes_ID']) { $theme = new themes($theme); $_SESSION['s_theme'] = $theme->{$theme->entity}['id']; } } catch (Exception $e) { //do nothing, simply ignore failed branch assignments } } #cpp#endif //Language settings. $GLOBALS['loadLanguage'] can be used to exclude language files from loading, for example during certain ajax calls if (!isset($GLOBALS['loadLanguage']) || $GLOBALS['loadLanguage']) {
#cpp#ifdef ENTERPRISE /* Braches (in hierarchical form) */ //$branches = eF_getTableData("module_hcd_branch", "branch_ID, name, father_branch_ID","","father_branch_ID ASC,branch_ID ASC"); $branches_list = eF_createBranchesTreeSelect(false, 6); $branches_list[0] = _DONTTAKEINTOACCOUNT; $form->addElement('select', 'search_branch', _WORKINGATBRANCH, $branches_list, 'id = "search_branch" class = "inputSelectMed" onchange="javascript:refreshResults()"'); // If a branch is selected then the form will reload on clicking the checkbox. if (isset($_GET['branch_ID'])) { $onclick_event = ' onclick = "" '; } else { $onclick_event = ''; } $form->addElement('advcheckbox', 'include_subbranches', _INCLUDESUBBRANCHES, null, 'class = "inputCheckbox" id="include_subbranchesId" onClick="javascript:includeSubbranches()"'); /* Job descriptions (all different job descriptions irrespective of the branch they belong to) */ if (isset($_GET['branch_ID']) && $_GET['branch_ID'] != "" && $_GET['branch_ID'] > 0) { $activeBranch = new EfrontBranch($_GET['branch_ID']); $job_description_list = $activeBranch->createJobDescriptionsSelect(); $job_description_list[0] = _DONTTAKEINTOACCOUNT; } else { //Changed code so that description_ID is sending in request instead of description because of this #3112 //$job_descriptions = eF_getTableData("module_hcd_job_description", "job_description_ID, description",""); $job_descriptions = eF_getTableData("module_hcd_job_description", "job_description_ID, description", "", "", "description having count(*) >= 1"); $job_description_list = array("0" => _DONTTAKEINTOACCOUNT); foreach ($job_descriptions as $job_description) { //$log = $job_description['description']; $job_description_list[$job_description['job_description_ID']] = $job_description['description']; } } $form->addElement('select', 'search_job_description', _WITHJOBDESCRIPTION, $job_description_list, 'id = "search_job_description" class = "inputSelectMed" onchange="javascript:refreshResults()"'); /* Skills */ $skills = eF_getTableData("module_hcd_skills", "skill_ID, description", "");
/** * The main functionality * * (non-PHPdoc) * @see libraries/EfrontModule#getModule() */ public function getModule() { $smarty = $this->getSmartyVar(); $smarty->assign("T_MODULE_BASEDIR", $this->moduleBaseDir); $smarty->assign("T_MODULE_BASELINK", $this->moduleBaseLink); $smarty->assign("T_MODULE_BASEURL", $this->moduleBaseUrl); $currentUser = $this->getCurrentUser(); if ($currentUser->user['user_type'] != 'administrator') { $currentEmployee = $this->getCurrentUser()->aspects['hcd']; if (!$currentEmployee || !$currentEmployee->isSupervisor()) { throw new Exception("You cannot access this module"); } } $form = new HTML_QuickForm("user_activity_form", "post", basename($_SERVER['PHP_SELF']) . "?ctg=module&op=module_idle_users&tab=user_activity", "", null, true); $form->addElement('date', 'idle_from_timestamp', _MODULE_IDLE_USERS_SHOWINACTIVEUSERSSINCE, array('minYear' => 2005, 'maxYear' => date("Y"))); $form->addElement("static", "", '<a href = "javascript:void(0)" onclick = "setFormDate(' . date("Y") . ',' . date("m") . ',' . (date("d") - 7) . ')">' . _LASTWEEK . '</a> - <a href = "javascript:void(0)" onclick = "setFormDate(' . date("Y") . ',' . (date("m") - 1) . ',' . date("d") . ')">' . _LASTMONTH . '</a> - <a href = "javascript:void(0)" onclick = "setFormDate(' . date("Y") . ',' . (date("m") - 3) . ',' . date("d") . ')">' . _MODULE_IDLE_USERS_LAST3MONTHS . '</a>'); $form->addElement("submit", "submit", _SUBMIT, 'class = "flatButton"'); if (!isset($_SESSION['timestamp_from'])) { $_SESSION['timestamp_from'] = time() - 86400 * 30; } $form->setDefaults(array("idle_from_timestamp" => $_SESSION['timestamp_from'])); if ($form->isSubmitted() && $form->validate()) { $values = $form->exportValues(); $_SESSION['timestamp_from'] = mktime(0, 0, 0, $values['idle_from_timestamp']['M'], $values['idle_from_timestamp']['d'], $values['idle_from_timestamp']['Y']); } $smarty->assign("T_IDLE_USER_FORM", $form->toArray()); try { if ($currentEmployee) { if ($_SESSION['s_current_branch'] && in_array($_SESSION['s_current_branch'], $currentEmployee->supervisesBranches)) { $currentBranch = new EfrontBranch($_SESSION['s_current_branch']); $subbranches = $currentBranch->getSubbranches(); foreach ($subbranches as $subbranch) { $branches[$subbranch['branch_ID']] = $subbranch['branch_ID']; } $branches[$_SESSION['s_current_branch']] = $_SESSION['s_current_branch']; $result = eF_getTableData("users u JOIN module_hcd_employee_works_at_branch ewb on ewb.users_login=u.login", "u.login,u.name,u.surname,u.active,u.last_login as last_action", "ewb.branch_ID in (" . implode(',', $branches) . ") and u.last_login is null or u.last_login <= " . $_SESSION['timestamp_from']); //$result = eF_getTableData("(select login,name,surname,active,max(l.timestamp) as last_action from users u left outer join logs l on u.login=l.users_LOGIN where u.archive=0 group by login) r join module_hcd_employee_works_at_branch ewb on ewb.users_login=r.login", "*", "ewb.branch_ID in (".implode(',', $branches) .") and (r.last_action is null or r.last_action <= ".$_SESSION['timestamp_from'].")"); } else { $result = eF_getTableData("users u JOIN module_hcd_employee_works_at_branch ewb on ewb.users_login=u.login", "u.login,u.name,u.surname,u.active,u.last_login as last_action", "ewb.branch_ID in (" . implode(',', $currentEmployee->supervisesBranches) . ") and u.last_login is null or u.last_login <= " . $_SESSION['timestamp_from']); //$result = eF_getTableData("(select login,name,surname,active,max(l.timestamp) as last_action from users u left outer join logs l on u.login=l.users_LOGIN where u.archive=0 group by login) r join module_hcd_employee_works_at_branch ewb on ewb.users_login=r.login", "*", "ewb.branch_ID in (".implode(',', $currentEmployee->supervisesBranches).") and (r.last_action is null or r.last_action <= ".$_SESSION['timestamp_from'].")"); } } else { $result = eF_getTableData("users", "login,name,surname,active,last_login as last_action", "last_login is null or last_login <= " . $_SESSION['timestamp_from']); } $users = array(); foreach ($result as $value) { if ($value['last_action']) { $value['last_action_since'] = eF_convertIntervalToTime(time() - $value['last_action'], true); } else { $value['last_action_since'] = null; } $users[$value['login']] = $value; } foreach ($users as $key => $value) { if (isset($_COOKIE['toggle_active'])) { if ($_COOKIE['toggle_active'] == 1 && !$value['active'] || $_COOKIE['toggle_active'] == -1 && $value['active']) { unset($users[$key]); } } } if (isset($_GET['excel'])) { $export_users[] = array(_USER, _MODULE_IDLE_USERS_LASTACTION, _STATUS); foreach ($users as $key => $value) { $value['last_action'] ? $last_action = formatTimestamp($value['last_action']) : ($last_action = _NEVER); $value['active'] ? $status = _ACTIVE : ($status = _INACTIVE); $export_users[] = array(formatLogin($value['login']), $last_action, $status); } EfrontSystem::exportToCsv($export_users, true); exit; } if ($_GET['ajax'] == 'idleUsersTable') { list($tableSize, $users) = filterSortPage($users); $smarty->assign("T_SORTED_TABLE", $_GET['ajax']); $smarty->assign("T_TABLE_SIZE", $tableSize); $smarty->assign("T_DATA_SOURCE", $users); } if (isset($_GET['ajax']) && isset($_GET['archive_user'])) { if (isset($users[$_GET['archive_user']])) { $user = EfrontUserFactory::factory($_GET['archive_user']); $user->archive(); } exit; } else { if (isset($_GET['ajax']) && isset($_GET['archive_all_users'])) { //eF_updateTableData("users", array("archive" => 1, "active" => 0), "login in (select login from (select login,max(l.timestamp) as last_action from users u left outer join logs l on u.login=l.users_LOGIN where u.archive=0 and u.login != '".$_SESSION['s_login']."' group by login) r where r.last_action <= ".$_SESSION['timestamp_from']." or r.last_action is null)"); foreach ($users as $value) { eF_updateTableData("users", array("archive" => 1, "active" => 0), "login='******'login'] . "'"); } exit; } else { if (isset($_GET['ajax']) && isset($_GET['toggle_user'])) { if (isset($users[$_GET['toggle_user']])) { $user = EfrontUserFactory::factory($_GET['toggle_user']); if ($user->user['active']) { $user->deactivate(); } else { $user->activate(); } echo json_encode(array('status' => 1, 'active' => $user->user['active'])); } exit; } else { if (isset($_GET['ajax']) && isset($_GET['deactivate_all_users'])) { //eF_updateTableData("users", array("active" => 0), "login in (select login from (select login,max(l.timestamp) as last_action from users u left outer join logs l on u.login=l.users_LOGIN where u.archive=0 and u.login != '".$_SESSION['s_login']."' group by login) r where r.last_action <= ".$_SESSION['timestamp_from']." or r.last_action is null)"); foreach ($users as $value) { eF_updateTableData("users", array("active" => 0), "login='******'login'] . "'"); } exit; } } } } } catch (Exception $e) { handleAjaxExceptions($e); } return true; }