/**
  * 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;
 }
Beispiel #2
0
                 $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='******'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;
 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;
 }
Beispiel #4
0
             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>";
/**
* 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();
 /**
  * Export lesson
  *
  * This function is used to export the current lesson's data to
  * a file, which can then be imported to other systems. Apart from
  * the lesson content, the user may optinally specify additional
  * information to export, using the $exportEntities array. If
  * $exportEntities is 'all', everything that can be exported, is
  * exported
  *
  * <br/>Example:
  * <code>
  * $exportedFile = $lesson -> export('all');
  * </code>
  *
  * @param array $exportEntities The additional data to export
  * @param boolean $rename Whether to rename the exported file with the same name as the lesson
  * @param boolean $exportFiles Whether to export files as well
  * @return EfrontFile The object of the exported data file
  * @since 3.5.0
  * @access public
  */
 public function export($exportEntities, $rename = true, $exportFiles = true)
 {
     if (!$exportEntities) {
         $exportEntities = array('export_surveys' => 1, 'export_announcements' => 1, 'export_glossary' => 1, 'export_calendar' => 1, 'export_comments' => 1, 'export_rules' => 1);
     }
     $data['lessons'] = $this->lesson;
     unset($data['lessons']['share_folder']);
     unset($data['lessons']['instance_source']);
     unset($data['lessons']['originating_course']);
     $content = eF_getTableData("content", "*", "lessons_ID=" . $this->lesson['id']);
     if (sizeof($content) > 0) {
         $contentIds = array();
         for ($i = 0; $i < sizeof($content); $i++) {
             $content[$i]['data'] = str_replace(G_SERVERNAME, "##SERVERNAME##", $content[$i]['data']);
             $content[$i]['data'] = str_replace("content/lessons/" . ($this->lesson['share_folder'] ? $this->lesson['share_folder'] : $this->lesson['id']), "##LESSONSLINK##", $content[$i]['data']);
             $contentIds[] = $content[$i]['id'];
         }
         $content_list = implode(",", array_values($contentIds));
         $data['content'] = $content;
         $questions = eF_getTableData("questions", "*", "lessons_ID=" . $this->lesson['id']);
         if (sizeof($questions) > 0) {
             for ($i = 0; $i < sizeof($questions); $i++) {
                 $questions[$i]['text'] = str_replace(G_SERVERNAME, "##SERVERNAME##", $questions[$i]['text']);
                 $questions[$i]['text'] = str_replace("content/lessons/" . ($this->lesson['share_folder'] ? $this->lesson['share_folder'] : $this->lesson['id']), "##LESSONSLINK##", $questions[$i]['text']);
             }
             $data['questions'] = $questions;
         }
         $tests = eF_getTableData("tests", "*", "lessons_ID=" . $this->lesson['id']);
         if (sizeof($tests)) {
             $testsIds = array();
             foreach ($tests as $key => $value) {
                 $testsIds[] = $value['id'];
             }
             $tests_list = implode(",", array_values($testsIds));
             $tests_to_questions = eF_getTableData("tests_to_questions", "*", "tests_ID IN ({$tests_list})");
             for ($i = 0; $i < sizeof($tests); $i++) {
                 $tests[$i]['description'] = str_replace(G_SERVERNAME, "##SERVERNAME##", $tests[$i]['description']);
                 $tests[$i]['description'] = str_replace("content/lessons/" . ($this->lesson['share_folder'] ? $this->lesson['share_folder'] : $this->lesson['id']), "##LESSONSLINK##", $tests[$i]['description']);
             }
             $data['tests'] = $tests;
             $data['tests_to_questions'] = $tests_to_questions;
         }
         if (isset($exportEntities['export_rules'])) {
             $rules = eF_getTableData("rules", "*", "lessons_ID=" . $this->lesson['id']);
             if (sizeof($rules) > 0) {
                 $data['rules'] = $rules;
             }
         }
         if (isset($exportEntities['export_comments'])) {
             $comments = eF_getTableData("comments", "*", "content_ID IN ({$content_list})");
             if (sizeof($comments) > 0) {
                 $data['comments'] = $comments;
             }
         }
     }
     if (isset($exportEntities['export_calendar'])) {
         $calendar = calendar::getLessonCalendarEvents($this);
         $calendar = array_values($calendar);
         if (sizeof($calendar) > 0) {
             $data['calendar'] = $calendar;
         }
     }
     if (isset($exportEntities['export_glossary'])) {
         $glossary = eF_getTableData("glossary", "*", "lessons_ID = " . $this->lesson['id']);
         if (sizeof($glossary) > 0) {
             $data['glossary'] = $glossary;
         }
     }
     if (isset($exportEntities['export_announcements'])) {
         $news = eF_getTableData("news", "*", "lessons_ID=" . $this->lesson['id']);
         if (sizeof($news) > 0) {
             $data['news'] = $news;
         }
     }
     if (isset($exportEntities['export_surveys'])) {
         $surveys = eF_getTableData("surveys", "*", "lessons_ID=" . $this->lesson['id']);
         //prepei na ginei to   lesson_ID -> lessons_ID sti basi (ayto isos to parampsoyme eykola)
         if (sizeof($surveys) > 0) {
             $data['surveys'] = $surveys;
             $surveys_ = array();
             foreach ($surveys as $key => $value) {
                 $surveys_[$value['id']] = $value;
             }
             $surveys_list = implode(",", array_keys($surveys_));
             $questions_to_surveys = eF_getTableData("questions_to_surveys", "*", "surveys_ID IN ({$surveys_list})");
             // oposipote omos to survey_ID -> surveys_ID sti basi
             if (sizeof($questions_to_surveys) > 0) {
                 $data['questions_to_surveys'] = $questions_to_surveys;
             }
         }
     }
     $lesson_conditions = eF_getTableData("lesson_conditions", "*", "lessons_ID=" . $this->lesson['id']);
     if (sizeof($lesson_conditions) > 0) {
         $data['lesson_conditions'] = $lesson_conditions;
     }
     $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('&quot;', '&gt;', '&lt;', '&#42;', '&#63;', '&#58;'), $this->lesson['name']);
         $file->rename($userTempDir . '/' . EfrontFile::encode($newName) . '.zip', true);
     }
     unlink($this->directory . '/' . "data.dat");
     //Delete database dump file
     return $file;
 }
Beispiel #7
0
 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());
         }
     }
 }
Beispiel #8
0
function askInformation()
{
    try {
        if (isset($_GET['lessons_ID']) && eF_checkParameter($_GET['lessons_ID'], 'id')) {
            $lesson = new EfrontLesson($_GET['lessons_ID']);
            $lessonInformation = $lesson->getInformation();
            $languages = EfrontSystem::getLanguages(true);
            //$lessonInformation['language'] = $languages[$lesson -> lesson['languages_NAME']];
            if ($lessonInformation['professors']) {
                foreach ($lessonInformation['professors'] as $value) {
                    $professorsString[] = $value['name'] . ' ' . $value['surname'];
                }
                $lessonInformation['professors'] = implode(", ", $professorsString);
            }
            $lesson->lesson['price'] ? $priceString = formatPrice($lesson->lesson['price'], array($lesson->options['recurring'], $lesson->options['recurring_duration']), true) : ($priceString = false);
            $lessonInformation['price_string'] = $priceString;
            //    if (!$lessonInformation['price']) {
            //        unset($lessonInformation['price_string']);
            //    }
            try {
                if ($_GET['from_course']) {
                    $course = new EfrontCourse($_GET['from_course']);
                    $schedule = $course->getLessonScheduleInCourse($lesson);
                    if ($schedule['start_date'] || $schedule['end_date']) {
                        $lessonInformation['from_timestamp'] = $schedule['start_date'];
                        $lessonInformation['to_timestamp'] = $schedule['end_date'];
                    } else {
                        $lessonInformation['from_timestamp'] = $schedule['active_in_lesson'] + 24 * 60 * 60 * $schedule['start_period'];
                        $lessonInformation['to_timestamp'] = $lessonInformation['from_timestamp'] + 24 * 60 * 60 * $schedule['end_period'];
                    }
                }
            } catch (Exception $e) {
            }
            foreach ($lessonInformation as $key => $value) {
                if ($value) {
                    switch ($key) {
                        case 'language':
                            $GLOBALS['configuration']['onelanguage'] or $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 'content':
                            $tooltipInfo[] = '<div class = "infoEntry"><span>' . _CONTENTUNITS . "</span><span>: {$value}</span></div>";
                            break;
                        case 'tests':
                            EfrontUser::isOptionVisible('tests') ? $tooltipInfo[] = '<div class = "infoEntry"><span>' . _TESTS . "</span><span>: {$value}</span></div>" : null;
                            break;
                        case 'projects':
                            EfrontUser::isOptionVisible('projects') ? $tooltipInfo[] = '<div class = "infoEntry"><span>' . _PROJECTS . "</span><span>: {$value}</span></div>" : null;
                            break;
                        case 'course_dependency':
                            $tooltipInfo[] = '<div class = "infoEntry"><span>' . _DEPENDSON . "</span><span>: {$value}</span></div>";
                            break;
                        case 'from_timestamp':
                            $tooltipInfo[] = '<div class = "infoEntry"><span>' . _AVAILABLEFROM . "</span><span>: " . formatTimestamp($value, 'time_nosec') . "</span></div>";
                            break;
                        case 'to_timestamp':
                            $tooltipInfo[] = '<div class = "infoEntry"><span>' . _AVAILABLEUNTIL . "</span><span>: " . formatTimestamp($value, 'time_nosec') . "</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>' . _LESSONTOPICS . "</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':
                            !$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);
    }
}
Beispiel #9
0
 }
 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) {
Beispiel #10
0
 /**
  * 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='******' 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='******' 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='******' 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;
 }
Beispiel #11
0
                                     							$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);
                         }
                     }
                 }
             }
         }
     }
 }
 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='******'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)) . "')");
                                     foreach ($active_recipients["login"] as $login) {
                                         $filtered_recipients[$login] = array("login" => $login);
                                     }
                                     $recipients = $filtered_recipients;
                                 }
                             } 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 ewb.assigned=1 and 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 ewb.assigned=1 and uc.courses_ID=" . $this->recipients["courses_ID"] . " and uc.archive=0)";
                                 //get course users' supervisors
                                 $result = eF_executeNew($query);
                                 $recipients = $result->getAll();
                             }
                         } else {
                             $recipients = eF_getTableData("users_to_courses uc, users u", "u.login, u.name, u.surname, u.email, u.user_type as basic_user_type, u.active, u.user_types_ID, uc.user_type as role", "u.active=1 and u.archive=0 and uc.archive=0 and uc.users_LOGIN = u.login and uc.courses_ID=" . $this->recipients["courses_ID"] . $completed_condition);
                         }
                     } else {
                         if (isset($this->recipients['user_type'])) {
                             $recipients = eF_getTableData("users", "*", "active=1 and archive=0 and user_type = '" . $this->recipients['user_type'] . "'");
                         } else {
                             if (isset($this->recipients['entity_ID']) && isset($this->recipients['entity_category'])) {
                                 if ($this->recipients['entity_category'] == "survey") {
                                     $recipients = eF_getTableData("users_to_surveys JOIN users ON users_LOGIN = users.login", "users.*", "users.active=1 and users.archive=0 and surveys_ID = '" . $this->recipients["entity_ID"] . "'");
                                     $notified = eF_getTableDataFlat("users_to_surveys JOIN users ON users_LOGIN = users.login", "users.*", "users.active=1 and users.archive=0 and users_to_surveys.last_post > 1 and surveys_ID = '" . $this->recipients["entity_ID"] . "'");
                                     //$resDone		= eF_getTableDataFlat("users_to_done_surveys", "users_LOGIN", "surveys_ID=".$this -> recipients["entity_ID"]);
                                     $usersToSent = array();
                                     if (!empty($notified['login'])) {
                                         foreach ($recipients as $key => $value) {
                                             if (!in_array($value['login'], $notified['login'])) {
                                                 $usersToSent[] = $value;
                                                 //eF_updateTableData("users_to_surveys", array("last_post" => time()), "users_LOGIN='******'login']."' and surveys_ID='".$this -> recipients["entity_ID"]."'");
                                             }
                                         }
                                         $recipients = $usersToSent;
                                     }
                                     foreach ($recipients as $key => $value) {
                                         // in order to include case empty($notified['login']
                                         eF_updateTableData("users_to_surveys", array("last_post" => time()), "users_LOGIN='******'login'] . "' and surveys_ID='" . $this->recipients["entity_ID"] . "'");
                                     }
                                 } else {
                                     if ($this->recipients['entity_category'] == "projects") {
                                         $recipients = eF_getTableData("users_to_projects JOIN users ON users_LOGIN = users.login", "users.*", "users.active=1 and users.archive=0 and projects_ID = '" . $this->recipients["entity_ID"] . "'");
                                     }
                                 }
                             } else {
                                 if (isset($this->recipients["groups_ID"])) {
                                     $recipients = eF_getTableData("users_to_groups JOIN users ON users_login = users.login", "users.*", "users.active=1 and users.archive=0 and groups_ID = '" . $this->recipients["groups_ID"] . "'");
                                 } else {
                                     if (isset($this->recipients['users_login'])) {
                                         if (G_VERSIONTYPE == 'enterprise') {
                                             #cpp#ifdef ENTERPRISE
                                             if (isset($this->recipients['supervisor'])) {
                                                 $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);
                                                 }
                                             } elseif (isset($this->recipients['immediate_supervisor'])) {
                                                 $result = eF_getTableDataFlat("module_hcd_employee_works_at_branch", "users_LOGIN", "supervisor=1 and branch_ID IN (select branch_ID from module_hcd_employee_works_at_branch where assigned=1 and supervisor=0 and users_login='******'users_login'] . "')");
                                                 $recipients = array();
                                                 foreach ($result['users_LOGIN'] as $supervisor) {
                                                     $recipients[$supervisor] = array("login" => $supervisor);
                                                 }
                                             } else {
                                                 $recipients = $this->recipients['users_login'];
                                             }
                                         } else {
                                             #cpp#else
                                             $recipients = $this->recipients['users_login'];
                                         }
                                         #cpp#endif
                                     }
                                 }
                             }
                         }
                     }
                 }
                 foreach ($recipients as $recipient) {
                     $recipients_list[$recipient['login']] = $recipient;
                 }
             } else {
                 if ($this->notification['recipient'] != "") {
                     preg_match("/\\d+_(\\d+)/", $this->notification['id_type_entity'], $matches);
                     if ($matches[1] == EfrontEvent::SYSTEM_ON_EMAIL_ACTIVATION) {
                         //In this case, we want an inactive user to receive the email
                         $user = eF_getTableData("users", "*", "archive=0 and login = '******'recipient'] . "'");
                     } else {
                         $user = eF_getTableData("users", "*", "active=1 and archive=0 and login = '******'recipient'] . "'");
                     }
                     if (!empty($user)) {
                         $recipients_list[$this->notification['recipient']] = $user[0];
                     }
                 }
             }
         }
     } else {
         if ($this->notification['recipient'] != "") {
             $user = eF_getTableData("users", "*", "active=1 and archive=0 and login = '******'recipient'] . "'");
             if (!empty($user)) {
                 $recipients_list[$this->notification['recipient']] = $user[0];
             }
         }
     }
     return $recipients_list;
 }
Beispiel #13
0
     }
     //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]);
    /**
     * Create HTML representation of file system tree
     *
     * This function creates the file manager HTML code. It also handles any AJAX calls,
     * composes and prints upload and create directory forms, as well as makes sure the
     * correct folder contents are displayed.
     * <code>
     * $basedir    = G_LESSONSPATH.'test/';
     * $filesystem = new FileSystemTree($basedir);									//Set the base directory that the file manager displayes
     * $url        = 'administrator.php?ctg=file_manager';			//Set the url where file manager resides
     * echo $filesystem -> toHTML($url); 											//Display file manager
     * </code>
     * The available options are (the default value in parenthesis):
     * - show_type (true)				//Whether to show the "type" column
     * - show_date (true)				//Whether to show the "last modified" column
     * - show_name (true)				//Whether to show the "name" column
     * - show_size (true)				//Whether to show the "size" column
     * - show_tools (true)				//Whether to show the "tools" column
     * - metadata (true)				//Whether to allow for metadata
     * - db_files_only (false) 			//Whether to display only files that have a db representation
     * - delete (true)					//Whether to display delete icon
     * - download (true)				//Whether to display download icon
     * - zip  (true)					//Whether to display zip icon
     * - share (true)					//Whether to display share icon
     * - create_folder (true)			//Whether to display create folder link
     * - upload (true)					//Whether to display upload file link
     * - copy (true)					//Whether to display copy icon
     * - folders (true)					//Whether to display folders in files list
     *
     * The $extraFileTools, $extraHeaderOptions, $extraDirectoryTools paramaters are used to add custom
     * extra tools to various places of the file manager. The format of these parameters is of the form:
     * $extraFileTools = array(array('image' => 'images/16x16/restore.png', 'title' => _RESTORE, 'action' => 'restore'));
     * $extraHeaderOptions = array(array('image' => 'images/16x16/undo.png', 'title' => _BACKUP, 'action' => 'backup'));
     *
     * @param string $url The url where the file manager resides
     * @param string $currentDirectory The directory to use as base directory
     * @param array $ajaxOptions AJAX-specific options: sort, order, limit, offset, filter
     * @param array $options Options for the file manager
     * @param array $extraFileTools Extra tools for files
     * @param array $extraDirectoryTools Extra tools for directories
     * @param array $extraHeaderOptions Extra tools for file manager header
     * @param array $defaultIterator A specific iterator to use for files display
     * @param bool 	$show_tooltip If tooltip is dislayed in name
     * @return string The HTML representation of the file system
     * @since 3.5.0
     * @access public
     */
    public function toHTML($url, $currentDirectory = '', $ajaxOptions = array(), $options, $extraFileTools = array(), $extraDirectoryTools = array(), $extraHeaderOptions = array(), $defaultIterator = false, $show_tooltip = true, $extraColumns = array())
    {
        //Set default options
        !isset($options['show_type']) ? $options['show_type'] = true : null;
        !isset($options['show_date']) ? $options['show_date'] = true : null;
        !isset($options['show_name']) ? $options['show_name'] = true : null;
        !isset($options['show_size']) ? $options['show_size'] = true : null;
        !isset($options['show_tools']) ? $options['show_tools'] = true : null;
        !isset($options['delete']) ? $options['delete'] = true : null;
        !isset($options['download']) ? $options['download'] = true : null;
        !isset($options['zip']) ? $options['zip'] = true : null;
        !isset($options['share']) ? $options['share'] = true : null;
        !isset($options['edit']) ? $options['edit'] = true : null;
        !isset($options['copy']) ? $options['copy'] = true : null;
        !isset($options['create_folder']) ? $options['create_folder'] = true : null;
        !isset($options['upload']) ? $options['upload'] = true : null;
        !isset($options['folders']) ? $options['folders'] = true : null;
        !isset($options['db_files_only']) ? $options['db_files_only'] = false : null;
        !isset($options['table_id']) ? $tableId = 'filesTable' : ($tableId = $options['table_id']);
        //Make sure that current directory is a path
        //$currentDirectory = new EfrontDirectory($currentDirectory);
        if ($currentDirectory instanceof EfrontDirectory) {
            $currentDirectory = $currentDirectory['path'];
        }
        if (isset($_POST['upload_current_directory']) && strpos(EfrontDirectory::normalize($_POST['upload_current_directory']), rtrim(G_ROOTPATH, "/")) !== false) {
            $currentDirectory = $_POST['upload_current_directory'];
        }
        if (isset($_POST['current_directory']) && strpos(EfrontDirectory::normalize($_POST['current_directory']), rtrim(G_ROOTPATH, "/")) !== false) {
            $currentDirectory = $_POST['current_directory'];
        }
        if (isset($_POST['copy_current_directory']) && strpos(EfrontDirectory::normalize($_POST['copy_current_directory']), rtrim(G_ROOTPATH, "/")) !== false) {
            $currentDirectory = $_POST['copy_current_directory'];
        }
        if ($currentDirectory && $currentDirectory != $this->dir['path']) {
            //Check that the current directory actually exists
            $currentDir = new EfrontDirectory($currentDirectory);
            //Get its parent directory
            $parentDir = new EfrontDirectory($currentDir['directory']);
            //Build a new (shallow) file system tree on the current directory
            $innerFileSystem = new FileSystemTree($currentDir, false);
            //Assign each node as a child to the currentDir, thus creating a new tree with currentDir as parent
            foreach ($innerFileSystem->tree as $key => $value) {
                $currentDir[$key] = $value;
            }
            //$currentDir = $this -> seekNode($currentDirectory);
            //$parentDir  = new EfrontDirectory($currentDir['directory']);
        } else {
            $currentDirectory = $this->dir['path'];
            $currentDir = $this->tree;
        }
        try {
            $uploadForm = new HTML_QuickForm("upload_file_form_{$tableId}", "post", $url, "", "target = 'POPUP_FRAME'", true);
            $uploadFormString = $this->getUploadForm($uploadForm);
            if ($uploadForm->isSubmitted() && $uploadForm->validate()) {
                $uploadedFile = $this->handleUploadForm($uploadForm);
                $uploadFormString .= '
                	  <script>if (window.name == "POPUP_FRAME") {(parent.eF_js_showDivPopup());parent.eF_js_rebuildTable(parent.$(\'filename_' . $tableId . '\').down().getAttribute(\'tableIndex\'), 0, \'\', \'desc\', \'' . urlencode($currentDirectory) . '\');parent.$(\'uploading_image\').hide()}</script>';
            }
            $createFolderForm = new HTML_QuickForm("create_folder_form", "post", $url, "", "target = 'POPUP_FRAME'", true);
            $createFolderString = $this->getCreateDirectoryForm($createFolderForm);
            if ($createFolderForm->isSubmitted() && $createFolderForm->validate()) {
                $this->handleCreateDirectoryForm($createFolderForm);
                $createFolderString .= '
                	  <script>if (window.name == "POPUP_FRAME") {(parent.eF_js_showDivPopup());parent.eF_js_rebuildTable(parent.$(\'filename_' . $tableId . '\').down().getAttribute(\'tableIndex\'), 0, \'\', \'desc\', \'' . urlencode($currentDirectory) . '\');}</script>';
            }
            /*
            $copyForm       = new HTML_QuickForm("copy_file_form", "post", $url, "", "", true);
            
            foreach ($iterator = new EfrontDirectoryOnlyFilterIterator(new EfrontNodeFilterIterator($currentDir)) as $key => $value) {
            $directories[$key] = str_replace($this -> dir['path'].'/', '', EfrontFile :: decode($value['path']));
            }
            $copyForm -> addElement('select', 'destination', null, $directories, 'class = "inputText"');
            $copyFormString = $this -> getCopyForm($copyForm);
            
            if ($copyForm -> isSubmitted() && $copyForm -> validate()) {
            $copiedFile = $this -> handleCopyForm($copyForm);
            }
            */
            //pr($currentDirectory);
            if (isset($_POST['copy_files']) && sizeof($_POST['copy_files']) > 0) {
                $copyFiles = explode(",", $_POST["copy_files"]);
                foreach ($copyFiles as $file) {
                    $file = new EfrontFile($file);
                    //pr('copying to '.$currentDirectory.'/'.basename($file['path']));
                    $file->copy($currentDirectory . '/' . basename($file['path']));
                }
            }
        } catch (Exception $e) {
            echo "<script>if (top && top.mainframe) {w=top.mainframe} else {w=parent;}w.document.getElementById('messageError').innerHTML = '" . $e->getMessage() . "';parent.\$('uploading_image').hide();</script>";
            //Don't halt for uploading and create directory errors
            $GLOBALS['smarty']->assign("T_EXCEPTION_TRACE", $e->getTraceAsString());
            $GLOBALS['message'] = $e->getMessage() . ' (' . $e->getCode() . ') &nbsp;<a href = "javascript:void(0)" onclick = "eF_js_showDivPopup(event, \'' . _ERRORDETAILS . '\', 2, \'error_details\')">' . _MOREINFO . '</a>';
        }
        $files = array();
        $fileArrays = array();
        $foldersArray = array();
        $filesArray = array();
        if ($options['folders']) {
            $iterator = new EfrontDirectoryOnlyFilterIterator(new ArrayIterator($currentDir));
            //Plain ArrayIterator so that it iterates only on the current's folder files
            if ($options['db_files_only']) {
                //Filter out directories without database representation
                $iterator = new EfrontDBOnlyFilterIterator($iterator);
            }
            foreach ($iterator as $key => $value) {
                //We convert iterator to a complete array of files, so we can apply sorting, filtering etc more easily
                $current = (array) $iterator->current();
                foreach ($current as $k => $v) {
                    //Remove child elements, such files, directories etc from the array, so we can successfully apply operations on to them, such as filtering
                    if ($v instanceof ArrayObject) {
                        unset($current[$k]);
                    }
                }
                $current['size'] = 0;
                $current['extension'] = '';
                $current['shared'] = 10;
                //Add these 3 parameters, so that sorting below works correctly (10 means nothing, since a folder cannot be shared, but it is handy for sorting)
                $foldersArray[] = (array) $current;
                //Array representation of directory objects, on which we can apply sorting, filtering, etc
            }
            $foldersArray = eF_multiSort($foldersArray, 'name', 'asc');
        }
        if ($defaultIterator) {
            $iterator = $defaultIterator;
        } else {
            $iterator = new EfrontFileOnlyFilterIterator(new EfrontNodeFilterIterator(new ArrayIterator($currentDir)));
            //Plain ArrayIterator so that it iterates only on the current folder's files
            if ($options['db_files_only']) {
                //Filter out directories without database representation
                $iterator = new EfrontDBOnlyFilterIterator($iterator);
            }
        }
        foreach ($iterator as $key => $value) {
            //We convert iterator to a complete array of files, so we can apply sorting, filtering etc more easily
            $current = (array) $iterator->current();
            foreach ($current as $k => $v) {
                //Remove child elements, such files, directories etc from the array, so we can successfully apply operations on to them, such as filtering
                if ($v instanceof ArrayObject) {
                    unset($current[$k]);
                }
            }
            $filesArray[] = (array) $current;
            //Array representation of file objects, on which we can apply sorting, filtering, etc
        }
        $filesArray = eF_multiSort($filesArray, 'name', 'asc');
        $fileArrays = array_merge($foldersArray, $filesArray);
        isset($ajaxOptions['order']) && $ajaxOptions['order'] == 'asc' ? $ajaxOptions['order'] = 'asc' : ($ajaxOptions['order'] = 'desc');
        !isset($ajaxOptions['sort']) ? $ajaxOptions['sort'] = 'name' : null;
        !isset($ajaxOptions['limit']) ? $ajaxOptions['limit'] = 20 : null;
        !isset($ajaxOptions['offset']) ? $ajaxOptions['offset'] = 0 : null;
        !isset($ajaxOptions['filter']) ? $ajaxOptions['filter'] = '' : null;
        $size = sizeof($fileArrays);
        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>&nbsp;';
                    $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>&nbsp;';
                }
                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>&nbsp;';
                }
                if ($options['download']) {
                    $toolsString .= '<a href = "' . $url . '&download=' . urlencode($identifier) . '"><img src = "images/16x16/import.png" alt = "' . _DOWNLOADFILE . '" title = "' . _DOWNLOADFILE . '" border = "0"/></a>&nbsp;';
                }
                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) . '" />
	                    	<img class = "ajaxHandle" src = "images/16x16/trafficlight_red.png"   alt = "' . _SHARE . '"   title = "' . _SHARE . '"   onclick = "shareFile(this, $(\'span_' . urlencode($identifier) . '\').innerHTML)"   style = "' . ($value['shared'] ? 'display:none' : null) . '" />';
                }
                if ($options['metadata']) {
                    $toolsString .= '<a href = "' . $url . '&popup=1&display_metadata=' . urlencode($identifier) . '" target = "POPUP_FRAME"><img src = "images/16x16/information.png" alt = "' . _METADATA . '" title = "' . _METADATA . '" onclick = "eF_js_showDivPopup(event, \'' . _METADATA . '\', 2)" border = "0"/></a>&nbsp;';
                }
                if ($options['edit'] && ($_SESSION['s_type'] == 'administrator' || ($value['users_LOGIN'] == $_SESSION['s_login'] || in_array($value['users_LOGIN'], $supervisedLogins)) && isset($value['users_LOGIN']) || EfrontUser::isOptionVisible('allow_users_to_delete_supervisor_files'))) {
                    $toolsString .= '<img class = "ajaxHandle edit" src = "images/16x16/edit.png" alt = "' . _EDIT . '" title = "' . _EDIT . '" onclick = "toggleEditBox(this, \'' . urlencode($identifier) . '\')"/>&nbsp;';
                }
                if ($options['delete'] && ($_SESSION['s_type'] == 'administrator' || ($value['users_LOGIN'] == $_SESSION['s_login'] || in_array($value['users_LOGIN'], $supervisedLogins) || $value['users_LOGIN'] == "") || EfrontUser::isOptionVisible('allow_users_to_delete_supervisor_files'))) {
                    $toolsString .= '<img class = "ajaxHandle" src = "images/16x16/error_delete.png" alt = "' . _DELETE . '" title = "' . _DELETE . '" onclick = "if (confirm(\'' . _IRREVERSIBLEACTIONAREYOUSURE . '\')) {deleteFile(this, $(\'span_' . urlencode($identifier) . '\').innerHTML)}"/></a>&nbsp;';
                }
            } else {
                if (is_dir($value['path'])) {
                    $identifier = $value['path'];
                    $value = new EfrontDirectory($value['path']);
                    $link = $url . '&view_dir=' . urlencode($identifier);
                    foreach ($extraDirectoryTools as $tool) {
                        $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>&nbsp;';
                    }
                    if ($options['edit']) {
                        $toolsString .= '<img class = "ajaxHandle edit" src = "images/16x16/edit.png" alt = "' . _EDIT . '" title = "' . _EDIT . '" onclick = "toggleEditBox(this, \'' . urlencode($identifier) . '\')"/>&nbsp;';
                    }
                    if ($options['delete']) {
                        $toolsString .= '<img class = "ajaxHandle" src = "images/16x16/error_delete.png" alt = "' . _DELETE . '" title = "' . _DELETE . '" onclick = "if (confirm(\'' . _IRREVERSIBLEACTIONAREYOUSURE . '\')) {deleteFolder(this, $(\'span_' . urlencode($identifier) . '\').innerHTML)}" />&nbsp;';
                    }
                }
            }
            $filesCode .= '<tr class = "defaultRowHeight ' . (fmod($i++, 2) ? 'oddRowColor' : 'evenRowColor') . '">';
            if ($options['show_type']) {
                $filesCode .= '<td class = "centerAlign"><span style = "display:none">' . (isset($value['extension']) ? $value['extension'] : '') . '</span>';
                if ($value['type'] == 'file') {
                    if (strpos($value['mime_type'], "image") !== false || strpos($value['mime_type'], "text") !== false || strpos($value['mime_type'], "pdf") !== false || strpos($value['mime_type'], "html") !== false || strpos($value['mime_type'], "video") !== false || strpos($value['mime_type'], "flash") !== false) {
                        $filesCode .= '<a href = "javascript:void(0);" onclick = "eF_js_showDivPopup(event, \'' . _PREVIEW . '\', 2, \'preview_table_' . $tableId . '\');$(\'preview_frame\').src = \'' . $link . '\';" ><img src = "' . $value->getTypeImage() . '" alt = "' . $value['mime_type'] . '" title = "' . $value['mime_type'] . '" border = "0"/></a></td>';
                    } else {
                        $filesCode .= '<a href = "' . $url . '&download=' . urlencode($identifier) . '"><img src = "' . $value->getTypeImage() . '" alt = "' . $value['mime_type'] . '" title = "' . $value['mime_type'] . '" border = "0"/></a>';
                    }
                } else {
                    isset($value['mime_type']) ? $mimeType = $value['mime_type'] : ($mimeType = '');
                    $filesCode .= '<img src = "' . $value->getTypeImage() . '" alt = "' . $mimeType . '" title = "' . $mimeType . '" border = "0"/></td>';
                }
            }
            if ($options['show_name']) {
                $filesCode .= '<td><span id = "span_' . urlencode($identifier) . '" style = "display:none;">' . urlencode($identifier) . '</span>';
                if ($value['type'] == 'file') {
                    if ($show_tooltip) {
                        $filesCode .= $value->toHTMLTooltipLink($link, true, $tableId);
                    } else {
                        if (strpos($value['mime_type'], "image") !== false || strpos($value['mime_type'], "text") !== false || strpos($value['mime_type'], "pdf") !== false || strpos($value['mime_type'], "flash") !== false || strpos($value['mime_type'], "video") !== false) {
                            $filesCode .= '<a href = "' . $link . '" target = "PREVIEW_FRAME" onclick = "eF_js_showDivPopup(event, \'' . _PREVIEW . '\', 2, \'preview_table_' . $tableId . '\');">' . $value['name'] . '</a>';
                        } else {
                            $filesCode .= '<a target = "PREVIEW_FRAME" href = "' . $url . '&download=' . urlencode($identifier) . '">' . $value['name'] . '</a>';
                        }
                    }
                } else {
                    $filesCode .= '<a class="editLink" href = "javascript:void(0)" onclick = "eF_js_rebuildTable($(\'filename_' . $tableId . '\').down().getAttribute(\'tableIndex\'), 0, \'\', \'desc\', \'' . urlencode($identifier) . '\');">' . $value['name'] . '</a>';
                }
                $filesCode .= '<span id = "edit_' . urlencode($identifier) . '" style = "display:none"><input type = "text" value = "' . $value['name'] . '" onkeypress = "if (event.which == 13 || event.keyCode == 13) {Element.extend(this).next().down().onclick(); return false;}"/>&nbsp;<a href = "javascript:void(0)"><img id = "editImage_' . urlencode($identifier) . '"src = "images/16x16/success.png" style = "vertical-align:middle" onclick = "editFile(this, $(\'span_' . urlencode($identifier) . '\').innerHTML, Element.extend(this).up().previous().value, \'' . $value['type'] . '\',\'' . eF_addslashes($value['name']) . '\')" border = "0"></a></span></td>';
            }
            $extraColumnsString = '';
            foreach ($extraColumns as $column) {
                $extraColumnsString = '<td class = "centerAlign">' . $value[$column] . '</td>';
            }
            $filesCode .= '' . ($options['show_size'] ? '<td>' . ($value['type'] == 'file' ? $value['size'] . ' ' . _KB : '') . '</td>' : '') . '
                        		' . ($options['show_date'] ? '<td>' . formatTimestamp($value['timestamp'], 'time_nosec') . '</td>' : '') . '
                        		' . $extraColumnsString . '
                        		' . ($_SESSION['s_lessons_ID'] && $options['share'] ? '<td class = "centerAlign">' . $sharedString . '</td>' : '') . '
                        		' . ($options['show_tools'] ? '<td class = "centerAlign">' . $toolsString . '</td>' : '') . '
	                        		' . ($options['delete'] || $_SESSION['s_lessons_ID'] && $options['share'] ? '<td class = "centerAlign">' . ($value['type'] == 'file' ? '<input type = "checkbox" id = "' . $identifier . '" value = "' . $identifier . '" />' : '') . '</td>' : '') . '
                        	</tr>';
        }
        $massOperationsCode = '';
        if ($size) {
            $filesCode .= '
        				</table>';
            if ($options['delete'] || $_SESSION['s_lessons_ID'] && $options['share']) {
                $massOperationsCode = '
            			<div class = "horizontalSeparatorAbove">
            				<span style = "vertical-align:middle">' . _WITHSELECTEDFILES . ':</span>
            				' . ($_SESSION['s_lessons_ID'] && $options['share'] ? '<a href = "javascript:void(0)"><img src = "images/16x16/trafficlight_green.png" title = "' . _SHARESELECTED . '" alt = "' . _SHARESELECTED . '" border = "0" style = "vertical-align:middle" onclick = "shareSelected()"></a><a href = "javascript:void(0)"><img src = "images/16x16/trafficlight_red.png" title = "' . _UNSHARESELECTED . '" alt = "' . _UNSHARESELECTED . '" border = "0" style = "vertical-align:middle" onclick = "unshareSelected()"></a>' : '');
                if ($options['copy']) {
                    $massOperationsCode .= '
                			<form name = "copy_files_form" id = "copy_files_form" method = "post" style = "display:none;"><input type = "hidden" name = "copy_current_directory" id = "copy_current_directory"><input type = "hidden" name = "copy_files" id = "copy_files" value = "" /></form>
							<img class = "ajaxHandle" src = "images/16x16/copy.png" title = "' . _COPYSELECTED . '" alt = "' . _COPYSELECTED . '" onclick = "copyFiles(this);">
                            <img style = "display:none" class = "ajaxHandle" src = "images/16x16/paste.png" title = "' . _PASTESELECTED . '" alt = "' . _PASTESELECTED . '" onclick = "pasteFiles(this, \'' . $tableId . '\');">&nbsp;';
                }
                $massOperationsCode .= ($options['delete'] ? '<a href = "javascript:void(0)"><img src = "images/16x16/error_delete.png" title = "' . _DELETESELECTED . '" alt = "' . _DELETESELECTED . '" border = "0" style = "vertical-align:middle" onclick = "if (confirm(\'' . _IRREVERSIBLEACTIONAREYOUSURE . '\')) deleteSelected()"></a>' : '') . '
            			</div>';
            }
        } elseif (!isset($parentDir)) {
            //Don't display 'no data found' if in subdirectory, because it doesn't show up well with the .. (up one level)
            $filesCode .= '
            				<tr class = "oddRowColor defaultRowHeight"><td colspan = "100%" class = "emptyCategory">' . _NODATAFOUND . '</td></tr>
        				</table>';
        }
        $str = '
        	<div class = "headerTools">';
        if ($options['upload']) {
            $str .= '
        		<span>
            		<img src = "images/16x16/add.png" alt = "' . _UPLOADFILE . '" title = "' . _UPLOADFILE . '"/>
        			<a href = "javascript:void(0)" onclick = "$(\'url_upload\').value = \'\';$$(\'input\').each(function(s)  {if (s.type == \'file\') s.value = \'\'});$(\'upload_current_directory\').value = $(\'' . $tableId . '\').getAttribute(\'currentDir\');eF_js_showDivPopup(event, \'' . _UPLOADFILE . '\', 0, \'upload_file_table_' . $tableId . '\')">' . _UPLOADFILE . '</a>&nbsp;
        		</span>';
        }
        if ($options['create_folder']) {
            $str .= '
        		<span>
        			<img src = "images/16x16/folder_add.png" alt = "' . _CREATEFOLDER . '" title = "' . _CREATEFOLDER . '">
        			<a href = "javascript:void(0)" onclick = "$(\'current_directory\').value = $(\'' . $tableId . '\').getAttribute(\'currentDir\');eF_js_showDivPopup(event, \'' . _CREATEFOLDER . '\', 0, \'create_directory_table_' . $tableId . '\')">' . _CREATEFOLDER . '</a>&nbsp;
        		</span>';
        }
        foreach ($extraHeaderOptions as $option) {
            $str .= '
            	<span>
	        		<img src = "' . $option['image'] . '" alt = "' . $option['title'] . '" title = "' . $option['title'] . '">
    	    		<a href = "' . (isset($option['href']) ? $option['href'] : 'javascript:void(0)') . '" onclick = "' . $option['action'] . '">' . $option['title'] . '</a>&nbsp;
    	    	</span>';
        }
        $str .= '
        	</div>

        	<table style = "width:100%">
        		<tr><td>
<!--ajax:' . $tableId . '-->
        				' . $filesCode . '
<!--/ajax:' . $tableId . '-->
						' . $massOperationsCode . '
        			</td></tr>
        	</table>
        	<script>
        	var url = "' . $url . '";
        	var tableId = "' . $tableId . '";
        	</script>
        	<div id = "upload_file_table_' . $tableId . '" 	   style = "display:none;" class = "filemanagerBlock">' . $uploadFormString . '</div>
        	<div id = "create_directory_table_' . $tableId . '" style = "display:none;" class = "filemanagerBlock">' . $createFolderString . '</div>

        	<div id = "preview_table_' . $tableId . '" style = "height:100%;display:none" class = "filemanagerBlock">
                <iframe name = "PREVIEW_FRAME" id = "preview_frame" src = "about:blank" style = "border-width:0px;width:100%;height:400px;padding:0px 0px 0px 0px">Sorry, but your browser needs to support iframes to see this</iframe>
            </div>';
        /*
                $GLOBALS['smarty'] -> assign("T_BLOCK_DATA", $uploadFormString);
                $GLOBALS['smarty'] -> assign("T_DISPLAY_BLOCK", '<div id = "upload_file_table_'.$tableId.'" style = "display:none;">{eF_template_printBlock title="'._UPLOADFILE.'" data=$T_BLOCK_DATA image="32x32/import.png"}</div>');
                $str .= $GLOBALS['smarty'] -> fetch("display_code.tpl");
                $GLOBALS['smarty'] -> assign("T_BLOCK_DATA", $createFolderString);
                $GLOBALS['smarty'] -> assign("T_DISPLAY_BLOCK", '<div id = "create_directory_table_'.$tableId.'" style = "display:none;">{eF_template_printBlock title="'._CREATEFOLDER.'" data=$T_BLOCK_DATA image="32x32/folder.png"}</div>');
                $str .= $GLOBALS['smarty'] -> fetch("display_code.tpl");
                $GLOBALS['smarty'] -> assign("T_DISPLAY_BLOCK", '<div id = "preview_table_'.$tableId.'" style = "display:none">{eF_template_printBlock title="'._PREVIEW.'" data="<iframe name = \"PREVIEW_FRAME\" id = \"preview_frame\" src = \"about:blank\" style = \"border-width:0px;width:100%;height:100%;padding:0px\">Sorry, but your browser needs to support iframes to see this</iframe>" image="32x32/folder.png"}</div>');
                $str .= $GLOBALS['smarty'] -> fetch("display_code.tpl");
        */
        return $str;
    }
 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') {
             $xlsFilePath = $currentUser->getDirectory() . 'category_report.xls';
             unlink($xlsFilePath);
             $_GET['limit'] = sizeof($courseUsers);
             $_GET['sort'] = 'category';
             list($tableSize, $courseUsers) = filterSortPage($courseUsers);
             $header = array('category' => _CATEGORY, 'course' => _NAME, 'login' => _USER, 'to_timestamp' => _COMPLETED, 'score' => _SCORE, 'supervisor' => _SUPERVISOR, 'branch' => _BRANCH, 'historic' => _MODULE_ADMINISTRATOR_TOOLS_HISTORICENTRY);
             foreach ($courseUsers as $value) {
                 $rows[] = array(_CATEGORY => str_replace("&nbsp;&rarr;&nbsp;", " -> ", $value['category']), _COURSE => $value['course'], _USER => formatLogin($value['login']), _COMPLETED => formatTimestamp($value['to_timestamp']), _SCORE => $value['historic'] ? '' : formatScore($value['score']) . '%', _SUPERVISOR => formatLogin($value['supervisor']), _BRANCH => str_replace("&nbsp;&rarr;&nbsp;", " -> ", $value['branch']), _MODULE_ADMINISTRATOR_TOOLS_HISTORICENTRY => $value['historic'] ? _YES : _NO);
             }
             EfrontSystem::exportToXls($rows, $xlsFilePath);
             exit;
         } else {
             if ($_GET['ajax'] == 'show_xls') {
                 $xlsFilePath = $currentUser->getDirectory() . 'category_report.xls';
                 $file = new EfrontFile($xlsFilePath);
                 $file->sendFile(true);
                 exit;
             } else {
                 list($tableSize, $courseUsers) = filterSortPage($courseUsers);
                 $smarty->assign("T_SORTED_TABLE", $_GET['ajax']);
                 $smarty->assign("T_TABLE_SIZE", $tableSize);
                 $smarty->assign("T_DATA_SOURCE", $courseUsers);
             }
         }
     }
     $smarty->assign("T_CATEGORY_FORM", $form->toArray());
 }
            if (G_VERSIONTYPE == 'enterprise') {
                #cpp#ifdef ENTERPRISE
                // For jobs
                if (isset($_GET['branch_ID']) && isset($_GET['job_description'])) {
                    if (eF_checkParameter($_GET['branch_ID'], 'id') && eF_checkParameter($_GET['job_description'], 'text')) {
                        $job = new EfrontJob(array("branch_ID" => $_GET['branch_ID'], "job_description" => $_GET['job_description']));
                        echo '<div class = "infoEntry"><span><b>' . _JOBANALYTICALDESCRIPTION . "</b>: " . $job->job['job_role_description'] . "</span><span></span></div>";
                    } else {
                        echo _JOBDOESNOTEXIST;
                    }
                }
            }
            #cpp#endif
            $tooltipInfo = array();
            if (isset($_GET['users_LOGIN']) && eF_checkParameter($_GET['users_LOGIN'], 'login')) {
                $user = EfrontUserFactory::factory($_GET['users_LOGIN']);
                if ($_GET['type'] == 'course_status') {
                    $constraints = array('archive' => false, 'active' => true, 'return_objects' => false);
                    $constraints['required_fields'] = array('active_in_course', 'user_type', 'completed', 'to_timestamp', 'score');
                    $courses = $user->getUserCoursesAggregatingResults($constraints);
                    $coursesTooltipInfo['completed'] = $coursesTooltipInfo['incomplete'] = array();
                    foreach ($courses as $key => $course) {
                        $course['completed'] ? $idx = 'completed' : ($idx = 'incomplete');
                        $coursesTooltipInfo[$idx][] = '<div class = "infoEntry">
											<span>' . $course['name'] . " (" . formatTimestamp($course['active_in_course']) . ")</span>\r\n\t\t\t\t\t\t\t\t\t\t\t<span>: " . ($course['completed'] ? _COMPLETED . ' ' . _ON . ' ' . formatTimestamp($course['to_timestamp']) : _NOTCOMPLETED) . "</span></div>";
                    }
                    if (sizeof($coursesTooltipInfo['incomplete']) > 0) {
                        $coursesTooltipInfo['incomplete'] = array_merge(array('<div class = "infoEntry"><span>' . _INCOMPLETECOURSES . ':</span></div>'), $coursesTooltipInfo['incomplete'], array('<br/>'));
                    }
                    if (sizeof($coursesTooltipInfo['completed']) > 0) {
                        $coursesTooltipInfo['completed'] = array_merge(array('<div class = "infoEntry"><span>' . _COMPLETEDCOURSES . ':</span></div>'), $coursesTooltipInfo['completed'], array('<br/>'));
         unset($fields['objectives']);
     }
     unset($fields['navigation']);
     unset($fields['completion_status']);
     unset($fields['success_status']);
     unset($fields['shared_data']);
     unset($fields['comments_from_lms']);
     unset($fields['comments_from_learner']);
     unset($fields['interactions']);
     unset($fields['learner_preferences']);
     unset($fields['score_scaled']);
     unset($fields['progress_measure']);
     unset($fields['finish']);
     $result = eF_getTableData("scorm_data", "total_time,id", "content_ID=" . $fields['content_ID'] . " AND users_LOGIN='******'users_LOGIN'] . "'");
 }
 $scoUser = EfrontUserFactory::factory($_SESSION['s_login'], false, 'student');
 $scoLesson = new EfrontLesson($_SESSION['s_lessons_ID']);
 $scoUnit = new EfrontUnit($fields['content_ID']);
 if (sizeof($result) > 0) {
     //This means that the students re-enters the unit
     if (isset($fields['session_time']) && $fields['session_time']) {
         //Make sure that time is properly converted, for example 35+35 minutes become 1 hour 10 minutes, instead if 70 minutes
         $time_parts1 = explode(":", $result[0]['total_time']);
         $time_parts2 = explode(":", $fields['session_time']);
         $time_parts[0] = $time_parts1[0] + $time_parts2[0];
         $time_parts[1] = $time_parts1[1] + $time_parts2[1];
         $time_parts[2] = $time_parts1[2] + $time_parts2[2];
         //print_r($time_parts1);print_r($time_parts2);print_r($time_parts);
         $time_parts[1] = $time_parts[1] + floor($time_parts[2] / 60);
         $time_parts[2] = fmod($time_parts[2], 60);
         $time_parts[0] = $time_parts[0] + floor($time_parts[1] / 60);
             		$count = 0;
             		foreach ($traffic['users'] as $key => $value) {
             			$graph -> data[]    = array($count, $value['accesses']);
             			$graph -> xLabels[] = array($count++, formatLogin($key));
             		}
             		//pr($graph);
             		$graph -> xTitle = _USERS;
             		$graph -> yTitle = _ACCESSES;
             		$graph -> title  = _ACCESSESPERUSER;
 
             		echo json_encode($graph);
             		exit;
             	} else
 */
 if (isset($_GET['ajax']) && $_GET['ajax'] == 'graph_user_access') {
     $user = EfrontUserFactory::factory($_GET['entity']);
     $timesReport = new EfrontTimes();
     $cnt = 0;
     $result = $timesReport->getUserSessionTimeInSingleLessonPerDay($user->user['login'], $infoLesson->lesson['id']);
     foreach ($result as $key => $value) {
         $labels[$cnt] = $key;
         $count[$cnt++] = ceil($value / 60);
     }
     $graph = new EfrontGraph();
     $graph->type = 'line';
     for ($i = 0; $i < sizeof($labels); $i++) {
         $graph->data[] = array($i, $count[$i]);
         $graph->xLabels[] = array($i, formatTimestamp($labels[$i]));
     }
     $graph->xTitle = _DAY;
     $graph->yTitle = _MINUTES;
Beispiel #19
0
             $comments_content = array("data" => $form->exportValue('data'));
             if (eF_updateTableData("profile_comments", $comments_content, "id=" . $id)) {
                 $message = _SUCCESFULLYUPDATEDCOMMENT;
                 $message_type = 'success';
             } else {
                 $message = _SOMEPROBLEMEMERGED;
                 $message_type = 'failure';
             }
         } elseif (isset($_GET['action']) && $_GET['action'] == 'insert') {
             $comments_content = array("data" => $form->exportValue('data'), "timestamp" => time(), "authors_LOGIN" => $_SESSION['s_login'], "users_LOGIN" => $_GET['user']);
             if (eF_insertTableData("profile_comments", $comments_content)) {
                 // Timelines add event
                 if ($_SESSION['s_login'] == $_GET['user']) {
                     EfrontEvent::triggerEvent(array("type" => EfrontEvent::NEW_PROFILE_COMMENT_FOR_SELF, "users_LOGIN" => $_SESSION['s_login'], "users_name" => $currentUser->user['name'], "users_surname" => $currentUser->user['surname']));
                 } else {
                     $commentedUser = EfrontUserFactory::factory($_GET['user']);
                     EfrontEvent::triggerEvent(array("type" => EfrontEvent::NEW_PROFILE_COMMENT_FOR_OTHER, "users_LOGIN" => $_SESSION['s_login'], "users_name" => $currentUser->user['name'], "users_surname" => $currentUser->user['surname'], "entity_ID" => $_GET['user'], "entity_name" => $commentedUser->user['name'] . " " . $commentedUser->user['surname']));
                 }
                 $message = _SUCCESFULLYADDEDCOMMENT;
                 $message_type = 'success';
             } else {
                 $message = _SOMEPROBLEMEMERGED;
                 $message_type = 'failure';
             }
         }
     }
 }
 $renderer = new HTML_QuickForm_Renderer_ArraySmarty($smarty);
 $form->setJsWarnings(_BEFOREJAVASCRIPTERROR, _AFTERJAVASCRIPTERROR);
 $form->setRequiredNote(_REQUIREDNOTE);
 $form->accept($renderer);
Beispiel #20
0
     case 'Canceled_Reversal':
     case 'Created':
     case 'Denied':
     case 'Expired':
     case 'Failed':
     case 'Refunded':
     case 'Reversed':
     case 'Processed':
     case 'Voided':
     default:
         if ($processPayment) {
             throw new EfrontPaymentsException(_UNSUPPORTEDPAYMENTSTATUS . ':' . $_POST['payment_status'], EfrontPaymentsException::UNSUPPORTED_PAYMENT);
         }
         break;
 }
 $user = EfrontUserFactory::factory($_POST['custom']);
 //@todo: check user type
 $ids = explode(":", $_POST['item_number']);
 !$ids[0] or $lessonIds = explode(",", $ids[0]);
 !$ids[1] or $courseIds = explode(",", $ids[1]);
 !$ids[2] or $credit = $ids[2];
 !$ids[3] or $couponIds = explode(",", trim($ids[3], ","));
 $couponIds = end($couponIds);
 //There may be multiple coupons set, but only the last is considered
 if ($_POST['txn_type'] == 'subscr_eot') {
     //Subscription ended, remove lessons and courses
     if ($lessonIds && sizeof($lessonIds) > 0 && $lessonIds[0]) {
         $user->removeLessons($lessonIds);
     }
     if ($courseIds && sizeof($courseIds) > 0 && $courseIds[0]) {
         $user->removeCourses($courseIds);
Beispiel #21
0
    } else {
        eF_redirect(basename($_SERVER['PHP_SELF']) . "?ctg=personal&user="******"&op=profile");
    }
} else {
    if (!isset($_GET['op'])) {
        if ($currentUser->user['login'] == $_GET['user'] && $currentUser->coreAccess['dashboard'] != 'hidden') {
            eF_redirect(basename($_SERVER['PHP_SELF']) . "?ctg=personal&user="******"&op=dashboard");
        } else {
            eF_redirect(basename($_SERVER['PHP_SELF']) . "?ctg=personal&user="******"&op=profile");
        }
    }
}
if ($currentUser->coreAccess['users'] == 'hidden' && $_GET['user'] != $currentUser->user['login']) {
    eF_redirect(basename($_SERVER['PHP_SELF']));
}
$editedUser = EfrontUserFactory::factory($_GET['user']);
$editedEmployee = $editedUser->aspects['hcd'];
$smarty->assign("T_EDITEDUSER", $editedUser);
if (G_VERSIONTYPE == 'enterprise') {
    #cpp#ifdef ENTERPRISE
    $currentEmployee = $currentUser->aspects['hcd'];
    if ($currentUser->user['login'] != $editedUser->user['login'] && $currentUser->user['user_type'] != 'administrator') {
        if (!$currentEmployee->isSupervisor() || !$currentEmployee->supervisesEmployee($editedUser->user['login'])) {
            eF_redirect(basename($_SERVER['PHP_SELF']) . "?ctg=personal&user="******"&op=profile&message=" . urlencode(_YOUCANNOTEDITTHISUSER) . "&message_type=failure");
        }
    }
} else {
    #cpp#else
    if ($currentUser->user['login'] != $editedUser->user['login'] && $currentUser->user['user_type'] != 'administrator') {
        eF_redirect(basename($_SERVER['PHP_SELF']) . "?ctg=personal&user="******"&op=profile&message=" . urlencode(_YOUCANNOTEDITTHISUSER) . "&message_type=failure");
    }
 /**
  * Process the variables sent by the Idp and perform the login with SAML
  * @param $sso array the value defined in domain's Configuration table
  * @param $values array sent by IdP
  */
 protected function _login($attributes)
 {
     if (!empty($attributes[$this->_sso_settings['saml_targeted_id']])) {
         // user comes authenticated in index page
         $login = $attributes[$this->_sso_settings['saml_targeted_id']][0];
         try {
             $user = EfrontUserFactory::factory($login);
         } catch (\Exception $e) {
             $login = null;
         }
         if (is_null($login)) {
             // User doesn't exist. Create user
             if (0 && reachedPlanLimit()) {
                 //@todo
                 // 					TemplateController::setMessage(("You have reached the maximum active users allowed by the selected plan."), 'warning');
             } else {
                 $fields = array('login' => $attributes[$this->_sso_settings['saml_targeted_id']][0], 'password' => sha1($attributes[$this->_sso_settings['saml_targeted_id']][0]), 'name' => $attributes[$this->_sso_settings['saml_first_name']][0], 'surname' => $attributes[$this->_sso_settings['saml_last_name']][0], 'active' => 1, 'email' => $attributes[$this->_sso_settings['saml_email']][0]);
                 $user = EfrontUser::createUser($fields);
                 $user->login($user->user['password'], true);
                 eF_redirect($user->user['user_type'] . '.php');
             }
         } else {
             // User exists
             $fields = array('name' => $attributes[$this->_sso_settings['saml_first_name']][0], 'surname' => $attributes[$this->_sso_settings['saml_last_name']][0], 'email' => $attributes[$this->_sso_settings['saml_email']][0]);
             $user = EfrontUserFactory::factory($login);
             //$user->setFields($fields)->save();	//update whatever changed
             $user->login($user->user['password'], true);
             eF_redirect($user->user['user_type'] . '.php');
         }
     }
     /*
      else{//User is not authenticates, set SAML session to be ready for authentication
     	
     $session = \SimpleSAML_Session::getInstance();
     $sso['domain']=$this->_domain;
     $session->setData("Array", "sso", $this->_sso_settings);
     }
     */
 }
Beispiel #23
0
 public static function exportToCsv($data, $download = false, $name = "data.csv")
 {
     $currentUser = EfrontUserFactory::factory($_SESSION['s_login']);
     $fp = fopen($currentUser->getDirectory() . $name, 'w');
     foreach ($data as $fields) {
         fputcsv($fp, $fields);
     }
     fclose($fp);
     $file = new EfrontFile($currentUser->getDirectory() . $name);
     if ($download) {
         $file->sendFile(true);
     } else {
         return $file;
     }
 }
function eF_local_canAccessUser()
{
    global $currentUser;
    global $isSupervisor;
    $editedUser = EfrontUserFactory::factory($_GET['sel_user']);
    if ($currentUser->user['user_type'] == 'administrator') {
        //can view any user
        return true;
    }
    if ($editedUser->user['login'] == $currentUser->user['login']) {
        //can view himself
        return true;
    }
    if ($isSupervisor) {
        //can view any user he/she supervises
        if ($currentUser->aspects['hcd']->supervisesEmployee($editedUser->user['login'])) {
            return true;
        }
    }
    $userLessons = $currentUser->getLessons(false, 'professor');
    if (!empty($userLessons)) {
        $result = eF_getTableData("users_to_lessons", "users_LOGIN", "archive=0 and users_LOGIN='******'login'] . "' and lessons_ID in (" . implode(",", array_keys($userLessons)) . ")");
    }
    if (!empty($result)) {
        return true;
    }
    return false;
}
 /**
  * Check if a course must be reset because of certificate expiry or 'before expiry' reset
  *
  * @param mixed lesson A lesson id or an EfrontLesson object
  * @since 3.6.3
  * @access public
  */
 public static function checkCertificateExpire()
 {
     $courses = eF_getTableData("courses", "id,reset_interval,reset", "certificate_expiration !=0");
     $notifications = eF_getTableData("event_notifications", "id,event_type,after_time,send_conditions", "event_type=-56 and active=1");
     $notifications_on_event = eF_getTableData("event_notifications", "id,event_type,after_time,send_conditions", "event_type=56 and active=1");
     foreach ($courses as $value) {
         $course = new EfrontCourse($value['id']);
         $constraints = array('archive' => false, 'active' => true, 'condition' => 'issued_certificate != ""');
         $users = $course->getStudentUsers(false, $constraints);
         foreach ($users as $user) {
             $login = $user['login'];
             $dateTable = unserialize($user['issued_certificate']);
             if (eF_checkParameter($dateTable['date'], 'timestamp')) {
                 //new way that issued date saves
                 $expirationArray = convertTimeToDays($course->course['certificate_expiration']);
                 $expirationTimestamp = getCertificateExpirationTimestamp($dateTable['date'], $expirationArray);
                 if ($course->course['reset_interval'] != 0) {
                     $resetArray = convertTimeToDays($value['reset_interval']);
                     $resetTimestamp = getCertificateResetTimestamp($expirationTimestamp, $resetArray);
                     if ($resetTimestamp < time()) {
                         $user = EfrontUserFactory::factory($user);
                         $user->resetProgressInCourse($course, true, true);
                     }
                 }
                 if ($course->course['reset']) {
                     //If student completed again the course with reset_interval, he has a new expire date so he will not be reset,(so it is not elseif)
                     if ($expirationTimestamp < time()) {
                         if (!$user instanceof EfrontUser) {
                             $user = EfrontUserFactory::factory($user);
                         }
                         $user->resetProgressInCourse($course, true);
                         foreach ($notifications_on_event as $notification) {
                             $send_conditions = unserialize($notification['send_conditions']);
                             $courses_ID = $send_conditions['courses_ID'];
                             if ($courses_ID == $value['id'] || $courses_ID == 0) {
                                 if ($notification['after_time'] == 0) {
                                     EfrontEvent::triggerEvent(array("type" => EfrontEvent::COURSE_CERTIFICATE_EXPIRY, "users_LOGIN" => $user->user['login'], "lessons_ID" => $course->course['id'], "lessons_name" => $course->course['name'], 'create_negative' => false));
                                 }
                             }
                         }
                     }
                 }
                 if (!$course->course['reset'] && !$course->course['reset_interval']) {
                     if ($expirationTimestamp < time()) {
                         eF_updateTableData("users_to_courses", array("issued_certificate" => ""), "users_LOGIN='******' and courses_ID = " . $course->course['id']);
                         foreach ($notifications_on_event as $notification) {
                             $send_conditions = unserialize($notification['send_conditions']);
                             $courses_ID = $send_conditions['courses_ID'];
                             if ($courses_ID == $value['id'] || $courses_ID == 0) {
                                 if ($notification['after_time'] == 0) {
                                     EfrontEvent::triggerEvent(array("type" => EfrontEvent::COURSE_CERTIFICATE_REVOKE, "users_LOGIN" => $login, "lessons_ID" => $course->course['id'], "lessons_name" => $course->course['name'], "create_negative" => false));
                                 }
                             }
                         }
                     }
                 }
                 foreach ($notifications as $notification) {
                     $send_conditions = unserialize($notification['send_conditions']);
                     $courses_ID = $send_conditions['courses_ID'];
                     if ($courses_ID == $value['id'] || $courses_ID == 0) {
                         if ($notification['after_time'] < 0) {
                             $resetArray = convertTimeToDays(abs($notification['after_time']));
                             $resetTimestamp = getCertificateResetTimestamp($expirationTimestamp, $resetArray);
                             // in order notification to be sent one (not every day after $resetTimestamp)
                             if ($GLOBALS['configuration']['last_reset_certificate'] < $resetTimestamp && $resetTimestamp < time() && $expirationTimestamp > time()) {
                                 EfrontEvent::triggerEvent(array("type" => -1 * EfrontEvent::COURSE_CERTIFICATE_EXPIRY, "users_LOGIN" => $login, "lessons_ID" => $course->course['id'], "lessons_name" => $course->course['name'], "create_negative" => false));
                             }
                         }
                     }
                 }
             }
         }
     }
 }
Beispiel #26
0
// Date in the past
header("cache-control: no-transform");
//To prevent 3G carriers from compressing the site, which will break all grids
//If the page is shown as a popup, make sure it remains in such mode
if (!isset($_GET['reset_popup']) && (isset($_GET['popup']) || isset($_POST['popup']) || isset($_SERVER['HTTP_REFERER']) && strpos(strtolower($_SERVER['HTTP_REFERER']), 'popup') !== false && strpos(strtolower($_SERVER['HTTP_REFERER']), 'reset_popup') === false)) {
    output_add_rewrite_var('popup', 1);
    $smarty->assign("T_POPUP_MODE", true);
    $popup = 1;
}
$search_message = $message = $message_type = '';
//Initialize messages, because if register_globals is turned on, some messages will be displayed twice
$load_editor = false;
$loadScripts = array();
try {
    if ($_GET['student']) {
        $currentUser = EfrontUserFactory::factory('student', false, 'student');
        $currentUser->login($currentUser->user['password'], true);
    } else {
        $currentUser = EfrontUser::checkUserAccess(false, 'student');
    }
    if ($currentUser->user['user_type'] == 'administrator') {
        throw new Exception(_ADMINISTRATORCANNOTACCESSLESSONPAGE, EfrontUserException::RESTRICTED_USER_TYPE);
    }
    $smarty->assign("T_CURRENT_USER", $currentUser);
} catch (Exception $e) {
    if ($e->getCode() == EfrontUserException::USER_NOT_LOGGED_IN && !isset($_GET['ajax'])) {
        setcookie('c_request', htmlspecialchars_decode(basename($_SERVER['REQUEST_URI'])), time() + 300);
    }
    eF_redirect("index.php?ctg=expired");
    exit;
}
         $message_type = 'failure';
     }
 } else {
     if (isset($_GET['revoke_certificate']) && !empty($result)) {
         try {
             $currentCourse->revokeCertificate($_GET['revoke_certificate']);
             eF_redirect('' . basename($_SERVER['PHP_SELF']) . '?' . $baseUrl . '&op=course_certificates&reset_popup=1&message=' . urlencode(_CERTIFICATEREVOKED) . '&message_type=success');
         } catch (Exception $e) {
             $smarty->assign("T_EXCEPTION_TRACE", $e->getTraceAsString());
             $message = _PROBLEMREVOKINGCERTIFICATE . ': ' . $e->getMessage() . ' &nbsp;<a href = "javascript:void(0)" onclick = "eF_js_showDivPopup(event, \'' . _ERRORDETAILS . '\', 2, \'error_details\')">' . _MOREINFO . '</a>';
             $message_type = 'failure';
         }
     } else {
         if (isset($_GET['reset_keep']) && !empty($result)) {
             try {
                 $user = EfrontUserFactory::factory($_GET['reset_keep']);
                 $user->resetProgressInCourse($currentCourse, true, true);
                 eF_redirect('' . basename($_SERVER['PHP_SELF']) . '?' . $baseUrl . '&op=course_certificates&reset_popup=1&message=' . urlencode(_PROGRESSRESETSUCCESSFULLY) . '&message_type=success');
             } catch (Exception $e) {
                 $smarty->assign("T_EXCEPTION_TRACE", $e->getTraceAsString());
                 $message = _PROBLEMRESETINGPROGRESS . ': ' . $e->getMessage() . ' &nbsp;<a href = "javascript:void(0)" onclick = "eF_js_showDivPopup(event, \'' . _ERRORDETAILS . '\', 2, \'error_details\')">' . _MOREINFO . '</a>';
                 $message_type = 'failure';
             }
         } else {
             if (isset($_GET['change_key']) && !empty($result)) {
                 try {
                     $result = eF_getTableData("users_to_courses", "users_LOGIN,issued_certificate", "courses_ID = " . $currentCourse->course['id'] . " and users_LOGIN = '******'login'] . "'");
                     $issued_certificate = unserialize($result[0]['issued_certificate']);
                     if ($issued_certificate) {
                         $issued_certificate['serial_number'] = $_GET['change_key'];
                         eF_updateTableData("users_to_courses", array('issued_certificate' => serialize($issued_certificate)), "courses_ID = " . $currentCourse->course['id'] . " and users_LOGIN = '******'login'] . "'");
Beispiel #28
0
 /**
  * Add a user to the group using the group key
  *
  * This function is used to add a user to the group, using the group's key
  * The courses and lessons of the group are assigned to the user using either the group's group_usertype,
  * or the user's own type if none is set
  *
  * @param mixed $user an EfrontUser object or a user login
  * @since 3.6.7
  * @access public
  */
 public function useKeyForUser($user)
 {
     if ($user instanceof EfrontUser) {
         $userObj = $user;
         $user = $user->user['login'];
     } else {
         $userObj = EfrontUserFactory::factory($user);
     }
     $groupUsers = $this->getUsers();
     if (in_array($user, $groupUsers['student']) || in_array($user, $groupUsers['professor'])) {
         //			throw new Exception(_YOUAREALREADYMEMBEROFTHISGROUP, EfrontGroupException::USER_ALREADY_MEMBER);
     }
     if (!$this->group['active']) {
         throw new Exception(_THISGROUPISINACTIVE, EfrontGroupException::ASSIGNMENT_ERROR);
     }
     if ($this->group['key_max_usage'] && $this->group['key_max_usage'] <= $this->group['key_current_usage']) {
         throw new Exception(_MAXIMUMKEYUSAGESREACHED, EfrontGroupException::ASSIGNMENT_ERROR);
     }
     $change_counter = false;
     foreach ($this->getCourses() as $course) {
         if (!$userObj->hasCourse($course['courses_ID'])) {
             $change_counter = true;
         }
     }
     foreach ($this->getLessons() as $lesson) {
         if (!$userObj->hasLesson($lesson['lessons_ID'])) {
             $change_counter = true;
         }
     }
     $max_users_errors = $this->addUsers($user, $this->group['user_types_ID'] ? $this->group['user_types_ID'] : 'student');
     if ($this->group['key_max_usage'] && $change_counter) {
         $this->group['key_current_usage']++;
         $this->persist();
     }
     if (is_array($max_users_errors) && !empty($max_users_errors)) {
         $_SESSION['s_message'] = _YOUWHEREADDEDTOTHEGROUPBUTSOMEERRORSOCCURED . '<br/>' . implode("<br>", $max_users_errors);
         $_SESSION['s_message_type'] = 'failure';
         return false;
     } else {
         $_SESSION['s_message'] = _YOUHAVEBEENSUCCESSFULLYADDEDTOTHEGROUP;
         $_SESSION['s_message_type'] = 'success';
         return true;
     }
 }
Beispiel #29
0
            $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);
        }
        $smarty->assign("T_SCORM_DATA", $scormData);
        $smarty->display('professor.tpl');
        exit;
    }
    foreach ($scormData as $value) {
        $scormIds[] = $value['id'];
    }
    if (isset($_GET['delete']) && in_array($_GET['delete'], $scormIds)) {
        eF_deleteTableData("scorm_data", "id=" . $_GET['delete']);
        $user = EfrontUserFactory::factory($scormData[0]['users_LOGIN']);
        $user->setSeenUnit($scormData[0]['content_ID'], $currentLesson, false);
        exit;
    }
} else {
    if ($_GET['scorm_import']) {
        if (isset($currentUser->coreAccess['content']) && $currentUser->coreAccess['content'] != 'change') {
            eF_redirect("" . basename($_SERVER['PHP_SELF']) . "?ctg=control_panel&message=" . urlencode(_UNAUTHORIZEDACCESS) . "&message_type=failure");
        }
        try {
            $smarty->assign("T_MAX_FILE_SIZE", FileSystemTree::getUploadMaxSize());
            $maxUploads = 5;
            $form = new HTML_QuickForm("upload_scorm_form", "post", basename($_SERVER['PHP_SELF']) . '?ctg=scorm&scorm_import=1', "", null, true);
            $form->registerRule('checkParameter', 'callback', 'eF_checkParameter');
            //Register this rule for checking user input with our function, eF_checkParameter
            $form->addElement('file', 'scorm_file[0]', _UPLOADTHESCORMFILEINZIPFORMAT);
 /**
  * Add event to eFront's events log
  *
  * This function enables module to provide events to the log
  * Events should be UNIQUELY defined INSIDE the module
  *
  * All data required for the appearance of the log message (provided by the getEventMessage function)
  * should be defined in the second argument array.
  *
  * <br/>Example:
  * <code>
  * $define("NEW_MODULE_ENTITY_INSERTION", 1);
  * $module -> addEvent(NEW_MODULE_ENTITY_INSERTION, array("id" => $id, "title" => $title));
  * </code>
  * The $data parameter is the information required by the getEventMessage function to display the related message
  * for this event.
  * Note:
  * Field 'timestamp' is automatically completed
  * If fields "users_LOGIN", "users_name" and "users_surname" are not defined, then the currentUser's info will be used
  * If fields "lessons_ID" and "lessons_name" are defined, then this event will also be related with that lesson
  * The array might contain any other fields. However, the exact same ones need to be used by getEventMessage
  *
  * @param integer $type The unique code of the event inside the particular module scope
  * @param array $data The information required by the getEventMessage function to display the related message
  * for this event.
  * @return EfrontEvent the result of the event insertion to the database or false if arguments are not correct
  * @since 3.6.0
  * @access public
  */
 public function addEvent($type, $data)
 {
     $fields = array();
     // All module related events have the same offset + the particular event's type
     $fields['type'] = EfrontEvent::MODULE_BASE_TYPE_CODE + (int) $type;
     // This should not exist normally, just in case
     unset($data['type']);
     // The discimination between events from different modules with the same type is made
     // by the entity_ID field, which is the className of the implicated module
     $fields['entity_ID'] = $this->className;
     // Mandatory users_LOGIN, users_surname, users_name fields
     if (isset($data['users_LOGIN'])) {
         $fields['users_LOGIN'] = $data['users_LOGIN'];
         if (isset($data['surname']) && isset($data['name'])) {
             $fields['users_surname'] = $data['surname'];
             $fields['users_name'] = $data['name'];
         } else {
             $eventsUser = EfrontUserFactory::factory($data['users_LOGIN']);
             $fields['users_surname'] = $eventsUser->user['surname'];
             $fields['users_name'] = $eventsUser->user['name'];
         }
         // We remove data fields, to serialize all remaining ones into the entity_name field
         unset($data['users_LOGIN']);
         unset($data['users_surname']);
         unset($data['users_name']);
     } else {
         $currentUser = $this->getCurrentUser();
         $fields['users_LOGIN'] = $currentUser->user['login'];
         $fields['users_surname'] = $currentUser->user['surname'];
         $fields['users_name'] = $currentUser->user['name'];
     }
     // The lessons_ID field associates an event with a specific lesson
     if (isset($data['lessons_ID'])) {
         $fields['lessons_ID'] = $data['lessons_ID'];
         if (isset($data['lessons_name'])) {
             $fields['lessons_name'] = $data['lessons_name'];
             unset($data['lessons_name']);
         } else {
             $lesson = new EfrontLesson($fields['lessons_ID']);
             $fields['lessons_name'] = $lesson->lesson['name'];
         }
         // We remove data fields, to serialize all remaining ones into the entity_name field
         unset($data['lessons_ID']);
     }
     // Serialize all remaining user provided data for this event, with the same labels as the ones given
     if (!empty($data)) {
         $fields['entity_name'] = serialize($data);
     }
     // Finally get current time
     $fields['timestamp'] = time();
     return EfrontEvent::triggerEvent($fields);
 }