/** * Get configuration values * * This function is used to retrieve configuration values. * Furthermore, it compares the keys of the $defaultOptions array with * The name/value pairs stored in the database. If a default name/value * pair is not present in the database, it is created using its default * value (unless the whole table is empty, in which case nothing is done) * <br>Example: * <code> * $defaultConfig = EfrontConfiguration :: getValues(); * </code> * * @return array The configuration options in name/value pairs * @access public * @since 3.0 * @static */ public static function getValues() { $options = EfrontCache::getInstance()->getCache('configuration'); if (!$options) { $options = eF_getTableDataFlat("configuration", "*"); sizeof($options) > 0 ? $options = array_combine($options['name'], $options['value']) : ($options = array()); EfrontCache::getInstance()->setCache('configuration', $options); } foreach (EfrontConfiguration::$defaultOptions as $key => $value) { if (!isset($options[$key])) { EfrontConfiguration::setValue($key, $value); $options[$key] = $value; } } return $options; }
/** * Create Payment * * This function is used to create a new payment entry * * @param array $fields The payment properties * @return payment The created payment * @since 3.6.0 * @access public */ public static function create($fields = array()) { $fields['lessons'] = array_filter($fields['lessons'], 'is_numeric'); if (isset($fields['lessons']) && sizeof($fields['lessons']) > 0) { $lessonNames = eF_getTableDataFlat("lessons", "name", "id in (" . implode(",", $fields['lessons']) . ")"); } $fields['courses'] = array_filter($fields['courses'], 'is_numeric'); if (isset($fields['courses']) && sizeof($fields['courses']) > 0) { $courseNames = eF_getTableDataFlat("courses", "name", "id in (" . implode(",", $fields['courses']) . ")"); } !isset($fields['charset']) or $fields['comments'] = iconv($fields['charset'], "UTF-8", $fields['comments']); $fields = array('timestamp' => isset($fields['timestamp']) && eF_checkParameter($fields['timestamp'], 'timestamp') ? $fields['timestamp'] : time(), 'users_LOGIN' => isset($fields['users_LOGIN']) && eF_checkParameter($fields['users_LOGIN'], 'login') ? $fields['users_LOGIN'] : $_SESSION['s_login'], 'amount' => isset($fields['amount']) && is_numeric($fields['amount']) && $fields['amount'] > 0 ? $fields['amount'] : 0, 'status' => isset($fields['status']) && $fields['status'] ? $fields['status'] : 'completed', 'txn_id' => $fields['txn_id'], 'comments' => $fields['comments'], 'method' => isset($fields['method']) && in_array($fields['method'], array_keys(self::$methods)) ? $fields['method'] : 'manual'); $user = EfrontUserFactory::factory($fields['users_LOGIN']); if ($fields['method'] == 'paypal') { //@todo: get corresponding paypal_data id $eventType = EfrontEvent::NEW_PAYPAL_PAYMENT; } else { if ($fields['method'] == 'balance') { $eventType = EfrontEvent::NEW_BALANCE_PAYMENT; } else { if ($fields['method'] == 'manual') { $eventType = EfrontEvent::NEW_MANUAL_PAYMENT; } else { $eventType = false; } } } $newId = eF_insertTableData("payments", $fields); $result = eF_getTableData("payments", "*", "id=" . $newId); //We perform an extra step/query for retrieving data, since this way we make sure that the array fields will be in correct order (first id, then name, etc) $payment = new payments($result[0]['id']); if ($eventType) { $event = array("type" => $eventType, "users_LOGIN" => $user->user['login'], "users_name" => $user->user['name'], "users_surname" => $user->user['surname'], "entity_ID" => $newId); if (isset($lessonNames) && !empty($lessonNames)) { $event['lessons_name'] = _LESSONS . ': ' . implode(",", $lessonNames['name']) . '<br>'; } if (isset($courseNames) && !empty($courseNames)) { $event['lessons_name'] .= _COURSES . ': ' . implode(",", $courseNames['name']); } if ($fields['credit']) { $event['lessons_name'] .= _BALANCE . ': ' . $fields['credit']; } EfrontEvent::triggerEvent($event); } return $payment; }
$form->addRule('header', _THEFIELD . ' ' . _SUBJECT . ' ' . _ISMANDATORY, 'required', null, 'client'); $form->addRule('header', _INVALIDFIELDDATA, 'checkParameter', 'text'); $load_editor = true; $form->addElement('textarea', 'message', _BODY, 'class = "digestEditor" id="messageBody" onActivate="myActiveElement=\'\';" style = "width:100%;height:200px"'); // Get available lessons $lessons = eF_getTableDataFlat("lessons", "id,name", "archive=0", "name"); sizeof($lessons) > 0 ? $av_lessons = array_combine(array_merge(array("0"), $lessons['id']), array_merge(array(_ANYLESSON), $lessons['name'])) : ($av_lessons = array(0 => _ANYLESSON)); sizeof($lessons) > 0 ? $lessons = array_combine($lessons['id'], $lessons['name']) : ($lessons = array()); // Get available courses $courses = eF_getTableDataFlat("courses", "id,name", "archive=0", "name"); //return only unarchived courses sizeof($courses) > 0 ? $av_courses = array_combine(array_merge(array("0"), $courses['id']), array_merge(array(_ANYCOURSE), $courses['name'])) : ($av_courses = array(0 => _ANYCOURSE)); sizeof($courses) > 0 ? $courses = array_combine($courses['id'], $courses['name']) : ($courses = array()); $smarty->assign("T_COURSES", $courses); // Get available tests $tests = eF_getTableDataFlat("tests", "id,name", "", "name"); $tests['id'] = array_merge(array("0"), $tests['id']); $tests['name'] = array_merge(array(_ANYTEST), $tests['name']); sizeof($tests) > 0 ? $tests = array_combine($tests['id'], $tests['name']) : ($tests = array("0" => _ANYTEST)); $smarty->assign("T_TESTS", $tests); /* // User groups in any case $groups = eF_getTableData("groups", "id, name", "active=1"); $groups_list = array(); if (!empty($groups)) { foreach ($groups as $group) { $log = $group['id']; $groups_list["$log"] = $group['name']; } } else { $groups_list["0"] = _NOGROUPSDEFINED;
/** * Complete course * * This function is used to set the course status to completed for * the current user. If the course is set to automatically issue a * certificate, the certificate is issued. * <br/>Example: * <code> * $user -> completeCourse(5, 87, 'Very good progress'); //Complete course with id 5 * </code> * * @param Efrontmixed $course Either an EfrontCourse object or a course id * @param int $score The course score * @param string $comments Comments for the course completion * @return boolean True if everything is ok */ public function completeCourse($course, $score, $comments, $time = '') { $time ? $timestamp = $time : ($timestamp = time()); if (!$course instanceof EfrontCourse) { $course = new EfrontCourse($course); } $constraints = array('archive' => false, 'active' => true, 'return_objects' => false); $userCourses = $this->getUserCourses($constraints); if (in_array($course->course['id'], array_keys($userCourses))) { //keep completed date when it is set (when only score changed for example) $checkCompleted = $userCourses[$course->course['id']]['to_timestamp']; $fields = array('completed' => 1, 'to_timestamp' => $timestamp, 'score' => str_replace(',', '.', $score), 'comments' => $comments); $where = "users_LOGIN = '******'login'] . "' and courses_ID=" . $course->course['id']; EfrontCourse::persistCourseUsers($fields, $where, $course->course['id'], $this->user['login']); if (!self::$cached_modules) { self::$cached_modules = eF_loadAllModules(); } // Trigger all necessary events. If the function has not been re-defined in the derived module class, nothing will happen foreach (self::$cached_modules as $module) { $module->onCompleteCourse($course->course['id'], $this->user['login']); } if ($course->options['auto_certificate']) { $certificate = $course->prepareCertificate($this->user['login'], $time); $course->issueCertificate($this->user['login'], $certificate); } $event = array("type" => EfrontEvent::COURSE_COMPLETION, "users_LOGIN" => $this->user['login'], "lessons_ID" => $course->course['id'], "lessons_name" => $course->course['name'], "replace" => true); EfrontEvent::triggerEvent($event); // Assign the related course skills to the employee if (G_VERSIONTYPE == 'enterprise') { #cpp#ifdef ENTERPRISE if (!$this->aspects['hcd']) { $this->aspects['hcd'] = EfrontEmployeeFactory::factory($this->user['login']); } $employee = $this->aspects['hcd']; $newSkills = eF_getTableDataFlat("module_hcd_course_offers_skill", "skill_ID, specification", "courses_ID = '" . $course->course['id'] . "'"); // The course associated skills will *complement* the existing ones - last argument = true $employee->addSkills($newSkills['skill_ID'], $newSkills['specification'], array_fill(0, sizeof($newSkills['skill_ID']), $score), true); } #cpp#endif return true; } else { return false; } }
private static function assignSourceLessonsToInstance($instanceSource, $instance) { $result = eF_getTableDataFlat("lessons_to_courses lc, lessons l", "l.id, l.instance_source", "l.id=lc.lessons_ID and lc.courses_ID=" . $instanceSource->course['id']); $instanceSourceLessonsThatAreUnique = array_combine($result['id'], $result['instance_source']); $instanceSourceLessons = $instanceSource->getCourseLessons(); $newLessons = array(); $lessonsSchedule = array(); foreach ($instanceSourceLessons as $key => $foo) { //Do this to get the lessons in the correct order $value = $instanceSourceLessonsThatAreUnique[$key]; if ($value) { $lessonInstance = EfrontLesson::createInstance($value, $instance->course['id']); $newLessons[] = $lessonInstance->lesson['id']; $lessonsSchedule[$lessonInstance->lesson['id']] = array('start_date' => $foo->lesson['start_date'], 'end_date' => $foo->lesson['end_date'], 'start_period' => $foo->lesson['start_period'], 'end_period' => $foo->lesson['end_period']); } else { $newLessons[] = $key; $lessonsSchedule[$key] = array('start_date' => $foo->lesson['start_date'], 'end_date' => $foo->lesson['end_date'], 'start_period' => $foo->lesson['start_period'], 'end_period' => $foo->lesson['end_period']); } } $instance->addLessons($newLessons, $lessonsSchedule); }
/** * Import users * * This function is used to import users from the given CSV * file. * <br/>Example: * <code> * $file = new EfrontFile(/var/www/efront/upload/admin/temp/users.csv); * EfrontSystem :: importUsers($file); * </code> * * @param mixed $file The CVS file with the users, either an EfrontFile object or the full path to the file * @param boolean $replaceUsers Whether to replace existing users having the same name as the ones imported * @return array The imported users in an array of EfrontUser objects * @since 3.5.0 * @access public */ public static function importUsers($file, $replaceUsers = false) { if (!$file instanceof EfrontFile) { $file = new EfrontFile($file); } $usersTable = eF_getTableData("users", "*", ""); $tableFields = array_keys($usersTable[0]); // Get user types to check if they exist $userTypesTable = eF_getTableData("user_types", "*", ""); // Set the userTypesTable to find in O(1) the existence or not of a user-type according to its name foreach ($userTypesTable as $key => $userType) { $userTypesTable[$userType['name']] = $userType; } // If we work on the enterprise version we need to distinguish between users and module_hcd_employees tables fields //$userFields = array('login', 'password','email','languages_NAME','name','surname','active','comments','user_type','timestamp','avatar','pending','user_types_ID'); $userFields = eF_getTableFields('users'); $existingUsers = eF_getTableDataFlat("users", "login"); $fileContents = file_get_contents($file['path']); $fileContents = explode("\n", trim($fileContents)); $separator = ";"; //$fields = explode($separator, trim($fileContents[0])); $fields = str_getcsv(trim($fileContents[0]), $separator); if (sizeof($fields) == 1) { $separator = ","; //$fields = explode($separator, $fileContents[0]); $fields = str_getcsv(trim($fileContents[0]), $separator); if (sizeof($fields) == 1) { throw new Exception(_UNKNOWNSEPARATOR, EfrontSystemException::ILLEGAL_CSV); } } foreach ($fields as $key => $value) { if (empty($value)) { $unused = $key; unset($fields[$key]); } } $inserted = 0; $matched = array_intersect($fields, $tableFields); $newUsers = array(); $messages = array(); // The check here is removed to offer interoperability between enterprise and educational versions // throw new Exception (_PLEASECHECKYOURCSVFILEFORMAT, EfrontSystemException::ILLEGAL_CSV); for ($i = 1; $i < sizeof($fileContents); $i++) { //$csvUser = explode($separator, $fileContents[$i]); $csvUser = str_getcsv($fileContents[$i], $separator); unset($csvUser[$unused]); if (sizeof($csvUser) != sizeof($fields)) { throw new Exception(_PLEASECHECKYOURCSVFILEFORMAT . ': ' . _NUMBEROFFIELDSMUSTBE . ' ' . sizeof($fields) . ' ' . _BUTFOUND . ' ' . sizeof($csvUser), EfrontSystemException::ILLEGAL_CSV); } $csvUser = array_combine($fields, $csvUser); array_walk($csvUser, create_function('&$v, $k', '$v=trim($v);')); if (in_array($csvUser['login'], $existingUsers['login']) && $replaceUsers) { $existingUser = EfrontUserFactory::factory($csvUser['login']); $existingUser->delete(); } if (!in_array($csvUser['login'], $existingUsers['login']) || $replaceUsers) { if (!isset($csvUser['password']) || !$csvUser['password']) { $csvUser['password'] = $csvUser['login']; } // Check the user-type existence by name if ($csvUser['user_type_name'] != "" && isset($userTypesTable[$csvUser['user_type_name']])) { // If there is a mismatch between the imported custom type basic type and the current basic type // then set no custom type if ($userTypesTable[$csvUser['user_type_name']]['basic_user_type'] != $csvUser['user_type']) { $csvUser['user_types_ID'] = 0; } else { $csvUser['user_types_ID'] = $userTypesTable[$csvUser['user_type_name']]['id']; } } else { $csvUser['user_types_ID'] = 0; } unset($csvUser['user_type_name']); if (!$csvUser['user_type']) { $csvUser['user_type'] = 'student'; } //If user type is not valid, don't insert that user if ($csvUser['user_type'] != "administrator" && $csvUser['user_type'] != "professor" && $csvUser['user_type'] != "student") { $messages[] = '"' . $csvUser['login'] . '": ' . _INVALIDUSERTYPE; unset($csvUser); continue; } // If we are not in enterprise version then $csvEmployeeProperties is used as a buffer // This is done to enable enterprise <-> Enteprise, educational <-> educational, enterprise <-> educational imports/exports $csvEmployeeProperties = $csvUser; if (G_VERSIONTYPE == 'enterprise') { #cpp#ifdef ENTERPRISE // Copy all fields and remove the user ones -> leaving only employee related fields $csvEmployeeProperties['users_login'] = $csvUser['login']; } #cpp#endif // Delete and recreate $csvUser to keep only the fields in userFields unset($csvUser); foreach ($userFields as $field) { if (isset($csvEmployeeProperties[$field])) { $csvUser[$field] = $csvEmployeeProperties[$field]; if (G_VERSIONTYPE == 'enterprise') { #cpp#ifdef ENTERPRISE unset($csvEmployeeProperties[$field]); } #cpp#endif } } try { if (G_VERSIONTYPE == 'enterprise') { #cpp#ifdef ENTERPRISE $user = EfrontUser::createUser($csvUser); if (isset($csvEmployeeProperties['branch_name'])) { $result = eF_getTableData("module_hcd_branch", "branch_ID", "name='" . $csvEmployeeProperties['branch_name'] . "'"); if ($result[0]['branch_ID']) { $branchId = $result[0]['branch_ID']; } unset($csvEmployeeProperties['branch_name']); } if (isset($csvEmployeeProperties['job_name'])) { $result = eF_getTableData("module_hcd_job_description", "job_description_ID", "description='" . $csvEmployeeProperties['job_name'] . "'"); if ($result[0]['job_description_ID']) { $jobId = $result[0]['job_description_ID']; } unset($csvEmployeeProperties['job_name']); } if (isset($csvEmployeeProperties['job_role'])) { $csvEmployeeProperties['job_role'] ? $jobRole = 1 : ($jobRole = 0); unset($csvEmployeeProperties['job_role']); } $user->aspects['hcd'] = EfrontHcdUser::createUser($csvEmployeeProperties); if (isset($branchId) && isset($jobId) && isset($jobRole)) { $user->aspects['hcd']->addJob($user, $jobId, $branchId, $jobRole); } $newUsers[] = $user; } else { #cpp#else $newUsers[] = EfrontUser::createUser($csvUser); } #cpp#endif } catch (Exception $e) { $messages[] = '"' . $csvUser['login'] . '": ' . $e->getMessage() . ' (' . $e->getCode() . ')'; } } } return array($newUsers, $messages); }
/** * Delete the skill corresponding to this lesson: Every lesson is mapped to a skill like "Knowledge of that lesson" * This deletion takes place when a lesson is changed from regular lesson to course_only * * <br/>Example: * <code> * $lesson -> deleteLessonSkill(); * </code> * * @return the result of the table deletion * @since 3.5.2 * @access public */ public function deleteLessonSkill() { // Delete the corresponding lesson skill to the skill and lesson_offers_skill tables $lesson_skill = eF_getTableData("module_hcd_skills JOIN module_hcd_lesson_offers_skill ON module_hcd_skills.skill_ID = module_hcd_lesson_offers_skill.skill_ID", "*", "lesson_ID = " . $this->lesson['id'] . " AND module_hcd_skills.categories_ID = -1"); eF_deleteTableData("module_hcd_skills", "skill_ID = " . $lesson_skill[0]['skill_ID']); // Delete all question-to-lesson specific skill assignments $questions = eF_getTableDataFlat("questions", "id", "lessons_ID = " . $this->lesson['id']); eF_deleteTableData("questions_to_skills", "questions_id IN ('" . implode("','", $questions['id']) . "') AND skills_ID = " . $lesson_skill[0]['skill_ID']); return eF_deleteTableData("module_hcd_lesson_offers_skill", "lesson_ID = " . $this->lesson['id'] . " AND skill_ID = " . $lesson_skill[0]['skill_ID']); }
$key = key($result['timestamp']); $topics[$k]['last_post'] = array('id' => $result['id'][$key], 'users_LOGIN' => $result['users_LOGIN'][$key], 'timestamp' => $result['timestamp'][$key]); $topics[$k]['last_post_timestamp'] = $result['timestamp'][$key]; $topics[$k]['first_message'] = strip_tags($result['body'][0]); } $last_posts[] = $topic['last_post']['timestamp']; //This array will be used for sorting according to last post } array_multisort($last_posts, SORT_DESC, $topics); //Sort topics so that those with most recent messages are displayed first foreach ($polls as $k => $poll) { if ($_SESSION['s_type'] != 'administrator' && $_SESSION['s_current_branch']) { //this applies to supervisors only $result = eF_getTableDataFlat("f_users_to_polls, module_hcd_employee_works_at_branch", "count(*)", "vote != 0 and f_poll_ID=" . $poll['id'] . " and module_hcd_employee_works_at_branch.users_login=f_users_to_polls.users_LOGIN and module_hcd_employee_works_at_branch.branch_ID=" . $currentBranch->branch['branch_ID']); } else { $result = eF_getTableDataFlat("f_users_to_polls", "count(*)", "vote != 0 and f_poll_ID=" . $poll['id']); } $polls[$k]['votes'] = $result['count(*)'][0]; } $smarty->assign("T_FORUM_TOPICS", $topics); $smarty->assign("T_FORUM_POLLS", $polls); if ((!$currentUser->coreAccess['forum'] || $currentUser->coreAccess['forum'] == 'change') && ($currentUser->user['user_type'] != 'student' || isset($forum_config) && $forum_config['students_add_forums']) && (!isset($_GET['forum']) || $forums[$_GET['forum']]['status'] != 2)) { $forum_options = array(1 => array('text' => _NEWFORUM, 'image' => "16x16/add.png", 'href' => basename($_SERVER['PHP_SELF']) . "?ctg=forum&add=1&type=forum&parent_forum_id={$parent_forum}&popup=1", 'onclick' => "eF_js_showDivPopup(event, '" . _NEWFORUM . "', 2)", 'target' => "POPUP_FRAME")); $smarty->assign("T_FORUM_OPTIONS", $forum_options); } } } //Calculate the forum parents, so the title may be created and displayed while ($parent_forum != 0 && $count++ < 100) { //Count is put to prevent an unexpected infinite loop $result = eF_getTableData("f_forums", "id,title,parent_id,lessons_ID", "id={$parent_forum}");
//the file is a temporary scorm exported file //proceed } else { if (preg_match("#" . G_UPLOADPATH . "(.*)/projects/#", $file['path'], $matches) || preg_match("#" . G_UPLOADPATH . "(.*)/tests/#", $file['path'], $matches)) { //this is a project or test file. Check whether the current user has access to it if ($matches[1] == $_SESSION['s_login']) { //continue if a user is trying to view his/her own file } else { if ($_SESSION['s_lesson_user_type'] != 'professor' || !$_SESSION['s_lessons_ID']) { throw new EfrontFileException(_YOUCANNOTACCESSTHEREQUESTEDRESOURCE, EfrontFileException::UNAUTHORIZED_ACTION); } else { if (!eF_checkParameter($matches[1], 'login')) { throw new EfrontFileException(_YOUCANNOTACCESSTHEREQUESTEDRESOURCE, EfrontFileException::UNAUTHORIZED_ACTION); } else { $professorLessons = eF_getTableDataFlat("lessons l, users_to_lessons ul", "id", "l.archive=0 and l.id=ul.lessons_ID and ul.archive=0 and ul.users_LOGIN='******'login'] . "'"); $userLessons = eF_getTableDataFlat("lessons l, users_to_lessons ul", "id", "l.archive=0 and l.id=ul.lessons_ID and ul.archive=0 and ul.users_LOGIN='******'"); if (!in_array($_SESSION['s_lessons_ID'], array_intersect($professorLessons['id'], $userLessons['id']))) { throw new EfrontFileException(_YOUCANNOTACCESSTHEREQUESTEDRESOURCE, EfrontFileException::UNAUTHORIZED_ACTION); } } } } } else { if (preg_match("#" . G_UPLOADPATH . "(.*)/avatars/#", $file['path'], $matches) || mb_strpos($file['path'], G_SYSTEMAVATARSPATH) !== false || mb_strpos($file['path'], G_UPLOADPATH) !== false && mb_strpos($file['path'], 'forum') !== false) { //proceed } else { if (mb_strpos($file['path'], G_UPLOADPATH) !== false && mb_strpos($file['path'], G_UPLOADPATH . $currentUser->user['login']) === false && $file['access'] != 777) { throw new EfrontFileException(_YOUCANNOTACCESSTHEREQUESTEDRESOURCE, EfrontFileException::UNAUTHORIZED_ACTION); } } }
} if (!isset($courses) || !$courses && !is_array($courses)) { //$courses = EfrontCourse :: getCourses(true); $constraints = array('active' => true, 'archive' => false, 'instance' => false, 'sort' => 'name'); $constraints['required_fields'] = array('has_instances'); $courses = EfrontCourse::getAllCourses($constraints); if ($_SESSION['s_current_branch']) { //filter out courses that don't belong to the current branch url $stats_filters = array(); $branches = array($_SESSION['s_current_branch']); $branchesTree = new EfrontBranchesTree(); $iterator = new EfrontNodeFilterIterator(new RecursiveIteratorIterator(new RecursiveArrayIterator($branchesTree->getNodeChildren($_SESSION['s_current_branch'])), RecursiveIteratorIterator::SELF_FIRST)); foreach ($iterator as $key => $value) { $branches[] = $key; } $result = eF_getTableDataFlat("module_hcd_course_to_branch", "courses_ID", "branches_ID in (" . implode(",", $branches) . ")"); foreach ($courses as $key => $value) { if (!in_array($key, $result['courses_ID'])) { unset($courses[$key]); } } } } //Mark the lessons and courses that the user already has, so that they can't be selected try { if (isset($_SESSION['s_login']) && $_SESSION['s_login']) { $currentUser = EfrontUserFactory::factory($_SESSION['s_login']); if ($currentUser->user['user_type'] == 'administrator') { throw new Exception(); } $userLessons = $currentUser->getLessons();
//Assign this form to the renderer, so that corresponding template code is created $smarty->assign('T_IMPORT_LESSON_FORM', $renderer->toArray()); //Assign the form to the template $lessons = EFrontLesson::getLessons(); $directionsTree = new EfrontDirectionsTree(); $directionPaths = $directionsTree->toPathString(); if (G_VERSIONTYPE == 'enterprise') { $result = eF_getTableDataFlat("lessons LEFT OUTER JOIN module_hcd_lesson_offers_skill ON module_hcd_lesson_offers_skill.lesson_ID = lessons.id", "lessons.id, count(skill_ID) as skills_offered", "lessons.archive=0", "", "id"); foreach ($result['id'] as $key => $lesson_id) { if (isset($lessons[$lesson_id])) { $lessons[$lesson_id]['skills_offered'] = $result['skills_offered'][$key]; } } } //Perform a query to get all the 'student' and 'student-like' users of every lesson $result = eF_getTableDataFlat("lessons l,users_to_lessons ul left outer join user_types ut on ul.user_type=ut.id", "l.id,count(*)", "ul.archive=0 and l.id=ul.lessons_ID and (ul.user_type='student' or (ul.user_type = ut.id and ut.basic_user_type = 'student'))", "", "l.id"); if (sizeof($result) > 0) { $lessonUsers = array_combine($result['id'], $result['count(*)']); } foreach ($lessons as $key => $lesson) { if (isset($lessonUsers[$key]) && !$lesson['course_only']) { $lessons[$key]['students'] = $lessonUsers[$key]; } else { $lessons[$key]['students'] = 0; } if (isset($_COOKIE['toggle_active'])) { if ($_COOKIE['toggle_active'] == 1 && !$lesson['active'] || $_COOKIE['toggle_active'] == -1 && $lesson['active']) { unset($lessons[$key]); } } if ($lessons[$key]['creator_LOGIN'] != $_SESSION['s_login']) {
/** * Function searchForOneWord() * * @param string $word The word to search for * @param int $maxres The total number of words it should return * @param string $table_name ? * @param string $position The position of the string we are looking for * @since 3.5.0 * @access public */ public static function searchForOneWord($word, $maxres, $tableName, $position) { $position == "title" ? $position_str = 0 : ($position_str = 1); $res = eF_getTableDataFlat("search_invertedindex", "id", "keyword like '%{$word}%'"); if (sizeof($res) > 0) { $idsList = implode(",", $res['id']); $result = eF_getTableDataFlat("search_keywords", "foreign_ID, count(keyword) AS score, table_name, position", "keyword IN ({$idsList})" . ($position ? ' and position=' . $position_str : '') . ($tableName ? ' and table_name=' . EfrontSearch::$tableAssoc[$tableName] : '') . "", "", "foreign_ID,table_name limit {$maxres}"); } return $result; }
$result = eF_getTableDataFlat("users JOIN module_hcd_employee_has_job_description ON users.login = module_hcd_employee_has_job_description.users_login JOIN module_hcd_job_description ON module_hcd_job_description.job_description_ID = module_hcd_employee_has_job_description.job_description_ID", "distinct login", "users.active = 1 AND module_hcd_job_description.description = '" . $form->exportValue('job_description_recipients') . "'"); } else { $result = eF_getTableDataFlat("users JOIN module_hcd_employee_has_job_description ON users.login = module_hcd_employee_has_job_description.users_login", "distinct login", "users.active = 1"); } break; case 'specific_skill': $result = eF_getTableDataFlat("users JOIN module_hcd_employee_has_skill ON users.login = module_hcd_employee_has_skill.users_login", "distinct login", "users.active = 1 AND module_hcd_employee_has_skill.skill_ID = '" . $form->exportValue('skill_recipients') . "'"); break; default: break; } if ($values['specific_type']) { if (!is_numeric($form->exportValue('user_type'))) { $filter_user_type = eF_getTableDataFlat("users", "login", "users.active=1 AND users.user_type='" . $form->exportValue('user_type') . "'"); } else { $filter_user_type = eF_getTableDataFlat("users", "login", "users.active=1 AND users.user_types_ID='" . $form->exportValue('user_type') . "'"); } if ($values['recipients'] == 'only_specific_users') { //Meaning we only clicked on the checkbox for user types $result = $filter_user_type; } else { $result['login'] = array_intersect($result['login'], $filter_user_type['login']); } } if ($_SESSION['s_type'] != 'administrator' && $_SESSION['s_current_branch']) { //this applies to supervisors only $currentBranch = new EfrontBranch($_SESSION['s_current_branch']); $branchTreeUsers = array_keys($currentBranch->getBranchTreeUsers()); foreach ($result['login'] as $key => $value) { if (!in_array($value, $branchTreeUsers)) { unset($result['login'][$key]);
$tooltipInfo[] = '<div class = "infoEntry"><span>' . _MAXIMUMUSERS . "</span><span>: {$value}</span></div>"; $tooltipInfo[] = '<div class = "infoEntry"><span>' . _SEATSREMAINING . "</span><span>: " . $lessonInformation['seats_remaining'] . "</span></div>"; break; default: break; } } } if ($string = implode("", $tooltipInfo)) { echo '<html ' . ($GLOBALS['rtl'] ? 'dir = "rtl"' : '') . ' >' . $string . '</html>'; } else { echo _NODATAFOUND; } } if (isset($_GET['courses_ID']) && eF_checkParameter($_GET['courses_ID'], 'id') && $_GET['type'] == 'branches') { $result = eF_getTableDataFlat("module_hcd_course_to_branch mb, module_hcd_branch b", "mb.branches_ID, b.name", "b.branch_ID=mb.branches_ID and mb.courses_ID=" . $_GET['courses_ID']); $tooltipInfo = '<div class = "infoEntry"><span>' . implode(", ", $result['name']) . "</span><span></span></div>"; echo $tooltipInfo; exit; } if (isset($_GET['courses_ID']) && eF_checkParameter($_GET['courses_ID'], 'id')) { $course = new EfrontCourse($_GET['courses_ID']); $courseInformation = $course->getInformation(); if ($courseInformation['professors']) { foreach ($courseInformation['professors'] as $value) { $professorsString[] = formatLogin($value['login']); } $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;
eF_redirect(basename($_SERVER['PHP_SELF']) . '?ctg=progress&message=' . urlencode(_STUDENTSTATUSCHANGED) . '&message_type=success'); } } $renderer = new HTML_QuickForm_Renderer_ArraySmarty($smarty); $form->setJsWarnings(_BEFOREJAVASCRIPTERROR, _AFTERJAVASCRIPTERROR); $form->setRequiredNote(_REQUIREDNOTE); $form->accept($renderer); $smarty->assign('T_COMPLETE_LESSON_FORM', $renderer->toArray()); $doneTests = EfrontStats::getDoneTestsPerUser($_GET['edit_user'], false, $currentLesson->lesson['id']); $result = EfrontStats::getStudentsDoneTests($currentLesson->lesson['id'], $_GET['edit_user']); foreach ($result[$_GET['edit_user']] as $key => $value) { if ($value['scorm']) { $scormDoneTests[$key] = $value; } } $testNames = eF_getTableDataFlat("tests t, content c", "t.id, c.name", "c.id=t.content_ID and t.active=1 and t.publish=1 and c.ctg_type='tests' and c.lessons_ID=" . $currentLesson->lesson['id']); $testNames = array_combine($testNames['id'], $testNames['name']); foreach ($doneTests[$_GET['edit_user']] as $key => $value) { if (in_array($key, array_keys($testNames))) { $userStats['done_tests'][$key] = array('name' => $testNames[$key], 'score' => $value['average_score'], 'last_test_id' => $value['last_test_id'], 'active_test_id' => $value['active_test_id'], 'last_score' => $value['scores'][$value['last_test_id']], 'active_score' => $value['active_score'], 'times_done' => $value['times_done'], 'content_ID' => $value[$value['last_test_id']]['content_ID']); } } foreach ($scormDoneTests as $key => $value) { $userStats['scorm_done_tests'][$key] = array('name' => $value['name'], 'score' => $value['score'], 'content_ID' => $key); } unset($userStats['done_tests']['average_score']); $smarty->assign("T_USER_LESSONS_INFO", $userStats); $notDoneTests = array_diff(array_keys($testNames), array_keys($doneTests[$_GET['edit_user']])); $smarty->assign("T_PENDING_TESTS", $notDoneTests); if ($GLOBALS['configuration']['time_reports']) { $userTime = EfrontTimes::formatTimeForReporting(EfrontLesson::getUserActiveTimeInLesson($editedUser->user['login'], $currentLesson->lesson['id']));
} } else { unset($editCourse->options['recurring']); } //$editCourse -> course['instance_source'] OR $editCourse -> options['course_code'] = $form -> exportValue('course_code'); //Instances don't have a code of their own $editCourse->options['training_hours'] = $form->exportValue('training_hours'); $editCourse->options['duration'] = $form->exportValue('duration') ? $form->exportValue('duration') : null; //$editCourse -> options['course_code'] = $form -> exportValue('course_code') ? $form -> exportValue('course_code') : null; //$editCourse -> options['duration'] = $form -> exportValue('duration'); //$start_date = mktime(0, 0, 0, $_POST['date_Month'], $_POST['date_Day'], $_POST['date_Year']); $editCourse->persist(); if (isset($updateCourseInstancesCategory) && $updateCourseInstancesCategory) { eF_updateTableData("courses", array("directions_ID" => $editCourse->course['directions_ID']), "instance_source=" . $editCourse->course['id']); } if ($form->exportValue('branches_ID') && eF_checkParameter($form->exportValue('branches_ID'), 'id')) { $result = eF_getTableDataFlat("module_hcd_course_to_branch", "branches_ID", "courses_ID=" . $editCourse->course['id']); if (sizeof($result['branches_ID']) == 0) { eF_insertTableData("module_hcd_course_to_branch", array("branches_ID" => $form->exportValue('branches_ID'), "courses_ID" => $editCourse->course['id'])); } elseif (sizeof($result['branches_ID']) == 1) { //Only one branch associated with this course, as a 'location' eF_updateTableData("module_hcd_course_to_branch", array("branches_ID" => $form->exportValue('branches_ID')), "courses_ID=" . $editCourse->course['id']); } } else { if (G_VERSIONTYPE == 'enterprise') { #cpp#ifdef ENTERPRISE eF_deleteTableData("module_hcd_course_to_branch", "courses_ID=" . $editCourse->course['id']); } #cpp#endif } !isset($redirect) or eF_redirect($redirect); } catch (Exception $e) {
public function onRemoveUsersFromCourse($courseId, $users) { $result = eF_getTableDataFlat("users", "login,email"); $emails = array_combine($result['login'], $result['email']); foreach ($users as $value) { $recipients[] = $emails[$value['users_LOGIN']]; } $this->cancelInvitation($courseId, $recipients); return true; }
} foreach ($iterator = new EfrontTestsFilterIterator(new EfrontVisitableFilterIterator(new EfrontNodeFilterIterator(new RecursiveIteratorIterator(new RecursiveArrayIterator($currentContent->tree), RecursiveIteratorIterator::SELF_FIRST)))) as $key => $value) { $testsIds[$key] = $key; //Get the not-test unit ids for this content } $lessonInformation = $currentLesson->getInformation($currentUser->user['login']); foreach ($lesson_info_categories as $key => $value) { if ($lessonInformation[$key] != "") { $lessonInformation[$key] = str_replace("\n", "<br />", $lessonInformation[$key]); } } $smarty->assign("T_LESSON_INFO", $lessonInformation); if (!$_admin_) { $seenContent = EfrontStats::getStudentsSeenContent($currentLesson->lesson['id'], $currentUser->user['login']); //Get the passing score for each "specific_test" rule $allTestsScore = eF_getTableDataFlat("tests", "content_ID,mastery_score"); if (sizeof($allTestsScore) > 0) { $allTestsScore = array_combine($allTestsScore['content_ID'], $allTestsScore['mastery_score']); } else { $allTestsScore = array(); } foreach ($conditions as $key => $condition) { if ($condition['type'] == 'specific_test') { $conditions[$key]['test_passing_score'] = $allTestsScore[$condition['options'][0]]; } } $times = new EfrontTimes(); list($conditionsStatus, $lessonPassed) = EfrontStats::checkConditions($seenContent[$currentLesson->lesson['id']][$currentUser->user['login']], $conditions, $visitableContentIds, $testsIds, EfrontLesson::getUserActiveTimeInLesson($currentUser->user['login'], $currentLesson->lesson['id'])); $smarty->assign("T_CONDITIONS", $conditions); $smarty->assign("T_CONDITIONS_STATUS", $conditionsStatus); //$smarty -> assign("T_LESSON_PASSED", $lessonPassed);
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(" → ", " -> ", $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(" → ", " -> ", $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()); }
public function getModule() { $currentLesson = $this->getCurrentLesson(); $smarty = $this->getSmartyVar(); $smarty->assign("T_LESSON_ID", $currentLesson->lesson['id']); if (isset($_GET['delete_link']) && eF_checkParameter($_GET['delete_link'], 'id')) { eF_deleteTableData("module_links", "id=" . $_GET['delete_link']); $this->setMessageVar(_LINKS_SUCCESFULLYDELETEDLINK, 'success'); eF_redirect("" . $this->moduleBaseUrl . "&message=" . urlencode($message) . "&message_type={$message_type}"); } else { if (isset($_GET['add_link']) || isset($_GET['edit_link']) && eF_checkParameter($_GET['edit_link'], 'id')) { $form = new HTML_QuickForm("link_entry_form", "POST", $_SERVER['REQUEST_URI'], ""); $form->registerRule('checkParameter', 'callback', 'eF_checkParameter'); //Register this rule for checking user input with our function, eF_checkParameter $form->addElement('text', 'display', null); $form->addElement('text', 'link', null); $form->addElement('textarea', 'description', null); $form->addElement('submit', 'submit_link', _SUBMIT, 'class = "flatButton"'); $element =& $form->getElement('display'); $element->setSize(50); $element =& $form->getElement('link'); $element->setSize(50); $element =& $form->getElement('description'); $element->setCols(50); if (isset($_GET['edit_link'])) { $link_entry = eF_getTableData("module_links", "*", "id=" . $_GET['edit_link']); $form->setDefaults(array('display' => $link_entry[0]['display'], 'link' => $link_entry[0]['link'], 'description' => $link_entry[0]['description'])); } else { $form->setDefaults(array('link' => "http://")); } if ($form->isSubmitted() && $form->validate()) { $fields = array('lessons_ID' => $_SESSION['s_lessons_ID'], 'display' => $form->exportValue('display'), 'link' => $form->exportValue('link'), 'description' => $form->exportValue('description')); if (isset($_GET['edit_link'])) { if (eF_updateTableData("module_links", $fields, "id=" . $_GET['edit_link'])) { $message = _LINKS_SUCCESFULLYUPDATEDLINKENTRY; $message_type = 'success'; eF_redirect("" . $_SERVER['PHP_SELF'] . "?ctg=module&op=module_links&message=" . urlencode($message) . "&message_type={$message_type}"); } else { $message = _LINKS_PROBLEMUPDATINGLINKENTRY; $message_type = 'failure'; eF_redirect("" . $_SERVER['PHP_SELF'] . "?ctg=module&op=module_links&message=" . urlencode($message) . "&message_type={$message_type}"); } } else { if (eF_insertTableData("module_links", $fields)) { $message = _LINKS_SUCCESFULLYINSERTEDLINKENTRY; $message_type = 'success'; eF_redirect("" . $_SERVER['PHP_SELF'] . "?ctg=module&op=module_links&message=" . urlencode($message) . "&message_type={$message_type}"); } else { $message = _LINKS_PROBLEMINSERTINGLINKENTRY; $message_type = 'failure'; eF_redirect("" . $_SERVER['PHP_SELF'] . "?ctg=module&op=module_links&message=" . urlencode($message) . "&message_type={$message_type}"); } } } $renderer = new HTML_QuickForm_Renderer_ArraySmarty($smarty); $form->accept($renderer); $smarty->assign('T_LINKS_FORM', $renderer->toArray()); } else { $links = eF_getTableDataFlat("module_links", "*", "lessons_ID = " . $_SESSION['s_lessons_ID']); $smarty->assign("T_LINKS", $links); } } return true; }
protected function exportData($data) { $result = eF_getTableDataFlat("user_profile", "name", "active=1 AND type ='date'"); //Get admin-defined form fields for user registration $dateFields = array(); if (!empty($result)) { $dateFields = $result['name']; } foreach ($data as $info) { unset($info['password']); foreach ($info as $field => $value) { if (!(strpos($field, "timestamp") === false) || !(strpos($field, "date") === false) || $field == "hired_on" || $field == "left_on" || in_array($field, $dateFields)) { $info[$field] = $this->createDatesFromTimestamp($value); } } $this->lines[] = implode($this->separator, $info); } }
$workSheet->write($row, 6, formatScore($lesson['overall_progress']['percentage']) . "%", $fieldCenterFormat); if (EfrontUser::isOptionVisible('tests')) { $workSheet->write($row, 7, formatScore($lesson['test_status']['mean_score']) . "%", $fieldCenterFormat); } if (EfrontUser::isOptionVisible('projects')) { $workSheet->write($row, 8, formatScore($lesson['project_status']['mean_score']) . "%", $fieldCenterFormat); } $workSheet->write($row, 9, $lesson['completed'] ? _YES : _NO, $fieldCenterFormat); $workSheet->write($row, 10, formatTimestamp($lesson['timestamp_completed']), $fieldCenterFormat); $workSheet->write($row, 11, $lesson['completed'] ? formatScore($lesson['score']) . "%" : '', $fieldCenterFormat); $row++; } } $row++; } $result = eF_getTableDataFlat("lessons", "id, name, active"); $lessonNames = array_combine($result['id'], $result['name']); //Done tests sheet $doneTests = EfrontStats::getStudentsDoneTests(false, $infoUser->user['login']); if (sizeof($doneTests[$infoUser->user['login']]) > 0) { $workSheet =& $workBook->addWorksheet('Tests Info'); $workSheet->setInputEncoding('utf-8'); $workSheet->setColumn(0, 0, 5); $row = 1; $workSheet->write($row, 1, _TESTSINFORMATION, $headerFormat); $workSheet->mergeCells($row, 1, $row, 4); $workSheet->setColumn(1, 4, 25); $row++; $workSheet->write($row, 1, _LESSON, $titleLeftFormat); $workSheet->write($row, 2, _TESTNAME, $titleCenterFormat); $workSheet->write($row, 3, _SCORE, $titleCenterFormat);
/** * Get user message folders * * This function retrieves the folders of the specified user. The folders are returned so that * "Incoming" is the first entry, "Sent" the 2nd, "Drafts" the 3rd and any other folders follow. * The array is on a id/name basis. * <br/>Example: * <code> * $userFolders = eF_PersonalMessage :: getUserFolders('jdoe'); * // Returns something like: array(2 => 'Incoming', 3 => 'Sent', 4 => 'Drafts', 8 => 'My folder'); * </code> * The function creates any missing directories in the user space as well * * @param mixed $user The user to retrieve folders for * @return array The array of folders * @since 3.6.0 * @access public */ public static function getUserFolders($user) { if ($user instanceof EfrontUser) { $user = $user->user['login']; } else { if (!eF_checkParameter($user, 'login')) { throw new EfrontUserException(_INVALIDLOGIN . ": '" . $user . "'", EfrontUserException::INVALID_LOGIN); } } if (!is_dir(G_UPLOADPATH . $user . '/message_attachments/')) { //Check if the messages folder for this user exists on the disk mkdir(G_UPLOADPATH . $user . '/message_attachments/', 0755); } $result = eF_getTableDataFlat("f_folders", "name", "users_LOGIN='******'"); in_array('Incoming', $result['name']) or eF_insertTableData("f_folders", array('name' => 'Incoming', 'users_LOGIN' => $user)); in_array('Sent', $result['name']) or eF_insertTableData("f_folders", array('name' => 'Sent', 'users_LOGIN' => $user)); in_array('Drafts', $result['name']) or eF_insertTableData("f_folders", array('name' => 'Drafts', 'users_LOGIN' => $user)); $folders = $incoming = $sent = $drafts = array(); $result = eF_getTableData("f_folders f left outer join f_personal_messages pm on pm.f_folders_ID=f.id", "f.*, count(pm.id) as messages_num", "f.users_LOGIN='******'", "", "f.id"); foreach ($result as $value) { $value['pathname'] = $value['name']; if (!is_dir(G_UPLOADPATH . $user . '/message_attachments/' . $value['name'])) { //Check whether the folders exist physically on the disk mkdir(G_UPLOADPATH . $user . '/message_attachments/' . $value['name'], 0755); } if ($value['name'] == 'Incoming') { $value['name'] = _INCOMING; $incoming = array($value['id'] => $value); } else { if ($value['name'] == 'Sent') { $value['name'] = _SENT; $sent = array($value['id'] => $value); } else { if ($value['name'] == 'Drafts') { $value['name'] = _DRAFTS; $drafts = array($value['id'] => $value); } else { $folders[$value['id']] = $value; } } } } //Move default folders on top of the list $folders = $incoming + $sent + $drafts + $folders; //Get files statistics foreach ($folders as $key => $folder) { foreach (new RecursiveIteratorIterator(new RecursiveDirectoryIterator(G_UPLOADPATH . $user . '/message_attachments/' . $folder['pathname'])) as $file) { $folders[$key]['size'] = 0; if ($file->isFile()) { $folders[$key]['filesize'] += $file->getSize(); } } $folders[$key]['filesize'] = round($folders[$key]['filesize'] / 1024); } return $folders; }
$from = mktime($_GET['from_hour'], $_GET['from_min'], 0, $_GET['from_month'], $_GET['from_day'], $_GET['from_year']); $to = mktime($_GET['to_hour'], $_GET['to_min'], 0, $_GET['to_month'], $_GET['to_day'], $_GET['to_year']); } else { $from = mktime(date("H"), date("i"), date("s"), date("m"), date("d") - 7, date("Y")); $to = mktime(date("H"), date("i"), date("s"), date("m"), date("d"), date("Y")); } $smarty->assign('T_FROM_TIMESTAMP', $from); $smarty->assign('T_TO_TIMESTAMP', $to); $actions = array('login' => _LOGIN, 'logout' => _LOGOUT, 'lesson' => _ACCESSEDLESSON, 'content' => _ACCESSEDCONTENT, 'tests' => _ACCESSEDTEST, 'test_begin' => _BEGUNTEST, 'lastmove' => _NAVIGATEDSYSTEM); $smarty->assign("T_ACTIONS", $actions); if (isset($_GET['showlog']) && $_GET['showlog'] == "true") { $lessonNames = eF_getTableDataFlat("lessons", "id, name"); $lessonNames = array_combine($lessonNames['id'], $lessonNames['name']); $contentNames = eF_getTableDataFlat("content", "id, name"); $contentNames = array_combine($contentNames['id'], $contentNames['name']); $testNames = eF_getTableDataFlat("tests t, content c", "t.id, c.name", "c.id=t.content_ID"); $testNames = array_combine($testNames['id'], $testNames['name']); $result = eF_getTableData("logs", "*", "timestamp between {$from} and {$to} order by timestamp"); foreach ($result as $key => $value) { $value['lessons_ID'] ? $result[$key]['lesson_name'] = $lessonNames[$value['lessons_ID']] : null; if ($value['action'] == 'content' || $value['action'] == 'tests' || $value['action'] == 'test_begin') { $result[$key]['content_name'] = $contentNames[$value['comments']]; } } $analytic_log = $result; $smarty->assign("T_SYSTEM_LOG", $analytic_log); } $users = array(); $result = eF_getTableData("logs, users", "users.name, users.surname, users.active, users_LOGIN, count(logs.id) as cnt ", "users.login=users_LOGIN and action = 'login' and logs.timestamp between {$from} and {$to} group by users_LOGIN order by count(logs.id) desc"); // $userTimes = EfrontUser :: getLoginTime(false, array('from' => $from, 'to' => $to)); $timesReport = new EfrontTimes(array($from, $to));
if ($GLOBALS['configuration']['lessons_directory'] == 1 && in_array('lessons', array_merge($positions['leftList'], $positions['rightList'], $positions['centerList']))) { if (isset($_SESSION['s_current_branch'])) { $branch = new EfrontBranch($_SESSION['s_current_branch']); $constraints = array('active' => true, 'archive' => false, 'instance' => false, 'sort' => 'name'); $courses = $branch->getBranchCoursesIncludingParentBranches($constraints); $lessons = array(); } $directionsTree = new EfrontDirectionsTree(); $options = array('lessons_link' => basename($_SERVER['PHP_SELF']) . '?ctg=lesson_info&lessons_ID=', 'courses_link' => basename($_SERVER['PHP_SELF']) . '?ctg=lesson_info&courses_ID=', 'search' => true, 'catalog' => true, 'url' => $_SERVER['PHP_SELF'], 'collapse' => $GLOBALS['configuration']['collapse_catalog'], 'buy_link' => true, 'course_lessons' => false); include "directions_tree.php"; } } /* -------------------------------------------------------Login part-------------------------------------------------------------------*/ if (isset($_GET['autologin']) && eF_checkParameter($_GET['autologin'], 'hex')) { try { $result = eF_getTableDataFlat("users", "login,autologin,password,user_type", "active=1 and autologin !=''"); $autolinks = $result['autologin']; $key = array_search($_GET['autologin'], $autolinks); if ($key !== false) { $user = EfrontUserFactory::factory($result['login'][$key]); //$pattern = $user -> user['login']."_".$user -> user['timestamp']; //$pattern = md5($pattern.G_MD5KEY); //if (strcmp($pattern, $_GET['autologin']) == 0) { $user->login($user->user['password'], true); if (isset($_GET['lessons_ID']) && eF_checkParameter($_GET['lessons_ID'], 'id')) { //check for valid lesson setcookie('c_request', $user->user['user_type'] . '.php?lessons_ID=' . $_GET['lessons_ID'], time() + 86400, false, false, false, true); } if (isset($_GET['view_unit']) && eF_checkParameter($_GET['view_unit'], 'id')) { //check for valid lesson setcookie('c_request', $user->user['user_type'] . '.php?view_unit=' . $_GET['view_unit'], time() + 86400, false, false, false, true);
if ($course->course['completed']) { $coursesScores[] = $course->course['score']; $coursesCEUS[] = $course->course['ceu']; } else { unset($userCourses[$key]['ceu']); } } $smarty->assign("T_USER_COURSES", $userCourses); $userLessons = $editedUser->getUserStatusInLessons(); foreach ($userLessons as $key => $value) { if (!in_array($value->lesson['user_type'], array_keys($studentRoles))) { unset($userLessons[$key]); } } $result = EfrontStats::getStudentsDoneTests($userLessons, $editedUser->user['login']); $feedbacks = eF_getTableDataFlat("tests t, content c", "t.id, t.content_ID", "c.id=t.content_ID and c.ctg_type='feedback'"); $labels = array('completed' => _COMPLETED, 'passed' => _PASSED, 'failed' => _FAILED, 'incomplete' => _PENDING); foreach ($result[$editedUser->user['login']] as $contentId => $value) { if (!in_array($contentId, $feedbacks['content_ID'])) { $value['status'] = $labels[$value['status']]; $userDoneTests[$value['lessons_ID']][] = $value; } } $smarty->assign("T_USER_TESTS", $userDoneTests); foreach ($userLessons as $key => $lesson) { if ($lesson->lesson['course_only']) { foreach ($courseLessons as $courseId => $foo) { if (isset($courseLessons[$courseId][$key])) { $courseLessons[$courseId][$key] = $lesson->lesson; } elseif ($foo->lesson) { $courseLessons[$courseId][$key] = $foo->lesson;
/** * * @param $fields * @return unknown_type */ public static function create($fields = array()) { if (is_file(G_THEMESPATH . $fields['path'] . 'images/logo.png')) { $fields['options']['logo'] = $fields['path'] . 'images/logo.png'; } if (is_file(G_THEMESPATH . $fields['path'] . 'images/favicon.png')) { $fields['options']['favicon'] = $fields['path'] . 'images/favicon.png'; } $fields = self::validateFields($fields); $result = eF_getTableDataFlat("themes", "name"); if (!in_array($fields['name'], $result['name'])) { $id = eF_insertTableData("themes", $fields); } else { $idx = array_search($fields['name'], $result['name']); $id = $result['name'][$idx]; } EfrontCache::getInstance()->deleteCache('themes'); $newTheme = new themes($id); return $newTheme; }
/** * Add users to group * * This function is used to add users to the current group * <br>Example: * <code> * $group = new EfrontGroup(2); * $group -> addUsers(array('jdoe', 'doej')); * </code> * * @param mixed $users An array of user logins or EfrontUser objects, or a single login or EfrontUser object * @return boolean True if everything is ok * @since 3.5.2 * @access public */ public function addUsers($users, $userTypeInCourses = 'student') { if (empty($users)) { return true; } $users = EfrontUser::verifyUsersList($users); $groupUsers = eF_getTableDataFlat("users_to_groups", "users_LOGIN", "groups_ID=" . $this->group['id']); $errors = array(); foreach ($users as $key => $user) { if (!in_array($user, $groupUsers['users_LOGIN'], true)) { $fields[] = array('groups_ID' => $this->group['id'], 'users_LOGIN' => $user); } } eF_insertTableDataMultiple("users_to_groups", $fields); foreach ($fields as $utg) { EfrontEvent::triggerEvent(array("type" => EfrontEvent::NEW_ASSIGNMENT_TO_GROUP, "users_LOGIN" => $utg['users_LOGIN'], "entity_ID" => $this->group['id'], "entity_name" => $this->group['name'])); } foreach ($this->getCourses(true, true) as $course) { try { $course->addUsers($users, $userTypeInCourses, 1); } catch (Exception $e) { if ($e->getCode() == EfrontCourseException::MAX_USERS_LIMIT) { $max_users_errors[] = $e->getMessage(); } else { $errors[] = $e->getMessage(); } } } foreach ($this->getLessons(true, true) as $lesson) { try { $lesson->addUsers($users, $userTypeInCourses, 1); } catch (Exception $e) { if ($e->getCode() == EfrontCourseException::MAX_USERS_LIMIT) { $max_users_errors[] = $e->getMessage(); } else { $errors[] = $e->getMessage(); } } } if (!empty($errors)) { throw new EfrontGroupException(implode("<br>", $errors), EfrontGroupException::ASSIGNMENT_ERROR); } if (!empty($max_users_errors)) { return $max_users_errors; } return true; }
if (!empty($branches)) { $stats_filters[] = array("table" => "module_hcd_employee_works_at_branch as filter_eb", "joinField" => "filter_eb.users_LOGIN", "condition" => "(filter_eb.branch_ID in (" . implode(",", $branches) . ") AND filter_eb.assigned = 1)"); } else { $stats_filters[] = array("table" => "module_hcd_employee_works_at_branch as filter_eb", "joinField" => "filter_eb.users_LOGIN", "condition" => "(filter_eb.branch_ID != '' AND filter_eb.assigned = 1)"); } } } } if (isset($_GET['job_filter']) && $_GET['job_filter'] != 0) { $jobs_array = explode(",", $_GET['job_filter']); $flag = 1; foreach ($jobs_array as $value) { $flag = $flag && eF_checkParameter($value, 'id'); } if ($flag) { $result = eF_getTableDataFlat("module_hcd_job_description", "job_description_ID,branch_ID", " description IN (SELECT description FROM module_hcd_job_description WHERE job_description_ID IN (" . implode(",", $jobs_array) . "))"); $jobs_array = $result['job_description_ID']; $stats_filters[] = array("table" => "module_hcd_employee_has_job_description as filter_ej", "joinField" => "filter_ej.users_login", "condition" => "(filter_ej.job_description_ID in (" . implode(",", $jobs_array) . "))"); } } } #cpp#endif if (!isset($_GET['ajax'])) { if ($_SESSION['s_type'] == 'administrator') { //supervisors don't see groups $groups = EfrontGroup::getGroups(); $smarty->assign("T_GROUPS", $groups); } else { $groups = $currentUser->getGroups(); // Changed for 3.6.15 to show only professor's groups $smarty->assign("T_GROUPS", $groups);
private function getRssSource($source, $mode, $lesson) { $feeds = $this->getProvidedFeeds(); foreach ($feeds as $value) { if ($value['active'] && $value['mode'] == 'system') { $systemFeeds[$value['type']] = $value; } else { if ($value['active'] && $value['mode'] == 'lesson') { $lessonFeeds[$value['type']] = $value; } } } if ($mode == 'system' && !in_array($source, array_keys($systemFeeds))) { return array(); } elseif ($mode == 'lesson' && !in_array($source, array_keys($lessonFeeds))) { return array(); } $data = array(); switch ($source) { case 'announcements': if ($mode == 'system') { $news = news::getNews(0, true); } elseif ($mode == 'lesson') { if ($lesson) { $news = news::getNews($lesson, true); } else { $lessons = eF_getTableDataFlat("lessons", "id, name"); $lessonNames = array_combine($lessons['id'], $lessons['name']); $news = news::getNews($lessons['id'], true); } } $count = 1; foreach ($news as $value) { if ($mode == 'lesson' && !$lesson) { $value['title'] = $lessonNames[$value['lessons_ID']] . ': ' . $value['title']; $link = G_SERVERNAME . 'userpage.php?lessons_ID=' . $value['lessons_ID'] . '&ctg=news&view=' . $value['id']; } else { $link = G_SERVERNAME . 'userpage.php?ctg=news&view=' . $value['id']; } $data[] = array('title' => $value['title'], 'link' => $link, 'description' => $value['data']); /* if ($count++ == $this -> feedLimit) { break; } */ } break; case 'catalog': $constraints = array("return_objects" => false, 'archive' => false, 'active' => true); $result = EfrontCourse::getAllCourses($constraints); $directionsTree = new EfrontDirectionsTree(); $directionPaths = $directionsTree->toPathString(); foreach ($result as $value) { $pathString = $directionPaths[$value['directions_ID']] . ' → ' . $value['name']; $data[] = array('title' => $pathString, 'link' => G_SERVERNAME . 'index.php?ctg=lesson_info&courses_ID=' . $value['id'], 'description' => implode("<br>", unserialize($value['info']))); } $result = eF_getTableData("lessons", "id,name,directions_ID, info", "archive=0 and instance_source = 0 and active=1 and course_only=0", "name"); foreach ($result as $value) { $pathString = $directionPaths[$value['directions_ID']] . ' → ' . $value['name']; $data[] = array('title' => $pathString, 'link' => G_SERVERNAME . 'index.php?ctg=lesson_info&lessons_ID=' . $value['id'], 'description' => implode("<br>", unserialize($value['info']))); } $data = array_values(eF_multisort($data, 'title', 'asc')); //Sort results based on path string break; case 'calendar': if ($mode == 'system') { $events = calendar::getGlobalCalendarEvents(); } elseif ($mode == 'lesson') { if ($lesson) { $events = calendar::getLessonCalendarEvents($lesson); } else { $events = calendar::getCalendarEventsForAllLessons(); } } foreach ($events as $value) { $value['name'] ? $title = formatTimestamp($value['timestamp']) . ' (' . $value['name'] . ')' : ($title = formatTimestamp($value['timestamp'])); $data[] = array('title' => $title, 'link' => G_SERVERNAME . 'userpage.php?ctg=calendar&view_calendar=' . $value['timestamp'] . '&type=0', 'description' => $value['data']); } break; /* case 'history': $currentUser = $this -> getCurrentUser(); $eventObjects = array(); $result = eF_getTableData("events", "*", "", "timestamp DESC limit 100"); foreach ($result as $value) { $eventObject = new EfrontEvent($value); $eventObject -> createMessage(); pr($eventObject); } break; */ /* case 'history': $currentUser = $this -> getCurrentUser(); $eventObjects = array(); $result = eF_getTableData("events", "*", "", "timestamp DESC limit 100"); foreach ($result as $value) { $eventObject = new EfrontEvent($value); $eventObject -> createMessage(); pr($eventObject); } break; */ case 'structure': if ($lesson) { $contentTree = new EfrontContentTree($lesson); $contentPath = $contentTree->toPathStrings(); foreach ($contentPath as $key => $value) { $data[] = array('title' => $value, 'link' => G_SERVERNAME . 'userpage.php?lessons_ID=' . $lesson . '&unit=' . $key, 'description' => $value); } } break; case 'forum': if ($mode == 'system') { $result = eF_getTableData("f_messages fm JOIN f_topics ft JOIN f_forums ff LEFT OUTER JOIN lessons l ON ff.lessons_ID = l.id", "ff.title as forum_name, fm.body, fm.title, fm.id, ft.id as topic_id, ft.title as topic_title, fm.users_LOGIN, fm.timestamp, l.name as lessons_name, lessons_id as show_lessons_id", "ft.f_forums_ID=ff.id AND fm.f_topics_ID=ft.id ", "fm.timestamp desc LIMIT 100"); } elseif ($mode == 'lesson') { if ($lesson) { $result = eF_getTableData("f_messages fm JOIN f_topics ft JOIN f_forums ff LEFT OUTER JOIN lessons l ON ff.lessons_ID = l.id", "ff.title as forum_name, fm.body, fm.title, fm.id, ft.id as topic_id, ft.title as topic_title, fm.users_LOGIN, fm.timestamp, l.name as lessons_name, lessons_id as show_lessons_id", "ft.f_forums_ID=ff.id AND fm.f_topics_ID=ft.id AND ff.lessons_ID = '" . $lesson . "'", "fm.timestamp desc LIMIT 100"); } else { $result = eF_getTableData("f_messages fm JOIN f_topics ft JOIN f_forums ff LEFT OUTER JOIN lessons l ON ff.lessons_ID = l.id", "ff.title as forum_name, fm.body, fm.title, fm.id, ft.id as topic_id, ft.title as topic_title, fm.users_LOGIN, fm.timestamp, l.name as lessons_name, lessons_id as show_lessons_id", "ft.f_forums_ID=ff.id AND fm.f_topics_ID=ft.id AND ff.lessons_ID != 0", "fm.timestamp desc LIMIT 100"); } } foreach ($result as $value) { $value['title'] = $value['forum_name'] . ' >> ' . $value['topic_title'] . ' >> ' . $value['title']; if ($mode == 'system' && $value['lessons_name'] || $mode == 'lesson' && !$lesson) { $value['title'] = $value['lessons_name'] . ': ' . $value['title']; } $data[] = array('title' => $value['title'], 'link' => G_SERVERNAME . 'userpage.php?ctg=forum&topic=' . $value['topic_id'], 'description' => $value['body']); } break; default: break; } return $data; }