本文整理汇总了PHP中EfrontUserFactory类的典型用法代码示例。如果您正苦于以下问题:PHP EfrontUserFactory类的具体用法?PHP EfrontUserFactory怎么用?PHP EfrontUserFactory使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了EfrontUserFactory类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: analyseSkillGapTest
/**
* Analyse a completed test as a skill gap test
*
* This function is used to perform skill-gap analysis
*
* <br/>Example:
* <code>
* $result = eF_getTableData("completed_tests", "*", "id=".$_GET['show_solved_test']);
* $showTest = unserialize($result[0]['test']);
* $analysisResults = $showTest -> analyseSkillGapTest();
* $lessonsProposed = $analysisResults['lessons'];
* $coursesProposed = $analysisResults['courses'];
* </code>
*
* @return array containing the proposed all test related skills, all user missing skills, lesson and courses proposed for assignment in the form array( "testSkills" => array(...) , "missingSkills" => array(...), "lessons" => array(...), "courses" => array(...) )
* @since 3.5.2
* @access public
*/
public function analyseSkillGapTest()
{
// SUB-COMPONENT 1: Creation of the skill-gap matrix
$questionsAnswered = array();
foreach ($this->questions as $qid => $question) {
$questionsAnswered[$qid] = $question->score / 100;
}
// Acquire from the DB all skills related to the questions so that you can do the all the analysis based on the resulting skills table
$all_related_skills = eF_getTableData("module_hcd_skills JOIN questions_to_skills ON skills_ID = skill_ID", "*", "questions_ID IN ('" . implode("','", array_keys($questionsAnswered)) . "')");
$skills = array();
foreach ($questionsAnswered as $qid => $questions) {
foreach ($all_related_skills as $skill) {
if ($qid == $skill['questions_id']) {
if (isset($skills[$skill['skill_ID']])) {
$skills[$skill['skill_ID']]['correct'] = $skills[$skill['skill_ID']]['correct'] + $questions * $skill['relevance'];
$skills[$skill['skill_ID']]['total'] = $skills[$skill['skill_ID']]['total'] + $skill['relevance'];
} else {
$skills[$skill['skill_ID']] = array("id" => $skill['skill_ID'], "skill" => $skill['description'], "correct" => $questions * $skill['relevance'], "total" => $skill['relevance']);
}
}
}
}
foreach ($skills as $skid => $skill) {
$skills[$skid]['score'] = 100 * $skill['correct'] / $skill['total'];
}
// SUB-COMPONENT 2: Make the skill-gap analysis
$analysisResults = array();
$analysisResults['testSkills'] = $skills;
// Get this test's general threshold
$testOrig = eF_getTableData("tests", "options", "id = '" . $this->completedTest['testsId'] . "'");
$temp = unserialize($testOrig[0]['options']);
$this->options['general_threshold'] = $temp['general_threshold'];
// Get the missing skills according to the analysis
$skills_missing = array();
$all_skills = "";
foreach ($skills as $skill_item) {
if ($skill_item['score'] < $this->options['general_threshold']) {
// TOCHANGE: with the threshold of each separate test
$skills_missing[] = $skill_item['id'];
$all_skills .= "&" . $skill_item['id'] . "=1";
} else {
$all_skills .= "&" . $skill_item['id'] . "=0";
}
}
// This smarty variable will denote all missing and existing skills
$analysisResults['missingSkills'] = $all_skills;
$skills_missing = implode("','", $skills_missing);
$user = EfrontUserFactory::factory($this->completedTest['login']);
// SUB-COMPONENT 3: Propose lessons and courses
$lessons_attending = implode("','", array_keys($user->getLessons()));
$analysisResults['lessons'] = eF_getTableData("module_hcd_skills LEFT OUTER JOIN module_hcd_lesson_offers_skill ON module_hcd_skills.skill_ID = module_hcd_lesson_offers_skill.skill_ID", "module_hcd_lesson_offers_skill.lesson_ID, count(module_hcd_lesson_offers_skill.skill_ID) as skills_offered", "module_hcd_lesson_offers_skill.skill_ID IN ('" . $skills_missing . "') AND module_hcd_lesson_offers_skill.lesson_ID NOT IN ('" . $lessons_attending . "')", "", "module_hcd_lesson_offers_skill.lesson_ID ORDER BY skills_offered DESC");
$courses_attending = implode("','", array_keys($user->getUserCourses()));
$analysisResults['courses'] = eF_getTableData("module_hcd_skills LEFT OUTER JOIN module_hcd_course_offers_skill ON module_hcd_skills.skill_ID = module_hcd_course_offers_skill.skill_ID", "module_hcd_course_offers_skill.courses_ID, count(module_hcd_course_offers_skill.skill_ID) as skills_offered", "module_hcd_course_offers_skill.skill_ID IN ('" . $skills_missing . "') AND module_hcd_course_offers_skill.courses_ID NOT IN ('" . $courses_attending . "')", "", "module_hcd_course_offers_skill.courses_ID ORDER BY skills_offered DESC");
return $analysisResults;
}
示例2: EfrontEmployee
$employee = new EfrontEmployee($new_employees_content, array());
$newUser = EfrontUserFactory::factory($values['login']);
//$encrypted = false; //the factory above changed the user password mode
if ($configuration['supervisor_mail_activation'] == 1 && $job_assigned['supervisor'] != "") {
$activating_supervisor_found = true;
$employee->addJob($newUser, $new_job_description_ID, $job_assigned['branch_ID'], 0, false, array("manager" => $job_assigned['supervisor'], "timestamp" => $newUser->user['timestamp']));
} else {
$employee->addJob($newUser, $new_job_description_ID, $job_assigned['branch_ID'], 0);
}
}
}
if ($_SESSION['s_current_branch']) {
$employee = new EfrontEmployee($new_employees_content, array());
if (!in_array($_SESSION['s_current_branch'], $employee->getBranches(true))) {
$new_job_description_ID = eF_getJobDescriptionId(_NOSPECIFICJOB, $_SESSION['s_current_branch']);
$newUser = EfrontUserFactory::factory($values['login']);
$employee->addJob($newUser, $new_job_description_ID, $_SESSION['s_current_branch'], 0);
}
}
} catch (Exception $e) {
$newUser->delete();
eF_redirect(basename($_SERVER['PHP_SELF']) . '?ctg=signup&message=' . urlencode($e->getMessage()) . '&message_type=failure');
}
}
#cpp#endif
if ($configuration['activation'] == 0) {
if ($configuration['mail_activation'] == 1) {
$tmp = eF_getTableData("users", "timestamp, login, name,surname", "login='" . $user_data['login'] . "'");
$timestamp = $tmp[0]["timestamp"];
EfrontEvent::triggerEvent(array("type" => EfrontEvent::SYSTEM_ON_EMAIL_ACTIVATION, "users_LOGIN" => $tmp[0]['login'], "users_name" => $tmp[0]['name'], "users_surname" => $tmp[0]['surname'], "timestamp" => $timestamp, "entity_name" => $timestamp));
$message = _YOUWILLRECEIVEMAILFORACCOUNTACTIVATION;
示例3: convertDatabaseResultToUserObjects
public static function convertDatabaseResultToUserObjects($result)
{
$roles = EfrontLessonUser::getRoles();
$userObjects = array();
foreach ($result as $value) {
$userObjects[$value['login']] = EfrontUserFactory::factory($value, false, $value['role'] ? $roles[$value['role']] : false);
}
return $userObjects;
}
示例4: catch
echo "<status>error</status>";
echo "<message>Incomplete arguments</message>";
echo "</xml>";
}
} else {
echo "<xml>";
echo "<status>error</status>";
echo "<message>Invalid token</message>";
echo "</xml>";
}
break;
case 'user_info':
if (isset($_GET['token']) && checkToken($_GET['token'])) {
if (isset($_GET['login'])) {
try {
$user = EfrontUserFactory::factory($_GET['login']);
echo "<xml>";
echo "<general_info>";
echo "<name>" . $user->user['name'] . " " . $user->user['surname'] . "</name>";
echo "<active>" . $user->user['active'] . "</active>";
echo "<user_type>" . $user->user['user_type'] . "</user_type>";
echo "</general_info>";
echo "</xml>";
} catch (Exception $e) {
echo "<xml>";
echo "<status>error</status>";
echo "<message>User doesn't exist</message>";
echo "</xml>";
}
} else {
echo "<xml>";
示例5: session_cache_limiter
/**
* This file is used to display a small files list, and is used
* inside the "insert image" operation of the editor
*/
//General initialization and parameters
session_cache_limiter('none');
session_id($_COOKIE['parent_sid']);
session_start();
$path = "../../libraries/";
/** Configuration file.*/
include_once $path . "configuration.php";
//Access is not allowed to users that are not logged in
if (isset($_SESSION['s_login']) && $_SESSION['s_password']) {
try {
$currentUser = EfrontUserFactory::factory($_SESSION['s_login']);
} catch (EfrontException $e) {
$message = $e->getMessage() . ' (' . $e->getCode() . ')';
eF_redirect("index.php?message=" . urlencode($message) . "&message_type=failure");
exit;
}
} else {
eF_redirect("index.php?message=" . urlencode(_YOUCANNOTACCESSTHISPAGE) . "&message_type=failure");
exit;
}
try {
//There are 2 legal modes: 'lessons' and 'external'. In the first case, we read the legitimate directory from the session. In the second case, we take it from global constant
if ($_GET['mode'] == 'lesson') {
$currentLesson = new EfrontLesson($_SESSION['s_lessons_ID']);
$rootDir = new EfrontDirectory($currentLesson->getDirectory());
$filesBaseUrl = $currentLesson->getDirectoryUrl();
示例6: export
//.........这里部分代码省略.........
$projects = eF_getTableData("projects", "*", "lessons_ID=" . $this->lesson['id']);
if (sizeof($projects) > 0) {
$data['projects'] = $projects;
}
$lesson_files = eF_getTableData("files", "*", "path like '" . str_replace(G_ROOTPATH, '', EfrontDirectory::normalize($this->getDirectory())) . "%'");
if (sizeof($lesson_files) > 0) {
$data['files'] = $lesson_files;
}
if (G_VERSIONTYPE != 'community') {
#cpp#ifndef COMMUNITY
if (G_VERSIONTYPE != 'standard') {
#cpp#ifndef STANDARD
//Export scorm tables from here over
$scormLessonTables = array('scorm_sequencing_adlseq_map_info', 'scorm_sequencing_content_to_organization', 'scorm_sequencing_maps_info', 'scorm_sequencing_organizations');
foreach ($scormLessonTables as $table) {
$scorm_data = eF_getTableData($table, "*", "lessons_ID=" . $this->lesson['id']);
if (sizeof($scorm_data) > 0) {
$data[$table] = $scorm_data;
}
}
$scormContentTables = array('scorm_sequencing_completion_threshold', 'scorm_sequencing_constrained_choice', 'scorm_sequencing_control_mode', 'scorm_sequencing_delivery_controls', 'scorm_sequencing_hide_lms_ui', 'scorm_sequencing_limit_conditions', 'scorm_sequencing_maps', 'scorm_sequencing_map_info', 'scorm_sequencing_objectives', 'scorm_sequencing_rollup_considerations', 'scorm_sequencing_rollup_controls', 'scorm_sequencing_rollup_rules', 'scorm_sequencing_rules');
if ($content_list) {
foreach ($scormContentTables as $table) {
$scorm_data = eF_getTableData($table, "*", "content_ID IN ({$content_list})");
if (sizeof($scorm_data) > 0) {
$data[$table] = $scorm_data;
}
if ($table == 'scorm_sequencing_rollup_rules' && sizeof($scorm_data) > 0) {
$ids = array();
foreach ($scorm_data as $value) {
$ids[] = $value['id'];
}
$result = eF_getTableData('scorm_sequencing_rollup_rule', "*", "scorm_sequencing_rollup_rules_ID IN (" . implode(",", $ids) . ")");
$data['scorm_sequencing_rollup_rule'] = $result;
}
if ($table == 'scorm_sequencing_rules' && sizeof($scorm_data) > 0) {
$ids = array();
foreach ($scorm_data as $value) {
$ids[] = $value['id'];
}
$result = eF_getTableData('scorm_sequencing_rule', "*", "scorm_sequencing_rules_ID IN (" . implode(",", $ids) . ")");
$data['scorm_sequencing_rule'] = $result;
}
}
}
}
#cpp#endif
}
#cpp#endif
//'scorm_sequencing_rollup_rule', 'scorm_sequencing_rule',
// MODULES - Export module data
// Get all modules (NOT only the ones that have to do with the user type)
$modules = eF_loadAllModules();
foreach ($modules as $module) {
if ($moduleData = $module->onExportLesson($this->lesson['id'])) {
$data[$module->className] = $moduleData;
}
}
file_put_contents($this->directory . '/' . "data.dat", serialize($data));
//Create database dump file
if ($exportFiles) {
$lessonDirectory = new EfrontDirectory($this->directory);
$file = $lessonDirectory->compress($this->lesson['id'] . '_exported.zip', false);
//Compress the lesson files
} else {
$dataFile = new EfrontFile($this->directory . '/' . "data.dat");
$file = $dataFile->compress($this->lesson['id'] . '_exported.zip');
}
$newList = FileSystemTree::importFiles($file['path']);
//Import the file to the database, so we can download it
$file = new EfrontFile(current($newList));
if (empty($GLOBALS['currentUser'])) {
if ($_SESSION['s_login']) {
$GLOBALS['currentUser'] = EfrontUserFactory::factory($_SESSION['s_login']);
$userTempDir = $GLOBALS['currentUser']->user['directory'] . '/temp';
} else {
$userTempDir = sys_get_temp_dir();
}
} else {
$userTempDir = $GLOBALS['currentUser']->user['directory'] . '/temp';
}
if (!is_dir($userTempDir)) {
//If the user's temp directory does not exist, create it
$userTempDir = EfrontDirectory::createDirectory($userTempDir, false);
$userTempDir = $userTempDir['path'];
}
try {
$existingFile = new EfrontFile($userTempDir . '/' . EfrontFile::encode($this->lesson['name']) . '.zip');
//Delete any previous exported files
$existingFile->delete();
} catch (Exception $e) {
}
if ($rename) {
$newName = str_replace(array('"', '>', '<', '*', '?', ':'), array('"', '>', '<', '*', '?', ':'), $this->lesson['name']);
$file->rename($userTempDir . '/' . EfrontFile::encode($newName) . '.zip', true);
}
unlink($this->directory . '/' . "data.dat");
//Delete database dump file
return $file;
}
示例7: importData
//.........这里部分代码省略.........
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) {
示例8: askInformation
//.........这里部分代码省略.........
$tooltipInfo[] = '<div class = "infoEntry"><span>' . _OTHERINFO . "</span><span>: {$value}</span></div>";
break;
case 'price_string':
!$lesson->lesson['course_only'] ? $tooltipInfo[] = '<div class = "infoEntry"><span>' . _PRICE . "</span><span>: {$value}</span></div>" : null;
break;
default:
break;
}
}
}
if ($string = implode("", $tooltipInfo)) {
echo $string;
} else {
echo _NODATAFOUND;
}
}
if (isset($_GET['courses_ID']) && eF_checkParameter($_GET['courses_ID'], 'id')) {
$course = new EfrontCourse($_GET['courses_ID']);
$courseInformation = $course->getInformation();
$languages = EfrontSystem::getLanguages(true);
if ($courseInformation['professors']) {
foreach ($courseInformation['professors'] as $value) {
$professorsString[] = $value['name'] . ' ' . $value['surname'];
}
$courseInformation['professors'] = implode(", ", $professorsString);
}
$course->course['price'] ? $priceString = formatPrice($course->course['price'], array($course->options['recurring'], $course->options['recurring_duration']), true) : ($priceString = false);
$courseInformation['price_string'] = $priceString;
foreach ($courseInformation as $key => $value) {
if ($value) {
switch ($key) {
case 'language':
$tooltipInfo[] = '<div class = "infoEntry"><span>' . _LANGUAGE . "</span><span>: {$languages[$value]}</span></div>";
break;
case 'professors':
$tooltipInfo[] = '<div class = "infoEntry"><span>' . _PROFESSORS . "</span><span>: {$value}</span></div>";
break;
case 'lessons_number':
$tooltipInfo[] = '<div class = "infoEntry"><span>' . _LESSONS . "</span><span>: {$value}</span></div>";
break;
case 'instances':
$tooltipInfo[] = '<div class = "infoEntry"><span>' . _COURSEINSTANCES . "</span><span>: {$value}</span></div>";
break;
case 'general_description':
$tooltipInfo[] = '<div class = "infoEntry"><span>' . _DESCRIPTION . "</span><span>: {$value}</span></div>";
break;
case 'assessment':
$tooltipInfo[] = '<div class = "infoEntry"><span>' . _ASSESSMENT . "</span><span>: {$value}</span></div>";
break;
case 'objectives':
$tooltipInfo[] = '<div class = "infoEntry"><span>' . _OBJECTIVES . "</span><span>: {$value}</span></div>";
break;
case 'lesson_topics':
$tooltipInfo[] = '<div class = "infoEntry"><span>' . _COURSETOPICS . "</span><span>: {$value}</span></div>";
break;
case 'resources':
$tooltipInfo[] = '<div class = "infoEntry"><span>' . _RESOURCES . "</span><span>: {$value}</span></div>";
break;
case 'other_info':
$tooltipInfo[] = '<div class = "infoEntry"><span>' . _OTHERINFO . "</span><span>: {$value}</span></div>";
break;
case 'price_string':
$tooltipInfo[] = '<div class = "infoEntry"><span>' . _PRICE . "</span><span>: {$value}</span></div>";
break;
default:
break;
}
}
}
if ($string = implode("", $tooltipInfo)) {
echo $string;
} else {
echo _NODATAFOUND;
}
}
// For eFront social
if (isset($_GET['common_lessons']) && isset($_GET['user1']) && isset($_GET['user2'])) {
$user1 = EfrontUserFactory::factory($_GET['user1']);
if ($user1->getType() != "administrator") {
$common_lessons = $user1->getCommonLessons($_GET['user2']);
// pr($common_lessons);
foreach ($common_lessons as $id => $lesson) {
if (strlen($lesson['name']) > 25) {
$lesson['name'] = substr($lesson['name'], 0, 22) . "...";
}
$tooltipInfo[] = '<div class = "infoEntry"><span>' . $lesson['name'] . "</span><span></span></div>";
}
if ($string = implode("", $tooltipInfo)) {
echo $string;
} else {
echo _NODATAFOUND;
}
} else {
echo _NODATAFOUND;
}
}
} catch (Exception $e) {
handleAjaxExceptions($e);
}
}
示例9: json_decode
}
if (isset($_GET['complete']) && isset($_GET['ajax'])) {
if (isset($currentUser->coreAccess['progress']) && $currentUser->coreAccess['progress'] != 'change') {
exit;
}
$completeEntities = json_decode($_GET['complete']);
if (!empty($completeEntities)) {
if (eF_checkParameter($_GET['date'], 'date')) {
$date = explode('-', $_GET['date']);
$timestamp = mktime(0, 0, 0, $date[1], $date[0], $date[2]);
}
$list = '"' . implode('","', $completeEntities) . '"';
$info = eF_getTableData("users_to_lessons", "users_LOGIN,lessons_ID,completed,score,to_timestamp,comments", "users_LOGIN IN (" . $list . ") and lessons_ID = " . $currentLesson->lesson['id']);
foreach ($info as $value) {
if ($value['completed'] == 0) {
$user = EfrontUserFactory::factory($value['users_LOGIN']);
$user->completeLesson($currentLesson->lesson['id'], 100, '', $timestamp);
}
}
}
exit;
}
if (isset($_GET['uncomplete']) && isset($_GET['ajax'])) {
if (isset($currentUser->coreAccess['progress']) && $currentUser->coreAccess['progress'] != 'change') {
exit;
}
$uncompleteEntities = json_decode($_GET['uncomplete']);
if (!empty($uncompleteEntities)) {
$list = '"' . implode('","', $uncompleteEntities) . '"';
$info = eF_getTableData("users_to_lessons", "users_LOGIN,lessons_ID,completed,score,to_timestamp,comments", "users_LOGIN IN (" . $list . ") and lessons_ID = " . $currentLesson->lesson['id']);
foreach ($info as $value) {
示例10: getUserUsageInfo
/**
* Get user usage info
*
* This returns usage info for a user
* <br/>Example:
* <code>
* $info = EfrontStats :: getUserUsageInfo('jdoe'); //Get usage information for user jdoe
* </code>
* @param mixed $user Either a user login or a EfrontUser object
* @return array the users' basic info
* @since 3.5.0
* @access public
* @static
*/
public static function getUserUsageInfo($user)
{
if (!$user instanceof EfrontUser) {
$user = EfrontUserFactory::factory($user);
}
$info = array();
$login_info = eF_getTableData("logs", "*", "users_LOGIN='" . $user->login . "' and action = 'login'", "timestamp desc");
$info['last_ip'] = eF_decodeIP($login_info[0]['session_ip']);
$logins = array();
foreach ($login_info as $login) {
$logins[$login['id']] = $login;
}
$month_login_info = eF_getTableData("logs", "*", "users_LOGIN='" . $user->login . "' and action = 'login' and timestamp > " . (time() - 2592000) . "");
$month_logins = array();
foreach ($month_login_info as $login) {
$month_logins[$login['id']] = $login;
}
$week_login_info = eF_getTableData("logs", "*", "users_LOGIN='" . $user->login . "' and action = 'login' and timestamp > " . (time() - 604800) . "");
$week_logins = array();
foreach ($week_login_info as $login) {
$week_logins[$login['id']] = $login;
}
$timeReport = new EfrontTimes();
$mean_duration = round($timeReport->getUserMeanSessionTime($user->login) / 60);
$timeReport = new EfrontTimes(array(time() - 2592000, time()));
$month_mean_duration = round($timeReport->getUserMeanSessionTime($user->login) / 60);
$timeReport = new EfrontTimes(array(time() - 604800, time()));
$week_mean_duration = round($timeReport->getUserMeanSessionTime($user->login) / 60);
/*
$temp = self :: getUserTimes($user -> login);
sizeof($temp['duration']) > 0 ? $mean_duration = ceil((array_sum($temp['duration']) / sizeof($temp['duration'])) / 60) : $mean_duration = 0;
$temp = self :: getUserTimes($user -> login, array('from' => time() - 2592000, 'to' => time()));
sizeof($temp['duration']) > 0 ? $month_mean_duration = ceil((array_sum($temp['duration']) / sizeof($temp['duration']) / 60)) : $month_mean_duration = 0;
$temp = self :: getUserTimes($user -> login, array('from' => time() - 604800, 'to' => time()));
sizeof($temp['duration']) > 0 ? $week_mean_duration = ceil((array_sum($temp['duration']) / sizeof($temp['duration']) / 60)) : $week_mean_duration = 0;
*/
$info['logins'] = $logins;
if (sizeof($info['logins']) > 0) {
$info['last_login'] = current($info['logins']);
}
$info['month_logins'] = $month_logins;
$info['week_logins'] = $week_logins;
$info['mean_duration'] = $mean_duration;
$info['month_mean_duration'] = $month_mean_duration;
$info['week_mean_duration'] = $week_mean_duration;
return $info;
}
示例11: array_search
$index = array_search($lesson, array_keys($usersTolessons[$user]));
if ($index !== false) {
unset($lessons[$index]);
}
}
if (!empty($lessons)) {
$user -> addLessons($lessons, $userType, 1); //active lessons
}
}
}
}
*/
if ($currentGroup->group['user_types_ID'] == '0') {
foreach ($groupUsers as $user) {
$user = EfrontUserFactory::factory($user);
$user->user['user_types_ID'] ? $userType[] = $user->user['user_types_ID'] : ($userType[] = $user->user['user_type']);
}
} else {
$userType = $currentGroup->group['user_types_ID'];
}
foreach ($lessonIds as $id) {
$lesson = new EfrontLesson($id);
$lesson->addUsers($groupUsers, $userType, true, true);
}
}
}
}
}
}
}
示例12: getRecipients
public function getRecipients()
{
$recipients_list = array();
if (isset($this->notification['send_conditions'])) {
//echo $this -> notification['send_conditions'];
if ($this->notification['send_conditions'] == "N;") {
$recipients = eF_getTableData("users", "*", "active=1 and archive=0");
//sending_queue_msgs[$key]['recipients'] = _ALLUSERS;
foreach ($recipients as $recipient) {
$recipients_list[$recipient['login']] = $recipient;
}
} else {
// the send_conditions field contains the information which identify the recipients
// it is defined in ....
//digests.php during the definition of the event notification
$this->notification['send_conditions'] = unserialize($this->notification['send_conditions']);
if ($this->notification['send_conditions'] == "supervisors") {
if (G_VERSIONTYPE == 'enterprise') {
#cpp#ifdef ENTERPRISE
$recipients = eF_getTableData("module_hcd_employee_works_at_branch as meb, users as u", "u.*", "meb.users_login=u.login and u.active=1 and u.archive=0 and meb.supervisor=1");
foreach ($recipients as $recipient) {
$recipients_list[$recipient['login']] = $recipient;
}
}
#cpp#endif
} elseif (is_array($this->notification['send_conditions'])) {
$this->recipients = $this->notification['send_conditions'];
// The recipients array definitely exists, due to constructor checks
if (isset($this->recipients["lessons_ID"]) && $this->recipients["lessons_ID"]) {
$lesson = new EfrontLesson($this->recipients["lessons_ID"]);
if (isset($this->recipients["user_type"])) {
// return lesson users of specific type
$recipients = array();
foreach ($lesson->getUsers($this->recipients["user_type"]) as $value) {
if ($value['active']) {
$recipients[] = $value;
}
}
} else {
if (isset($this->recipients["completed"])) {
// return lesson students according to whether they have completed the lesson or not
$recipients = array();
foreach ($lesson->getUsersCompleted($this->recipients["completed"]) as $value) {
if ($value['active']) {
$recipients[] = $value;
}
}
} else {
// return all users
$recipients = array();
foreach ($lesson->getUsers() as $value) {
if ($value['active']) {
$recipients[] = $value;
}
}
}
}
} else {
if (isset($this->recipients["courses_ID"])) {
$entity_parts = explode("_", $this->notification['id_type_entity']);
$notification_type = $entity_parts[1];
if ($this->recipients['user_type'] == "professor") {
$completed_condition = " AND uc.user_type = 'professor'";
} else {
if ($this->recipients['completed'] == "1") {
$completed_condition = " AND completed = '1'";
} else {
if ($this->recipients['completed'] == "2" || $notification_type == EfrontEvent::COURSE_PROGRAMMED_EXPIRY) {
$completed_condition = " AND completed = '0' and uc.user_type in ('" . implode("','", array_keys(EfrontLessonUser::getStudentRoles())) . "')";
} else {
$completed_condition = "";
}
}
}
if ($this->recipients['supervisor']) {
if ($this->recipients['users_login']) {
$editedUser = EfrontUserFactory::factory($this->recipients['users_login']);
//new EfrontUser();
$editedEmployee = $editedUser->aspects['hcd'];
$supervisors = $editedEmployee->getSupervisors();
$recipients = array();
foreach ($supervisors as $supervisor) {
$recipients[$supervisor] = array("login" => $supervisor);
}
} else {
$query = "select distinct u.login, u.name, u.surname, u.email, u.user_type as basic_user_type, u.active, u.user_types_ID from module_hcd_employee_works_at_branch ewb join users u on u.login=ewb.users_login where supervisor=1 and u.active=1 and u.archive=0 and branch_ID in (select branch_ID from module_hcd_employee_works_at_branch ewb, users_to_courses uc where uc.users_LOGIN=ewb.users_login and uc.courses_ID=" . $this->recipients["courses_ID"] . " and uc.archive=0)";
//get course users' supervisors
$result = eF_executeNew($query);
$recipients = $result->getAll();
}
} elseif ($this->recipients['immediate_supervisor']) {
if ($this->recipients['users_login']) {
$result = eF_getTableDataFlat("module_hcd_employee_works_at_branch", "users_LOGIN", "supervisor=1 and assigned=1 and branch_ID IN (select branch_ID from module_hcd_employee_works_at_branch where assigned=1 and supervisor=0 and users_login='" . $this->recipients['users_login'] . "')");
$recipients = array();
foreach ($result['users_LOGIN'] as $supervisor) {
$recipients[$supervisor] = array("login" => $supervisor);
}
$filtered_recipients = array();
if (!empty($recipients)) {
$active_recipients = eF_getTableDataFlat("users", "login", "active=1 and archive=0 and login IN ('" . implode("','", array_keys($recipients)) . "')");
//.........这里部分代码省略.........
示例13: EfrontDirectionsTree
}
//foreach ($courses as $key => $course) {
//$courses[$key]['languages_NAME'] = $languages[$course['languages_NAME']];
//}
$smarty->assign("T_ASSIGNED_COURSES_DATA", $courses);
$smarty->display('administrator.tpl');
exit;
}
if (isset($_GET['ajax']) && $_GET['ajax'] == 'coursesTable') {
$directionsTree = new EfrontDirectionsTree();
$directionPaths = $directionsTree->toPathString();
$courses = EfrontCourse::getCourses();
if ($_SESSION['s_type'] == 'administrator') {
$editedUser = EfrontUserFactory::factory($_GET['user']);
} else {
$editedUser = EfrontUserFactory::factory($_SESSION['s_login']);
}
$userCourses = $editedUser->getUserCourses();
foreach ($courses as $key => $course) {
$courses[$key]['partof'] = 0;
$courses[$key]['directions_name'] = $directionPaths[$course['directions_ID']];
$courses[$key]['user_type'] = $editedUser->user['user_types_ID'] ? $editedUser->user['user_types_ID'] : $editedUser->user['user_type'];
if (in_array($course['id'], array_keys($userCourses))) {
$courses[$key]['from_timestamp'] = $userCourses[$key]->course['active_in_course'];
$courses[$key]['partof'] = 1;
$courses[$key]['user_type'] = $userCourses[$key]->course['user_type'];
$courses[$key]['completed'] = $userCourses[$key]->course['completed'];
$courses[$key]['score'] = $userCourses[$key]->course['score'];
} else {
if ($currentUser->user['user_type'] != 'administrator' || !$course['active']) {
unset($courses[$key]);
示例14: toHTML
//.........这里部分代码省略.........
if ($size) {
$fileArrays = eF_multiSort($fileArrays, $ajaxOptions['sort'], $ajaxOptions['order']);
$ajaxOptions['filter'] ? $fileArrays = eF_filterData($fileArrays, $ajaxOptions['filter']) : null;
$fileArrays = array_slice($fileArrays, $ajaxOptions['offset'], $ajaxOptions['limit']);
}
$extraColumnsString = '';
foreach ($extraColumns as $value) {
$extraColumnsString = '<td class = "topTitle centerAlign" name = "' . $value . '">' . $value . '</td>';
}
$filesCode = '
<table class = "sortedTable" style = "width:100%" size = "' . $size . '" id = "' . $tableId . '" useAjax = "1" rowsPerPage = "20" other = "' . urlencode($currentDirectory) . '" url = "' . $url . '&" nomass = "1" currentDir = "' . (isset($currentDir['path']) ? $currentDir['path'] : '') . '">
<tr>' . ($options['show_type'] ? '<td class = "topTitle centerAlign" name = "extension">' . _TYPE . '</td>' : '') . '
' . ($options['show_name'] ? '<td class = "topTitle" name = "name" id = "filename_' . $tableId . '">' . _NAME . '</td>' : '') . '
' . ($options['show_size'] ? '<td class = "topTitle" name = "size">' . _SIZE . '</td>' : '') . '
' . ($options['show_date'] ? '<td class = "topTitle" name = "timestamp">' . _MODIFIED . '</td>' : '') . '
' . $extraColumnsString . '
' . ($_SESSION['s_lessons_ID'] && $options['share'] ? '<td class = "topTitle centerAlign" name = "shared">' . _SHARE . '</td>' : '') . '
' . ($options['show_tools'] ? '<td class = "topTitle centerAlign noSort">' . _OPERATIONS . '</td>' : '') . '
' . ($options['delete'] || $_SESSION['s_lessons_ID'] && $options['share'] ? '<td class = "topTitle centerAlign">' . _SELECT . '</td>' : '') . '
</tr>';
if (isset($parentDir)) {
if ($parentDir['path'] == $this->dir['path']) {
$parentDir['path'] = '';
}
$filesCode .= '
<tr class = "defaultRowHeight eventRowColor"><td class = "centerAlign" colspan = "100%">' . _CURRENTLYBROWSINGFOLDER . ': ' . EfrontFile::decode(str_replace($this->dir['path'], '', $currentDir['path'])) . '</td></tr>
<tr class = "defaultRowHeight oddRowColor">
<td class = "centerAlign"><span style = "display:none"></span><img src = "images/16x16/folder_up.png" alt = "' . _UPONELEVEL . '" title = "' . _UPONELEVEL . '"/></td>
<td><a class="editLink" href = "javascript:void(0)" onclick = "eF_js_rebuildTable($(\'filename_' . $tableId . '\').down().getAttribute(\'tableIndex\'), 0, \'\', \'desc\', \'' . urlencode($parentDir['path']) . '\');">.. (' . _UPONELEVEL . ')</a></td>
<td colspan = "5"></td></tr>';
}
$i = 0;
if ($_SESSION['supervises_branches'] != "") {
$currentEmployee = EfrontUserFactory::factory($_SESSION['s_login']);
$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.*, count(job_description_ID) as jobs_num", " 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') OR EXISTS (SELECT module_hcd_employees.users_login FROM module_hcd_employees LEFT OUTER JOIN module_hcd_employee_works_at_branch ON module_hcd_employee_works_at_branch.users_login = module_hcd_employees.users_login WHERE users.login=module_hcd_employees.users_login AND module_hcd_employee_works_at_branch.branch_ID IS NULL)) GROUP BY login", "login");
$supervisedLogins = array();
foreach ($employees as $key2 => $value2) {
if (!$value2['active'] || $value2['archive'] || !$value2['jobs_num']) {
unset($employees[$key2]);
} else {
$supervisedLogins[] = $value2['login'];
}
}
}
foreach ($fileArrays as $key => $value) {
$toolsString = '';
$sharedString = '';
if (is_file($value['path'])) {
$value['id'] == -1 ? $identifier = $value['path'] : ($identifier = $value['id']);
//The file/directory identifier will be the id, if the entity has a database representation, or the file path otherwise
$value = new EfrontFile($value);
//Restore file/directory representation, so we can use its methods
$link = $url . '&view=' . urlencode($identifier);
foreach ($extraFileTools as $tool) {
//$toolsString .= '<a href = "javascript:void(0)"><img src = "'.$tool['image'].'" alt = "'.$tool['title'].'" title = "'.$tool['title'].'" border = "0" onclick = "'.$tool['action'].'(this, \''.urlencode($identifier).'\')" /></a> ';
$toolsString .= '<a href = "javascript:void(0)"><img src = "' . $tool['image'] . '" alt = "' . $tool['title'] . '" title = "' . $tool['title'] . '" border = "0" onclick = "' . $tool['action'] . '(this, $(\'span_' . urlencode($identifier) . '\').innerHTML)" /></a> ';
}
if (($value['extension'] == 'zip' || $value['extension'] == 'gz') && $options['zip']) {
$toolsString .= '<a href = "javascript:void(0)"><img src = "images/16x16/uncompress.png" alt = "' . _UNCOMPRESS . '" title = "' . _UNCOMPRESS . '" border = "0" onclick = "uncompressFile(this, $(\'span_' . urlencode($identifier) . '\').innerHTML)" /></a> ';
}
if ($options['download']) {
$toolsString .= '<a href = "' . $url . '&download=' . urlencode($identifier) . '"><img src = "images/16x16/import.png" alt = "' . _DOWNLOADFILE . '" title = "' . _DOWNLOADFILE . '" border = "0"/></a> ';
}
if ($_SESSION['s_lessons_ID'] && $options['share']) {
$sharedString = '
<img class = "ajaxHandle" src = "images/16x16/trafficlight_green.png" alt = "' . _UNSHARE . '" title = "' . _UNSHARE . '" onclick = "unshareFile(this, $(\'span_' . urlencode($identifier) . '\').innerHTML)" style = "' . (!$value['shared'] ? 'display:none' : null) . '" />
示例15: doCategoryReports
private function doCategoryReports()
{
$smarty = $this->getSmartyVar();
$currentUser = $this->getCurrentUser();
$directionsTree = new EfrontDirectionsTree();
$directionPaths = $directionsTree->toPathString();
$form = new HTML_QuickForm("category_form", "post", basename($_SERVER['PHP_SELF']) . "?ctg=module&op=module_administrator_tools&tab=category_reports&do=enterprise", "", null, true);
$form->addElement('select', 'category', _CATEGORY, $directionPaths);
$form->addElement('checkbox', 'incomplete', _MODULE_ADMINISTRATOR_TOOLS_SHOWINCOMPLETE);
$form->addElement('checkbox', 'inactive', _MODULE_ADMINISTRATOR_TOOLS_SHOWINACTIVECOURSES);
$form->addElement('date', 'from_timestamp', _MODULE_ADMINISTRATOR_TOOLS_COMPLETEDFROM, array('minYear' => 1970, 'maxYear' => date("Y")));
$form->addElement('date', 'to_timestamp', _MODULE_ADMINISTRATOR_TOOLS_COMPLETEDTO, array('minYear' => 1970, 'maxYear' => date("Y")));
$form->addElement("submit", "submit", _SUBMIT, 'class = "flatButton"');
$form->setDefaults(array("from_timestamp" => mktime(0, 0, 0, date("m") - 1, date("d"), date("Y")), "to_timestamp" => time()));
if ($form->isSubmitted() && $form->validate()) {
$values = $form->exportValues();
$_SESSION['from_timestamp'] = mktime(0, 0, 0, $_POST['from_timestamp']['M'], $_POST['from_timestamp']['d'], $_POST['from_timestamp']['Y']);
$_SESSION['to_timestamp'] = mktime(23, 59, 59, $_POST['to_timestamp']['M'], $_POST['to_timestamp']['d'], $_POST['to_timestamp']['Y']);
$_SESSION['category'] = $values['category'];
$_SESSION['incomplete'] = $values['incomplete'];
$_SESSION['inactive'] = $values['inactive'];
$smarty->assign("T_SHOW_TABLE", true);
}
if (isset($_GET['ajax']) && $_GET['ajax'] == 'categoryUsersTable' || $_GET['ajax'] == 'xls' || $_GET['ajax'] == 'show_xls') {
$smarty->assign("T_SHOW_TABLE", true);
$smarty->assign("T_DIRECTIONS_TREE", $directionPaths);
$branchesTree = new EfrontBranchesTree();
$branchesPaths = $branchesTree->toPathString();
$category = new EfrontDirection($_SESSION['category']);
$directionsTree = new EfrontDirectionsTree();
$children = $directionsTree->getNodeChildren($_SESSION['category']);
foreach (new EfrontAttributeFilterIterator(new RecursiveIteratorIterator(new RecursiveArrayIterator($children)), array('id')) as $value) {
$siblings[] = $value;
}
$result = eF_getTableDataFlat("courses", "id", "archive = 0 && directions_ID in (" . implode(",", $siblings) . ")");
$categoryCourses = $result['id'];
$resultCourses = eF_getTableDataFlat("users_to_courses uc, courses c", "distinct c.id", 'c.id=uc.courses_ID ' . (!$_SESSION['inactive'] ? 'and c.active=1' : '') . ' and uc.archive=0 and uc.completed=1 and uc.to_timestamp >= ' . $_SESSION['from_timestamp'] . ' and uc.to_timestamp <= ' . $_SESSION['to_timestamp']);
$resultEvents = eF_getTableDataFlat("events e, courses c", "distinct c.id", 'c.id=e.lessons_ID ' . (!$_SESSION['inactive'] ? 'and c.active=1' : '') . ' and e.type=54 and e.timestamp >= ' . $_SESSION['from_timestamp'] . ' and e.timestamp <= ' . $_SESSION['to_timestamp']);
if (empty($resultEvents)) {
$resultEvents['id'] = array();
}
$result = array_unique(array_merge($resultCourses['id'], $resultEvents['id']));
$categoryCourses = array_intersect(array_unique($categoryCourses), $result);
//count only courses that have users completed them
if ($_SESSION['incomplete']) {
$constraints = array('archive' => false, 'condition' => '(to_timestamp is null OR to_timestamp = 0 OR (to_timestamp >= ' . $_SESSION['from_timestamp'] . ' and to_timestamp <= ' . $_SESSION['to_timestamp'] . '))');
} else {
$constraints = array('archive' => false, 'condition' => 'completed=1 and to_timestamp >= ' . $_SESSION['from_timestamp'] . ' and to_timestamp <= ' . $_SESSION['to_timestamp']);
}
foreach ($categoryCourses as $courseId) {
$course = new EfrontCourse($courseId);
foreach ($course->getCourseUsers($constraints) as $value) {
$userBranches = $value->aspects['hcd']->getBranches();
$userSupervisors = $value->aspects['hcd']->getSupervisors();
$userSupervisor = end($userSupervisors);
$value->user['course_active'] = $course->course['active'];
$value->user['course_id'] = $course->course['id'];
$value->user['category'] = $directionPaths[$course->course['directions_ID']];
$value->user['course'] = $course->course['name'];
$value->user['directions_ID'] = $course->course['directions_ID'];
$value->user['branch'] = $branchesPaths[current($userBranches['employee'])];
$value->user['branch_ID'] = current($userBranches['employee']);
$value->user['supervisor'] = $userSupervisor;
$value->user['historic'] = false;
$unique = md5($value->user['to_timestamp'] . $value->user['course_id'] . $value->user['login']);
$courseUsers[$unique] = $value->user;
}
$result = eF_getTableData("events", "*", 'type=54 and lessons_ID=' . $courseId . ' and timestamp >= ' . $_SESSION['from_timestamp'] . ' and timestamp <= ' . $_SESSION['to_timestamp']);
//exit;
foreach ($result as $entry) {
try {
$value = EfrontUserFactory::factory($entry['users_LOGIN']);
if (!$value->user['archive']) {
$userBranches = $value->aspects['hcd']->getBranches();
$userSupervisors = $value->aspects['hcd']->getSupervisors();
//pr($entry['users_LOGIN']);pr($userSupervisors);pr(current($userSupervisors));
$userSupervisor = current($userSupervisors);
$value->user['course_active'] = $course->course['active'];
$value->user['course_id'] = $course->course['id'];
$value->user['category'] = $directionPaths[$course->course['directions_ID']];
$value->user['course'] = $course->course['name'];
$value->user['directions_ID'] = $course->course['directions_ID'];
$value->user['branch'] = $branchesPaths[current($userBranches['employee'])];
$value->user['branch_ID'] = current($userBranches['employee']);
$value->user['supervisor'] = $userSupervisor;
$value->user['to_timestamp'] = $entry['timestamp'];
$value->user['completed'] = 1;
$value->user['score'] = '';
$value->user['historic'] = true;
$unique = md5($value->user['to_timestamp'] . $value->user['course_id'] . $value->user['login']);
if (!isset($courseUsers[$unique])) {
$courseUsers[$unique] = $value->user;
}
}
} catch (Exception $e) {
/*Bypass non-existing users*/
}
}
}
if ($_GET['ajax'] == 'xls') {
//.........这里部分代码省略.........