function getRefresh_rate() { $rate = eF_getTableData("module_chat_config", "refresh_rate", "1"); foreach ($rate as $r) { echo $r['refresh_rate']; } }
function getLessonFromId() { if (eF_checkParameter($_GET['loglessonid'], 'id')) { $id = $_GET["loglessonid"]; $result = eF_getTableData('lessons', 'id, name', "id='" . $id . "'"); echo json_encode(array('name' => $result[0]['name'], 'id' => $result[0]['id'])); } }
/** * * @param $param * @return unknown_type */ public function __construct($param) { //Special handling in case we are instantiating with string (name) instead of id if (!eF_checkParameter($param, 'id') && eF_checkParameter($param, 'alnum_general')) { $result = eF_getTableData("themes", "id", "name='" . $param . "'"); if (sizeof($result) == 0) { throw new EfrontEntityException(_ENTITYNOTFOUND . ': ' . htmlspecialchars($param), EfrontEntityException::ENTITY_NOT_EXIST); } $param = $result[0]['id']; } parent::__construct($param); if (strpos($this->{$this->entity}['path'], 'http') === 0) { $this->remote = 1; } /* //Check whether this is a remote theme if (!is_dir($this -> {$this -> entity}['path']) && !is_file($this -> {$this -> entity}['path'])) { if (!fopen($this -> {$this -> entity}['path'].'theme.xml', 'r')) { throw new EfrontEntityException(_ENTITYNOTFOUND.': '.htmlspecialchars($this -> {$this -> entity}['path']), EfrontEntityException :: ENTITY_NOT_EXIST); } else { $this -> remote = 1; } } */ if (unserialize($this->{$this->entity}['options']) !== false) { $this->options = unserialize($this->{$this->entity}['options']); } if (!$this->options) { $this->options = array(); } if (unserialize($this->{$this->entity}['layout']) !== false) { $this->layout = unserialize($this->{$this->entity}['layout']); } if (!$this->layout) { $this->layout = array(); } //Check validity of current logo try { if (isset($this->options['logo'])) { new EfrontFile($this->options['logo']); } else { throw new Exception(); } } catch (Exception $e) { $this->options['logo'] = false; } //Check validity of current favicon try { if (isset($this->options['favicon'])) { new EfrontFile($this->options['favicon']); } else { throw new Exception(); } } catch (Exception $e) { $this->options['favicon'] = false; } }
function getConnectedUsers() { $usersOnline = array(); //A user may have multiple active entries on the user_times table, one for system, one for unit etc. Pick the most recent $result = eF_getTableData("user_times,users,module_chat_users", "users_LOGIN, users.name, users.surname, users.user_type, timestamp_now, session_timestamp", "users.login=user_times.users_LOGIN and users.login=module_chat_users.username and session_expired=0", "timestamp_now desc"); foreach ($result as $value) { if (!isset($parsedUsers[$value['users_LOGIN']])) { $value['login'] = $value['users_LOGIN']; $usersOnline[] = array('login' => $value['users_LOGIN'], 'formattedLogin' => formatLogin($value['login'], $value), 'user_type' => $value['user_type'], 'timestamp_now' => $value['timestamp_now'], 'time' => eF_convertIntervalToTime(time() - $value['session_timestamp'])); $parsedUsers[$value['users_LOGIN']] = true; } } return $usersOnline; }
$groups[$key]['partof'] = 1; } else { if ((!$group['active'] || !$_change_groups_) && !($_self_groups_ && $group['self_enroll'])) { unset($groups[$key]); } } } $dataSource = $groups; $tableName = 'groupsTable'; include "sorted_table.php"; } } catch (Exception $e) { handleAjaxExceptions($e); } if (isset($_GET['postAjaxRequest']) && ($_change_groups_ || $_self_groups_)) { $result = eF_getTableData("groups", "*", "active=1"); $groups = array(); foreach ($result as $key => $value) { if ($value['active'] && ($_change_groups_ || $_self_groups_ && $value['self_enroll'])) { $groups[$value['id']] = $value; } } try { if ($_GET['insert'] == "true" && in_array($_GET['add_group'], array_keys($groups))) { $editedUser->addGroups($_GET['add_group']); } else { if ($_GET['insert'] == "false" && in_array($_GET['add_group'], array_keys($groups))) { $editedUser->removeGroups($_GET['add_group']); } else { if (isset($_GET['addAll'])) { isset($_GET['filter']) ? $groups = eF_filterData($groups, $_GET['filter']) : null;
} $smarty->assign("T_TABLE_OPTIONS", $options); $currentContent = new EfrontContentTree($currentLesson); if ($_GET['scorm_review']) { $iterator = new EfrontSCORMFilterIterator(new EfrontNodeFilterIterator(new RecursiveIteratorIterator(new RecursiveArrayIterator($currentContent->tree), RecursiveIteratorIterator::SELF_FIRST))); foreach ($iterator as $key => $value) { $scormContentIds[] = $key; } if (sizeof($scormContentIds)) { $result = eF_getTableData("scorm_data, content, users", "scorm_data.*, content.name as content_name, users.name, users.surname", "scorm_data.users_LOGIN != '' and scorm_data.content_ID IN (" . implode(",", $scormContentIds) . ") and content_ID=content.id and users.login=scorm_data.users_LOGIN"); $result2004 = array(); if (G_VERSIONTYPE != 'community') { #cpp#ifndef COMMUNITY if (G_VERSIONTYPE != 'standard') { #cpp#ifndef STANDARD $result2004 = eF_getTableData("scorm_data_2004, content, users", "scorm_data_2004.*, content.name as content_name, users.name, users.surname", "scorm_data_2004.users_LOGIN != '' and scorm_data_2004.content_ID IN (" . implode(",", $scormContentIds) . ") and content_ID=content.id and users.login=scorm_data_2004.users_LOGIN"); } #cpp#endif } #cpp#endif $scormData = array_merge($result, $result2004); } else { $scormData = array(); } foreach ($result as $value) { //$scormData[$value['users_LOGIN']] = $value; } //$smarty -> assign("T_SCORM_DATA", $scormData); if (isset($_GET['ajax']) && $_GET['ajax'] == 'scormUsersTable') { isset($_GET['limit']) && eF_checkParameter($_GET['limit'], 'uint') ? $limit = $_GET['limit'] : ($limit = G_DEFAULT_TABLE_SIZE); if (isset($_GET['sort']) && eF_checkParameter($_GET['sort'], 'text')) {
$skills_missing = array(); $all_skills = ""; foreach ($_GET as $key => $value) { // all skill-related posted values are just the skill_ID ~ a uint value if (eF_checkParameter($key, 'unit')) { if ($value == 1) { $skills_missing[] = $key; } } } // We found all the skills missing $skills_missing = implode("','", $skills_missing); // We have all the already attended courses $alredy_attending = implode("','", array_keys($editedUser->getLessons())); // Thus we can find the missing courses to fill the skill gap $lessons_proposed = 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 JOIN lessons ON lessons.id = module_hcd_lesson_offers_skill.lesson_ID", "module_hcd_lesson_offers_skill.lesson_ID, lessons.*, 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 ('" . $alredy_attending . "')", "", "module_hcd_lesson_offers_skill.lesson_ID ORDER BY skills_offered DESC"); // And assign them foreach ($lessons_proposed as $lesson) { $editedUser->addLessons($lesson['lesson_ID']); } } } } } } exit; } } if (isset($_GET['ajax']) && $_GET['ajax'] == 'toggle_user' && $_GET['type'] == 'lesson' && $_change_lessons_) { $response = array('status' => 1); $editLesson = new EfrontLesson($_GET['id']);
} $currentContent->seekNode($value)->activate(); } catch (Exception $e) { $errorMessages[] = $e->getMessage() . ' ' . $e->getCode(); } } } } if (isset($_POST['deactivate_nodes']) && $_POST['deactivate_nodes']) { foreach ($_POST['deactivate_nodes'] as $value) { if (in_array($value, $legalValues) && eF_checkParameter($value, 'id')) { try { // Deactivate also linked units $linked_units = eF_getTableData('content', 'id', 'linked_to=' . $value); foreach ($linked_units as $unit) { $lessons_IDs = eF_getTableData('content', 'lessons_ID', 'id=' . $unit['id']); foreach ($lessons_IDs as $lessons_ID) { $lessonsContent = new EfrontContentTree($lessons_ID['lessons_ID']); $lessonsContent->seekNode($unit['id'])->deactivate(); } } $currentContent->seekNode($value)->deactivate(); } catch (Exception $e) { $errorMessages[] = $e->getMessage() . ' ' . $e->getCode(); } } } } if (isset($_POST['node_orders']) && $_POST['node_orders']) { //$nodeOrders = explode(",", $_POST['node_orders']); $previousContentId = 0;
} catch (Exception $e) { $smarty->assign("T_EXCEPTION_TRACE", $e->getTraceAsString()); $message = $e->getMessage() . ' <a href = "javascript:void(0)" onclick = "eF_js_showDivPopup(event, \'' . _ERRORDETAILS . '\', 2, \'error_details\')">' . _MOREINFO . '</a>'; $message_type = failure; } } else { $smarty->assign("T_CART", cart::prepareCart()); } if (isset($_SESSION['s_login']) && ($GLOBALS['currentTheme']->options['sidebar_interface'] == 2 && $GLOBALS['currentTheme']->options['show_header'] == 2)) { try { //$currentUser = EfrontUserFactory :: factory($_SESSION['s_login']); $currentUser = EfrontUser::checkUserAccess(); refreshLogin(); //$_SESSION['last_action_timestamp'] = time(); //Keep the last time something happened to the session if ($accounts = unserialize($currentUser->user['additional_accounts'])) { $result = eF_getTableData("users", "login, user_type", 'login in ("' . implode('","', array_values($accounts)) . '")'); $smarty->assign("T_MAPPED_ACCOUNTS", $result); } } catch (Exception $e) { } } if (isset($_GET['ctg']) && is_numeric($_GET['ctg'])) { //cheking a possible issue with search engine robots that overloads server if (empty($customBlocks) || in_array($_GET['ctg'], array_keys($customBlocks)) !== true) { eF_redirect("HTTP/1.0 404 Not Found"); } } if (isset($_SESSION['s_login']) && $_SESSION['s_login']) { //This way, logged in users that stay on index.php are not logged out $loadScripts[] = 'sidebar'; }
function eF_local_printBranchJobs($branch) { $result = $branch->getJobDescriptions(); $branchJobs = array("--- {$branch->branch['name']} ---"); foreach ($result as $value) { $branchJobs[$value['description']] = $value['description']; } $branchJobs['#empty#'] = "--- " . _OTHERBRANCHJOBS . " ---"; $result = eF_getTableData("module_hcd_job_description", "distinct description"); foreach ($result as $value) { $branchJobs[$value['description']] = $value['description']; } return $branchJobs; }
$smarty->assign("T_LAYOUT_CLASS", "centerFull hideLeft"); } else { $smarty->assign("T_LAYOUT_CLASS", $currentTheme->options['toolbar_position'] == "left" ? "hideRight" : "hideLeft"); //Whether to show the sidemenu on the left or on the right } if (!$currentLesson->options['show_horizontal_bar'] && $_student_ || $_COOKIE['horizontalSideBar'] == 'hidden') { $smarty->assign("T_HEADER_CLASS", "headerHidden"); } else { $smarty->assign("T_HEADER_CLASS", "header"); //$currentTheme -> options['toolbar_position'] == "left" ? "hideRight" : "hideLeft"); //Whether to show the sidemenu on the left or on the right } if (isset($currentUnit['options']['maximize_viewport']) && $currentUnit['options']['maximize_viewport'] && $currentUser->getType($currentLesson) == "student") { $smarty->assign("T_MAXIMIZE_VIEWPORT", 1); } if (isset($currentUnit['options']['scorm_times']) && $currentUnit['options']['scorm_times']) { $result = eF_getTableData("users_to_content", "visits", "content_ID={$unit['id']} AND lessons_ID={$currentLesson->lesson['id']} AND users_LOGIN='******'login']}'"); $remaining_times = $currentUnit['options']['scorm_times'] - $result[0]['visits']; $remaining_times > 0 or $remaining_times = 0; $smarty->assign("T_SCORM_TIMES_REMAINING", $remaining_times); } if (isset($currentUnit['options']['scorm_asynchronous']) && $currentUnit['options']['scorm_asynchronous']) { $smarty->assign("T_SCORM_ASYNCHRONOUS", 1); } else { $smarty->assign("T_SCORM_ASYNCHRONOUS", 0); } if (isset($currentUnit['options']['object_ids']) && $currentUnit['options']['object_ids']) { $smarty->assign("T_OBJECT_IDS", $currentUnit['options']['object_ids']); } $content_side_modules = array(); foreach ($loadedModules as $module) { if (isset($currentLesson->options[$module->className]) && $currentLesson->options[$module->className] == 1) {
$result = eF_getTableData("users_to_content", "visits, attempt_identifier", "content_ID={$unit['id']} and users_LOGIN='******'login']}'"); if (!empty($result)) { // vd($_SESSION['attempt_identifier']); // vd($result[0]['attempt_identifier']); $visits = $result[0]['visits']; if ($_SESSION['attempt_identifier'] != $result[0]['attempt_identifier']) { eF_updateTableData("users_to_content", array("visits" => $result[0]['visits'] + 1, "attempt_identifier" => $_SESSION['attempt_identifier']), "content_ID={$unit['id']} and users_LOGIN='******'login']}'"); $visits = $result[0]['visits'] + 1; } } else { eF_insertTableData("users_to_content", array("attempt_identifier" => $_SESSION['attempt_identifier'], "visits" => 1, "content_ID" => $unit['id'], "lessons_ID" => $unit['lessons_ID'], "users_LOGIN" => $scoUser->user['login'])); $visits = 1; } $remaining_times = $unit['options']['scorm_times'] - $visits; } } $newUserProgress = EfrontStats::getUsersLessonStatus($scoLesson, $scoUser->user['login']); $newPercentage = $newUserProgress[$scoLesson->lesson['id']][$scoUser->user['login']]['overall_progress']; $newConditionsPassed = $newUserProgress[$scoLesson->lesson['id']][$scoUser->user['login']]['conditions_passed']; $newLessonPassed = $newUserProgress[$scoLesson->lesson['id']][$scoUser->user['login']]['lesson_passed']; if ($scoLesson->lesson['course_only'] && $_SESSION['s_courses_ID']) { $res = eF_getTableData("users_to_courses", "issued_certificate", "courses_ID=" . $_SESSION['s_courses_ID'] . " and users_LOGIN='******'s_login'] . "'"); if ($res[0]['issued_certificate'] != "") { $courseCertified = true; } } echo json_encode(array($newPercentage, $newConditionsPassed, $newLessonPassed, $scormState, $redirectTo, $trackActivityInfo, $courseCertified, $remaining_times)); } catch (Exception $e) { echo json_encode(array('error' => $e->getMessage())); } exit;
private function toggleSetting($setting, $enable) { $result = eF_getTableData("lessons", "id, options"); foreach ($result as $value) { $options = unserialize($value['options']); $enable ? $options[$setting] = 1 : ($options[$setting] = 0); eF_updateTableData("lessons", array("options" => serialize($options)), "id=" . $value['id']); } }
$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}"); $parent_forum = $result[0]['parent_id']; $parents[$result[0]['id']] = $result[0]['title']; $firstNode = $result[0]['lessons_ID']; } //echo $firstNode; $smarty->assign("T_FIRSTNODE", $firstNode); //pr($parents); $smarty->assign("T_FORUM_PARENTS", array_reverse($parents, true)); $dataSource = $topics; $tableName = 'topicsTable'; include "sorted_table.php"; } } } }
} } $smarty->assign("T_MODULES", $modulesList); $upload_form = new HTML_QuickForm("upload_file_form", "post", basename($_SERVER['PHP_SELF']) . '?ctg=modules', "", null, true); $upload_form->registerRule('checkParameter', 'callback', 'eF_checkParameter'); //Register this rule for checking user input with our function, eF_checkParameter $upload_form->addElement('file', 'file_upload[0]', null, 'class = "inputText"'); $upload_form->addElement('checkbox', 'overwrite', _OVERWRITEIFFOLDEREXISTS); $upload_form->setMaxFileSize(FileSystemTree::getUploadMaxSize() * 1024); //getUploadMaxSize returns size in KB $upload_form->addElement('submit', 'submit_upload_file', _UPLOAD, 'class = "flatButton"'); if ($upload_form->isSubmitted() && $upload_form->validate()) { $filesystem = new FileSystemTree(G_MODULESPATH); $uploadedFile = $filesystem->uploadFile('file_upload', G_MODULESPATH, 0); if (isset($_GET['upgrade'])) { $prev_module_version = eF_getTableData("modules", "position", "className = '" . $_GET['upgrade'] . "'"); $prev_module_folder = $prev_module_version[0]['position']; // The name of the temp folder to extract the new version of the module $module_folder = $prev_module_folder; //basename($filename[0], '.zip') . time(); $module_position = $prev_module_folder; //basename($filename[0], '.zip'); } else { $module_folder = basename($uploadedFile['path'], '.zip'); $module_position = $module_folder; } if (is_dir(G_MODULESPATH . $module_folder) && !isset($_GET['upgrade']) && !isset($_POST['overwrite'])) { $message = _FOLDERWITHMODULENAMEEXISTSIN . G_MODULESPATH; $message_type = 'failure'; } else { $zip = new ZipArchive();
exit; } */ } catch (Exception $e) { handleNormalFlowExceptions($e); } try { if (isset($_GET['ajax']) && isset($_GET['reset_user'])) { $user = EfrontUserFactory::factory($_GET['reset_user']); $user->resetProgressInLesson($editLesson); exit; } if (isset($_GET['postAjaxRequest'])) { if (isset($_GET['login']) && eF_checkParameter($_GET['login'], 'login')) { isset($_GET['user_type']) && in_array($_GET['user_type'], array_keys($roles)) ? $userType = $_GET['user_type'] : ($userType = 'student'); $result = eF_getTableData("users_to_lessons", "users_LOGIN, user_type", "archive = 0 and users_LOGIN='******'login']}' and lessons_ID={$editLesson->lesson['id']}"); if (sizeof($result) == 0) { $editLesson->addUsers($_GET['login'], $userType); } else { $userType != $result[0]['user_type'] ? $editLesson->setRoles($_GET['login'], $userType) : $editLesson->archiveLessonUsers($_GET['login']); } } else { if (isset($_GET['addAll'])) { $constraints = array('archive' => false, 'active' => true, 'condition' => 'r.lessons_ID is null', 'return_objects' => false); $users = $editLesson->getLessonUsersIncludingUnassigned($constraints); isset($_GET['filter']) ? $users = eF_filterData($users, $_GET['filter']) : null; $userTypes = array(); foreach ($users as $user) { $user['user_types_ID'] ? $userTypes[] = $user['user_types_ID'] : ($userTypes[] = $user['user_type']); } $editLesson->addUsers($users, $userTypes);
/** * 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)); } } } } } } } }
/** * Create lesson instance * * This function is used to create a lesson instance. * <br/>Example: * <code> * $instance = EfrontLesson :: createInstance(43); * </code> * * @param mixed $instanceSource Either a lesson id or an EfrontLesson object. * @return EfrontLesson The new lesson instance * @since 3.6.1 * @access public * @static */ public static function createInstance($instanceSource, $originateCourse) { if (!$instanceSource instanceof EfrontLesson) { $instanceSource = new EfrontLesson($instanceSource); } if (!$originateCourse instanceof EfrontCourse) { $originateCourse = new EfrontCourse($originateCourse); } $result = eF_getTableData("lessons", "*", "id=" . $instanceSource->lesson['id']); unset($result[0]['id']); //unset($result[0]['directions_ID']); //Instances don't belong to a category if (!$result[0]['share_folder']) { $result[0]['share_folder'] = $instanceSource->lesson['id']; } //$result[0]['name'] .= ' ('._INSTANCE.')'; $result[0]['originating_course'] = $originateCourse->course['id']; $result[0]['instance_source'] = $instanceSource->lesson['id']; $file = $instanceSource->export(false, true, false); $instance = EfrontLesson::createLesson($result[0]); $instance->import($file, true, true, true); $instance->course['originating_course'] = $originateCourse->course['id']; $instance->course['instance_source'] = $instanceSource->lesson['id']; $instance->persist(); $modules = eF_loadAllModules(); foreach ($modules as $module) { $module->onCreateInstance($instance->lesson['id'], $instanceSource->lesson['id']); } return $instance; }
if ($_POST['dashboard']) { eF_updateTableData("users", array('dashboard_positions' => $positions), "login='******'login'] . "'"); } else { if ($currentUser->user['user_type'] == 'administrator' && !isset($_POST['lessons_ID'])) { EfrontConfiguration::setValue($currentUser->user['login'] . "_positions", $positions); } else { if (isset($_POST['set_default']) && ($currentUser->user['user_type'] == 'administrator' || $roles[$currentLesson->getRole($currentUser->user['login'])] == 'professor')) { $currentLesson->setOptions(array("default_positions" => $positions)); $positions = serialize(array('first' => array_unique($firstlist), 'second' => array_unique($secondlist), 'visibility' => $visibility, 'update' => true)); $lessonStudents = $currentLesson->getUsers('student'); if (sizeof($lessonStudents) > 0) { $users = implode("','", array_keys($lessonStudents)); eF_updateTableData("users_to_lessons", array('positions' => $positions), "users_LOGIN in ('" . $users . "') and lessons_ID=" . $currentLesson->lesson['id']); } } else { if (!$visibility) { $result = eF_getTableData("users_to_lessons", "positions", "lessons_ID=" . $currentLesson->lesson['id'] . " AND users_LOGIN='******'login'] . "'"); $result = unserialize($result[0]['positions']); $visibility = $result['visibility']; if (isset($result['visibility'])) { $positions = serialize(array('first' => array_unique($firstlist), 'second' => array_unique($secondlist), 'visibility' => $visibility)); } } eF_updateTableData("users_to_lessons", array('positions' => $positions), "lessons_ID=" . $currentLesson->lesson['id'] . " AND users_LOGIN='******'login'] . "'"); } } } } } catch (Exception $e) { handleAjaxExceptions($e); }
if (!in_array($value, $branchTreeUsers)) { unset($all_related_users[$key]); } } } if (isset($_GET['ajax'])) { $result = eF_getTableData("users", "login, avatar", "login IN ('" . implode("','", $all_related_users) . "')"); $users_avatars = array(); foreach ($result as $avatar) { $users_avatars[$avatar['login']] = $avatar['avatar']; } } $myEvents = EfrontEvent::getEvents($all_related_users, true, 1000); } else { if (isset($_GET['ajax'])) { $result = eF_getTableData("users", "login, avatar"); $users_avatars = array(); foreach ($result as $avatar) { $users_avatars[$avatar['login']] = $avatar['avatar']; } } $myEvents = EfrontEvent::getEventsForAllUsers(true, 1000); } $allModules = eF_loadAllModules(); $eventMessages = array(); foreach ($myEvents as $key => $event) { if ($myEvents[$key]->createMessage($allModules)) { if (strpos($myEvents[$key]->event['time'], "-") === false) { // Added this to prevent events that changed time in the future as project expiration $new_event = array("time" => $myEvents[$key]->event['time'], "message" => $myEvents[$key]->event['message']); if ($myEvents[$key]->event['editlink']) {
if (G_VERSIONTYPE != 'community') { #cpp#ifndef COMMUNITY if ($_SESSION['s_type'] != 'administrator') { $templates = eF_getTableData("certificate_templates", "id, certificate_name, certificate_type", "certificate_type='main' OR id='" . $currentCourse->options['certificate_tpl_id'] . "' OR users_LOGIN='******'currentUser']->user['login'] . "'", "certificate_name"); } else { $templates = eF_getTableData("certificate_templates", "id, certificate_name, certificate_type", "", "certificate_name"); } foreach ($templates as $key => $value) { $userTemplates[$value['id']] = $value['id']; } if (!in_array($_GET['template_id'], $userTemplates)) { $message = urlencode(_CERTIFICATETEMPLATENOACCESS) . "&message_type=failure"; eF_redirect("" . basename($_SERVER['PHP_SELF']) . "?" . $baseUrl . "&op=format_certificate&switch=1&message=" . urlencode($message)); } if ($currentCourse->options['certificate_tpl_id'] == $_GET['template_id']) { $mainTemplate = eF_getTableData("certificate_templates", "id", "certificate_name='" . CERTIFICATES_MAIN_TEMPLATE_NAME . "'"); // XXX $currentCourse->options['certificate_tpl_id'] = $mainTemplate[0]['id']; $currentCourse->persist(); } if (eF_deleteTableData("certificate_templates", "id=" . $_GET['template_id'])) { $message = urlencode(_SUCCESSFULLYDELETECERTIFICATETEMPLATE) . "&message_type=success"; eF_redirect("" . basename($_SERVER['PHP_SELF']) . "?" . $baseUrl . "&op=format_certificate&switch=1&message=" . urlencode($message)); } else { $message = urlencode(_PROBLEMDELETECERTIFICATETEMPLATE) . "&message_type=failure"; eF_redirect("" . basename($_SERVER['PHP_SELF']) . "?" . $baseUrl . "&op=format_certificate&switch=1&message=" . urlencode($message)); } } #cpp#endif } else { if ($_GET['op'] == 'course_rules') {
protected function getData($type) { switch ($type) { case "users": if (G_VERSIONTYPE == 'enterprise') { #cpp#ifdef ENTERPRISE return eF_getTableData("users LEFT JOIN module_hcd_employees ON users.login = module_hcd_employees.users_login", implode(",", $this->types), "users.archive = 0"); } else { #cpp#else return eF_getTableData($type, implode(",", $this->types), "archive = 0"); } #cpp#endif #cpp#endif case "users_to_courses": return eF_getTableData("users_to_courses JOIN courses ON courses.id = users_to_courses.courses_ID", implode(",", $this->types), ""); case "users_to_groups": return eF_getTableData("users_to_groups JOIN groups ON groups.id = users_to_groups.groups_ID", implode(",", $this->types), ""); #cpp#ifdef ENTERPRISE #cpp#ifdef ENTERPRISE case "branches": return eF_getTableData("module_hcd_branch LEFT OUTER JOIN module_hcd_branch as father_branches ON module_hcd_branch.father_branch_ID = father_branches.branch_ID", implode(",", $this->types), ""); case "job_descriptions": return eF_getTableData("module_hcd_job_description JOIN module_hcd_branch ON module_hcd_branch.branch_ID = module_hcd_job_description.branch_ID", implode(",", $this->types), ""); case "skills": return eF_getTableData("module_hcd_skills JOIN module_hcd_skill_categories ON module_hcd_skill_categories.id = module_hcd_skills.categories_ID", implode(",", $this->types), ""); case "users_to_jobs": return eF_getTableData("module_hcd_employee_has_job_description JOIN module_hcd_job_description ON module_hcd_employee_has_job_description.job_description_ID = module_hcd_job_description.job_description_ID JOIN module_hcd_branch ON module_hcd_job_description.branch_ID = module_hcd_branch.branch_ID JOIN module_hcd_employee_works_at_branch ON (module_hcd_job_description.branch_ID = module_hcd_employee_works_at_branch.branch_ID AND module_hcd_employee_works_at_branch.users_login = module_hcd_employee_has_job_description.users_login)", implode(",", $this->types), ""); case "users_to_skills": return eF_getTableData("module_hcd_employee_has_skill JOIN module_hcd_skills ON module_hcd_employee_has_skill.skill_ID = module_hcd_skills.skill_ID", implode(",", $this->types), ""); case "courses_to_branches": return eF_getTableData("module_hcd_course_to_branch as mcb JOIN courses as c ON c.id = mcb.courses_ID JOIN module_hcd_branch as b ON b.branch_ID=mcb.branches_ID", implode(",", $this->types), ""); #cpp#endif return eF_getTableData($type, implode(",", $this->types), "archive = 0"); } }
/** * Construct user object * * This function is used to construct a user object, based on the user type. * Specifically, it creates an EfrontStudent, EfrontProfessor, EfrontAdministrator etc * An optional password verification may take place, if $password is specified * If $user is a login name, the function queries database. Alternatively, it may * use a prepared user array, which is mostly convenient when having to perform * multiple initializations * <br/>Example : * <code> * $user = EfrontUserFactory :: factory('jdoe'); //Use factory function to instantiate user object with login 'jdoe' * $userData = eF_getTableData("users", "*", "login='******'"); * $user = EfrontUserFactory :: factory($userData[0]); //Use factory function to instantiate user object using prepared data * </code> * * @param mixed $user A user login or an array holding user data * @param string $password An optional password to check against * @param string $forceType Force the type to initialize the user, for example for when a professor accesses student.php as student * @return EfrontUser an object of a class extending EfrontUser * @since 3.5.0 * @access public * @static */ public static function factory($user, $password = false, $forceType = false) { if ((is_string($user) || is_numeric($user)) && eF_checkParameter($user, 'login')) { $result = eF_getTableData("users", "*", "login='******'"); if (sizeof($result) == 0) { throw new EfrontUserException(_USERDOESNOTEXIST . ': ' . $user, EfrontUserException::USER_NOT_EXISTS); } else { if ($password !== false && $password != $result[0]['password']) { throw new EfrontUserException(_INVALIDPASSWORDFORUSER . ': ' . $user, EfrontUserException::INVALID_PASSWORD); } } /* if (strcmp($result[0]['login'], $user) !=0){ throw new EfrontUserException(_USERDOESNOTEXIST.': '.$user, EfrontUserException :: USER_NOT_EXISTS); } */ $user = $result[0]; } elseif (!is_array($user)) { throw new EfrontUserException(_INVALIDLOGIN . ': ' . $user, EfrontUserException::INVALID_PARAMETER); } $forceType ? $userType = $forceType : ($userType = $user['user_type']); switch ($userType) { case 'administrator': $factory = new EfrontAdministrator($user, $password); break; case 'professor': $factory = new EfrontProfessor($user, $password); break; case 'student': $factory = new EfrontStudent($user, $password); break; default: throw new EfrontUserException(_INVALIDUSERTYPE . ': "' . $userType . '"', EfrontUserException::INVALID_TYPE); break; } if (G_VERSIONTYPE == 'enterprise') { #cpp#ifdef ENTERPRISE $factory->aspects['hcd'] = EfrontEmployeeFactory::factory($factory); } #cpp#endif return $factory; }
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 'deactivate_user_course': if (isset($_GET['token']) && checkToken($_GET['token'])) { if (isset($_GET['login']) && isset($_GET['course'])) { $update['from_timestamp'] = 0; $courses = eF_getTableData("lessons_to_courses", "lessons_id", "courses_ID=" . $_GET['course']); for ($i = 0; $i < sizeof($courses); $i++) { if (eF_updateTableData("users_to_lessons", $update, "users_LOGIN='******'login'] . "' and lessons_ID=" . $courses[$i]['lessons_id'])) { $cacheKey = "user_lesson_status:lesson:" . $courses[$i]['lessons_id'] . "user:"******"<xml>"; echo "<status>ok</status>"; echo "</xml>"; } else { echo "<xml>"; echo "<status>error</status>"; echo "<message>Incomplete arguments</message>"; echo "</xml>"; }
// Create the branches select require_once $path . "module_hcd_tools.php"; eF_getRights(); $company_branches = eF_getTableData("module_hcd_branch", "branch_ID, name, father_branch_ID", "", "father_branch_ID ASC,branch_ID ASC"); if ($_SESSION['s_type'] != 'administrator' && $currentEmployee->isSupervisor()) { //this applies to supervisors only foreach ($company_branches as $key => $value) { if (!in_array($value['branch_ID'], $allowedBranches)) { unset($company_branches[$key]); } } $company_branches = array_values($company_branches); } $filter_branches = eF_createBranchesTreeSelect($company_branches, 4); $smarty->assign("T_BRANCHES", $filter_branches); $job_descriptions = eF_getTableData("module_hcd_job_description", "description,job_description_ID,branch_ID", "", "description ASC"); if ($_SESSION['s_type'] != 'administrator' && $currentEmployee->isSupervisor()) { //this applies to supervisors only foreach ($job_descriptions as $key => $value) { if (!in_array($value['branch_ID'], $allowedBranches)) { unset($job_descriptions[$key]); } } $job_descriptions = array_values($job_descriptions); } $job_des = array(); foreach ($job_descriptions as $key => $value) { if (empty($job_des[$key])) { $job_des[$value['description']] = $value['job_description_ID']; } }
public static function switchLessonReportingMode($mode) { if ($GLOBALS['configuration']['time_reports'] != $mode && $mode == 1) { //step one: Read all times from the user_times table, per user,lesson and unit $data = $totals = array(); $result = eF_getTableData("user_times", "users_LOGIN, entity_ID, lessons_ID, time", "entity = 'unit'"); foreach ($result as $value) { if (isset($totals[$value['users_LOGIN']][$value['lessons_ID']][$value['entity_ID']])) { $totals[$value['users_LOGIN']][$value['lessons_ID']][$value['entity_ID']] += $value['time']; } else { $totals[$value['users_LOGIN']][$value['lessons_ID']][$value['entity_ID']] = $value['time']; } } //step 2: read all current time entries in the users_to_content table $result = eF_getTableData("users_to_content", "users_LOGIN, content_ID, lessons_ID, total_time"); foreach ($result as $value) { $existing[$value['users_LOGIN']][$value['lessons_ID']][$value['content_ID']] = $value['total_time']; } //step 3: Populate the users_to_content table with the data from the user_times table, or update if a value already exist (overwriting it). foreach ($totals as $user => $lesson) { foreach ($lesson as $lessonId => $content) { foreach ($content as $contentId => $seconds) { if (isset($existing[$user][$lessonId][$contentId])) { eF_updateTableData("users_to_content", array("total_time" => $seconds), "users_LOGIN='******' and content_ID={$contentId} and lessons_ID={$lessonId}"); } else { $data[] = array("users_LOGIN" => $user, "content_ID" => $contentId, "lessons_ID" => $lessonId, "total_time" => $seconds); } } } } eF_insertTableDataMultiple("users_to_content", $data); //step 4: Read the lesson (but not unit) times from the user_times table $data = $totals = array(); $result = eF_getTableData("user_times", "users_LOGIN, entity_ID, time", "entity = 'lesson'"); foreach ($result as $value) { if (isset($totals[$value['users_LOGIN']][$value['entity_ID']])) { $totals[$value['users_LOGIN']][$value['entity_ID']] += $value['time']; } else { $totals[$value['users_LOGIN']][$value['entity_ID']] = $value['time']; } } //step 5: Populate the users_to_content table with the plain lesson times, using null as a contentId foreach ($totals as $user => $lesson) { foreach ($lesson as $lessonId => $seconds) { $data[] = array("users_LOGIN" => $user, "content_ID" => null, "lessons_ID" => $lessonId, "total_time" => $seconds); } } eF_deleteTableData("users_to_content", "content_ID is null or content_ID=0"); //empty previous entries eF_insertTableDataMultiple("users_to_content", $data); } }
/** * Clear duplicate comments * * There are times that the system may end up with duplicate comments, like when * copying content. This function is used to effectively eliminate duplicates. * <br/>Example: * <code> * comments :: clearDuplicates($currentLesson); * </code> * * @param mixed $lesson a lesson id or an EfrontLesson object * @access public * @static * @since 3.6.0 */ public static function clearDuplicates($lesson) { if ($lesson instanceof EfrontLesson) { $lessonId = $lesson->lesson['id']; } elseif (eF_checkParameter($lesson, 'id')) { $lessonId = $lesson; } else { throw new EfrontLessonException(_INVALIDID . ": {$lesson}", EfrontLessonException::INVALID_ID); } $result = eF_getTableData("comments", "*", "lessons_ID=" . $lessonId, "id"); foreach ($result as $value) { $commentsTerms[$value['id']] = $value; $id = $value['id']; unset($value['id']); $checksums[$id] = md5(serialize($value)); } $uniques = array_unique($checksums); $duplicates = array_diff_key($checksums, $uniques); foreach ($duplicates as $key => $value) { $comments = new comments($commentsTerms[$key]); $comments->delete(); } }
<?php $path = "../../../libraries/"; require_once $path . "configuration.php"; //debug(); $result = eF_getTableData("modules", "*", "name='module_rss'"); $module = $result[0]; if ($module['active']) { $folder = $module['position']; $className = $module['className']; require_once G_MODULESPATH . $folder . "/" . $className . ".class.php"; $moduleInstance = new $className("student.php?ctg=module&op=" . $className, $folder); $moduleInstance->createRssFeed($_GET['type'], $_GET['mode'], $_GET['lesson']); exit; } else { header("Content-Type: application/xml; charset=" . _CHARSET); echo "<message>Rss feeds not activated</message>"; exit; } /* $date = getdate(); $lastHour = mktime($date['hours'], 0, 0, $date['mon'], $date['mday'], $date['year']); lastModificationTime($lastHour); cacheHeaders(lastModificationTime()); lastModificationTime($lastHour); function cacheHeaders($lastModifiedDate) { if ($lastModifiedDate) { if (isset($_SERVER['HTTP_IF_MODIFIED_SINCE']) && strtotime($_SERVER['HTTP_IF_MODIFIED_SINCE']) >= $lastModifiedDate) { if (php_sapi_name()=='CGI') { Header("Status: 304 Not Modified"); } else {
//This file cannot be called directly, only included. if (str_replace(DIRECTORY_SEPARATOR, "/", __FILE__) == $_SERVER['SCRIPT_FILENAME']) { exit; } $loadScripts[] = 'includes/lessons_list'; $loadScripts[] = 'includes/catalog'; try { if (isset($_GET['op']) && $_GET['op'] == 'tests') { require_once "tests/show_skill_gap_tests.php"; } elseif (isset($_GET['export']) && $_GET['export'] == 'rtf') { require_once "rtf_export.php"; } elseif (isset($_GET['export']) && $_GET['export'] == 'xml') { require_once "xml_export.php"; } elseif (isset($_GET['course'])) { $currentCourse = new EfrontCourse($_GET['course']); $result = eF_getTableData("users_to_courses", "user_type", "users_LOGIN='******'login'] . "' and archive=0 and courses_ID=" . $currentCourse->course['id']); if (empty($result) || $roles[$result[0]['user_type']] != 'professor') { throw new Exception(_UNAUTHORIZEDACCESS); } $currentUser->applyRoleOptions($result[0]['user_type']); $baseUrl = 'ctg=lessons&course=' . $currentCourse->course['id']; $smarty->assign("T_BASE_URL", $baseUrl); $smarty->assign("T_CURRENT_COURSE", $currentCourse); require_once 'course_settings.php'; } elseif (isset($_GET['op']) && $_GET['op'] == 'search') { require_once "module_search.php"; } elseif (isset($_GET['catalog'])) { require_once "catalog_page.php"; } else { $myCoursesOptions = array(); $directionsTree = new EfrontDirectionsTree();
/** * (non-PHPdoc) * @see libraries/EfrontEntity#delete() */ public function delete() { $folderMessages = eF_getTableData("f_personal_messages", "id", "f_folders_ID=" . $this->{$this->entity}['id']); foreach ($folderMessages as $message) { eF_PersonalMessage::eF_deletePersonalMessage($message['id']); } $folderDirectory = new EfrontDirectory(G_UPLOADPATH . $this->{$this->entity}['users_LOGIN'] . '/message_attachments/' . $this->{$this->entity}['name']); $folderDirectory->delete(); parent::delete(); }