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'])); } }
public function __construct($param, $isCouponCode) { if ($isCouponCode && eF_checkParameter($param, 'text')) { $result = eF_getTableData("coupons", "*", "code='" . $param . "'"); $param = $result[0]; } parent::__construct($param); }
public function getModule() { // Get smarty variable $smarty = $this->getSmartyVar(); if (isset($_GET['delete_faq']) && eF_checkParameter($_GET['delete_faq'], 'id')) { eF_deleteTableData("module_faq", "id=" . $_GET['delete_faq']); eF_redirect("" . $this->moduleBaseUrl . "&message=" . urlencode(_FAQ_SUCCESFULLYDELETEDFAQENTRY) . "&message_type=success"); } else { if (isset($_GET['add_faq']) || isset($_GET['edit_faq']) && eF_checkParameter($_GET['edit_faq'], 'id')) { $load_editor = true; //TODO $form = new HTML_QuickForm("faq_entry_form", "post", $_SERVER['REQUEST_URI'], "", null, true); $form->registerRule('checkParameter', 'callback', 'eF_checkParameter'); //Register this rule for checking user input with our function, eF_checkParameter $form->addElement('textarea', 'question', null, 'class = "simpleEditor" style = "width:100%;height:5em;"'); $form->addElement('textarea', 'answer', null, 'class = "simpleEditor" style = "width:100%;height:25em;"'); $currentLesson = $this->getCurrentLesson(); $units = eF_getTableDataFlat("content", "id, name", "lessons_ID = " . $currentLesson->lesson['id']); //$units['id'] = array_merge(array("0"), $units['id']); //$units['name'] = array_merge(array(_FAQ_GENERAL_LESSON), $units['name']); sizeof($units) > 0 ? $units = array(0 => _FAQ_GENERAL_LESSON) + array_combine($units['id'], $units['name']) : ($units = array("0" => _FAQ_GENERAL_LESSON)); $form->addElement('select', 'related_content', _CONTENT, $units, 'class = "inputSelectLong"'); $form->addElement('submit', 'submit_faq', _SUBMIT, 'class = "flatButton"'); if (isset($_GET['edit_faq'])) { $faq_entry = eF_getTableData("module_faq", "*", "id=" . $_GET['edit_faq']); $form->setDefaults(array('related_content' => $faq_entry[0]['unit_ID'], 'question' => $faq_entry[0]['question'], 'answer' => $faq_entry[0]['answer'])); } if ($form->isSubmitted() && $form->validate()) { $fields = array('lessons_ID' => $_SESSION['s_lessons_ID'], 'unit_ID' => $form->exportValue('related_content'), 'question' => $form->exportValue('question'), 'answer' => $form->exportValue('answer')); if (isset($_GET['edit_faq'])) { if (eF_updateTableData("module_faq", $fields, "id=" . $_GET['edit_faq'])) { eF_redirect("" . $this->moduleBaseUrl . "&message=" . urlencode(_FAQ_SUCCESFULLYUPDATEDFAQENTRY) . "&message_type=success"); } else { $this->setMessageVar(_FAQ_PROBLEMUPDATINGFAQENTRY, 'failure'); } } else { if (eF_insertTableData("module_faq", $fields)) { eF_redirect("" . $this->moduleBaseUrl . "&message=" . urlencode(_FAQ_SUCCESFULLYINSERTEDFAQENTRY) . "&message_type=success"); } else { $this->setMessageVar(_FAQ_PROBLEMINSERTINGFAQENTRY, 'failure'); } } } $renderer = new HTML_QuickForm_Renderer_ArraySmarty($smarty); $form->accept($renderer); $smarty->assign('T_FAQ_FORM', $renderer->toArray()); } else { $currentLesson = $this->getCurrentLesson(); $faq = eF_getTableDataFlat("module_faq", "*", "lessons_ID=" . $currentLesson->lesson['id']); $currentUser = $this->getCurrentUser(); $smarty->assign("T_FAQUSERLESSONROLE", $currentUser->getRole($currentLesson)); $smarty->assign("T_FAQ", $faq); $smarty->assign("T_QUESTIONS_FOUND", sizeof($faq)); } } return true; }
function getLessonFromId() { if (eF_checkParameter($_GET['loglessonid'], 'id')) { $id = $_GET["loglessonid"]; $sql = "SELECT name FROM lessons WHERE id='" . $id . "'"; $result = mysql_query($sql); } while ($lesson = mysql_fetch_array($result)) { echo $lesson["name"]; } }
/** * Instantiate direction * * This function is the class constructor, which instantiates the * EfrontDirection object, based on the direction values * <br/>Example: * <code> * $direction_array = eF_getTableData("directions", "*", "id=4"); * $direction = new EfrontDirection($direction_array[0]); * </code> * * @param array $array The direction values * @since 3.5.0 * @access public */ function __construct($direction) { if (!is_array($direction)) { if (!eF_checkParameter($direction, 'id')) { throw new EfrontLessonException(_INVALIDID . ': ' . $direction, EfrontDirectionException::INVALID_ID); } $result = eF_getTableData("directions", "*", "id=" . $direction); if (sizeof($result) == 0) { throw new EfrontLessonException(_CATEGORYDOESNOTEXIST . ': ' . $direction, EfrontDirectionException::DIRECTION_NOT_EXISTS); } $direction = $result[0]; } parent::__construct($direction); }
/** * 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; }
/** * Instantiate entity * * @param $param The parameters to instantiate entity with * @since 3.6.0 * @access public */ public function __construct($param) { if (!$this->entity) { $this->entity = strtolower(str_replace('Efront', '', get_class($this))); } if (!is_array($param)) { if (!eF_checkParameter($param, 'id')) { throw new EfrontEntityException(_INVALIDID . ': ' . $param, EfrontEntityException::INVALID_ID); } $result = eF_getTableData($this->entity, "*", "id={$param}"); if (sizeof($result) == 0) { throw new EfrontEntityException(_ENTITYNOTFOUND . ': ' . htmlspecialchars($param), EfrontEntityException::ENTITY_NOT_EXIST); } $this->{$this->entity} = $result[0]; } else { $this->{$this->entity} = $param; } }
/** * 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(); } }
foreach ($supervisedBranches as $value) { $branches[] = $value['branch_ID']; } 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 {
/** * 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; }
if ($certificate_tpl_id <= 0) { $mainTemplate = eF_getTableData("certificate_templates", "id", "certificate_name='" . CERTIFICATES_MAIN_TEMPLATE_NAME . "'"); // XXX $certificate_tpl_id = $mainTemplate[0]['id']; } $issued_data = unserialize($result[0]['issued_certificate']); $templateData = eF_getTableData("certificate_templates", "certificate_xml", "id=" . $certificate_tpl_id); foreach (eF_loadAllModules() as $module) { $module->onXMLExportCourseCertificate($issued_data, $templateData, $course, $_GET['user']); } $userName = $issued_data['user_name']; $userSurName = $issued_data['user_surname']; $courseName = $issued_data['course_name']; $courseGrade = $issued_data['grade']; $serialNumber = $issued_data['serial_number']; if (eF_checkParameter($issued_data['date'], 'timestamp')) { $certificateDate = formatTimestamp($issued_data['date']); } if ($course->course['certificate_expiration'] != 0) { $expirationArray = convertTimeToDays($course->course['certificate_expiration']); $expire_certificateTimestamp = getCertificateExpirationTimestamp($issued_data['date'], $expirationArray); $expireDate = formatTimestamp($expire_certificateTimestamp); } $xmlExport = new XMLExport($templateData[0]['certificate_xml']); $creator = $xmlExport->getCreator(); $author = $xmlExport->getAuthor(); $subjct = $xmlExport->getSubject($userName . ' ' . $userSurName); $keywrd = $xmlExport->getKeywords(); $orientation = $xmlExport->getOrientation(); $pdf = new TCPDF($orientation, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false); $pdf->SetCreator($creator);
EfrontEvent::triggerEvent(array("type" => EfrontEvent::SYSTEM_FORGOTTEN_PASSWORD, "users_LOGIN" => $user->user['login'], "users_name" => $user->user['name'], "users_surname" => $user->user['surname'])); $message = _ANEMAILHASBEENSENT; $message_type = 'success'; if ($_SESSION['login_mode'] != 1) { eF_redirect('' . basename($_SERVER['PHP_SELF']) . '?message=' . urlencode($message) . '&message_type=' . $message_type); } } } catch (Exception $e) { $message = _NONEXISTINGMAIL; $message_type = 'failure'; eF_redirect('' . basename($_SERVER['PHP_SELF']) . '?ctg=reset_pwd&message=' . urlencode($message) . '&message_type=' . $message_type); } } elseif (isset($_GET['id']) && isset($_GET['login'])) { //Second stage, user received the email and clicked on the link $login = $_GET['login']; if (!eF_checkParameter($login, 'login')) { //Possible hacking attempt: malformed user $message = _INVALIDUSER; $message_type = 'failure'; } else { $user = eF_getTableData("users", "email, name", "login='******'"); if (strcmp($_GET['id'], EfrontUser::createPassword($login)) == 0 && sizeof($user) > 0) { $password = implode("", array_map(create_function('$v', 'return chr($v);'), array_rand(array_flip(array_merge(range(48, 57), range(64, 90), range(97, 122))), 10))); $password_encrypted = EfrontUser::createPassword($password); eF_updateTableData("users", array('password' => $password_encrypted), "login='******'"); EfrontEvent::triggerEvent(array("type" => EfrontEvent::SYSTEM_NEW_PASSWORD_REQUEST, "users_LOGIN" => $login, "entity_name" => $password)); $message = _EMAILWITHPASSWORDSENT; eF_redirect('' . basename($_SERVER['PHP_SELF']) . '?message=' . urlencode($message) . '&message_type=success'); } else { $message = _INVALIDUSER; $message_type = 'failure';
$editLesson->archiveLessonUsers(array_keys($users)); } } } exit; } } catch (Exception $e) { handleAjaxExceptions($e); } } } else { if (isset($_GET['lesson_info']) && eF_checkParameter($_GET['lesson_info'], 'id')) { /***/ require_once "lesson_information.php"; } else { if (isset($_GET['lesson_settings']) && eF_checkParameter($_GET['lesson_settings'], 'id')) { $currentLesson = new EfrontLesson($_GET['lesson_settings']); $smarty->assign("T_CURRENT_LESSON", $currentLesson); $loadScripts[] = 'scriptaculous/scriptaculous'; $loadScripts[] = 'scriptaculous/effects'; $baseUrl = 'ctg=lessons&lesson_settings=' . $currentLesson->lesson['id']; $smarty->assign("T_BASE_URL", $baseUrl); require_once "lesson_settings.php"; } else { //The default action is to just print a list with the lessons defined in the system // $filesystem = new FileSystemTree(G_LESSONSPATH, true); $form = new HTML_QuickForm("import_lesson_form", "post", basename($_SERVER['PHP_SELF']) . "?ctg=lessons", "", null, true); //Build the form $form->addElement('file', 'import_content', _UPLOADLESSONFILE, 'class = "inputText"'); $form->setMaxFileSize(FileSystemTree::getUploadMaxSize() * 1024); //getUploadMaxSize returns size in KB
//remove inactive and archived lessons $result = eF_getTableDataFlat("lessons", "id", "active=0 OR archive!=''"); if (!empty($result['id'])) { foreach ($forums as $key => $value) { if (in_array($value['lessons_ID'], $result['id']) !== false) { unset($forums[$key]); } } } //pr($forums); $dataSource = $forums; $tableName = 'forumsTable'; /**Handle sorted table's sorting and filtering*/ include "sorted_table.php"; $smarty->assign("T_FORUMS", $forums); isset($_GET['forum']) && eF_checkParameter($_GET['forum'], 'id') ? $parent_forum = $_GET['forum'] : ($parent_forum = 0); $smarty->assign("T_PARENT_FORUM", $parent_forum); $smarty->assign("T_HAS_SUBFORUMS", sizeof($forumTree[$_GET['forum']])); if ($_SESSION['s_type'] != 'administrator' && $_SESSION['s_current_branch']) { //this applies to supervisors only $polls = eF_getTableData("f_poll, module_hcd_employee_works_at_branch", "*", "f_forums_ID=" . $parent_forum . " and module_hcd_employee_works_at_branch.users_login=f_poll.users_LOGIN and module_hcd_employee_works_at_branch.branch_ID=" . $currentBranch->branch['branch_ID']); $topics = eF_getTableData("f_topics, module_hcd_employee_works_at_branch", "*", "f_forums_ID=" . $parent_forum . " and module_hcd_employee_works_at_branch.users_login=f_topics.users_LOGIN and module_hcd_employee_works_at_branch.branch_ID=" . $currentBranch->branch['branch_ID']); } else { $polls = eF_getTableData("f_poll", "*", "f_forums_ID=" . $parent_forum); $topics = eF_getTableData("f_topics", "*", "f_forums_ID=" . $parent_forum); } foreach ($topics as $k => $topic) { if ($_SESSION['s_type'] != 'administrator' && $_SESSION['s_current_branch']) { //this applies to supervisors only $result = eF_getTableDataFlat("f_messages, module_hcd_employee_works_at_branch", "f_messages.users_LOGIN, f_messages.id, f_messages.timestamp, f_messages.body", "f_topics_ID=" . $topic['id'] . " and module_hcd_employee_works_at_branch.users_login=f_messages.users_LOGIN and module_hcd_employee_works_at_branch.branch_ID=" . $currentBranch->branch['branch_ID']); } else {
} else { $message = '"' . $className . '": ' . _MODULEISALREADYINSTALLED; $message_type = 'failure'; //eF_deleteFolder(G_MODULESPATH.$module_folder.'/'); $dir = new EfrontDirectory(G_MODULESPATH . $module_folder . '/'); $dir->delete(); } } else { $message = _NOMODULECLASSFOUND . ' "' . $className . '" : ' . G_MODULESPATH . $module_folder; $message_type = 'failure'; //$dir = new EfrontDirectory(G_MODULESPATH.$module_folder.'/'); //$dir -> delete(); //eF_deleteFolder(G_MODULESPATH.$module_folder.'/'); } } } elseif (isset($_GET['export_module']) && eF_checkParameter($_GET['export_module'], 'filename')) { if (isset($currentUser->coreAccess['modules'])) { throw new EfrontSystemException(_UNAUTHORIZEDACCESS, EfrontSystemException::UNAUTHORIZED_ACCESS); } $className = $_GET['export_module']; $directory = new EfrontDirectory(G_MODULESPATH . $className); $file = $directory->compress(false, false); echo $file['url_path']; exit; } } catch (Exception $e) { handleAjaxExceptions($e); } $modulesList = eF_getTableData("modules", "*", "", "active desc"); // Check for errors in modules foreach ($modulesList as $key => $module) {
/** * Set version key * * Sets the current version based on the key provided. The key is checked for * validity using checkVersionKey() * <br/>Example: * <code> * $key = 'version_key'; * $result = EfrontSystem :: setVersionKey($key); * </code> * * @param string $key The version key * @return boolean True if the key was successfully set, false otherwise * @since 3.6.0 * @access public * @static */ public static function setVersionKey($key) { if (!$key || !eF_checkParameter($key, 'alnum')) { throw new EfrontSystemException(_INVALIDVERSIONKEY . ': ' . $key, EfrontSystemException::INVALID_VERSION_KEY); } //$versionData = eF_checkVersionKey($key); $versionData = self::checkVersionKey($key); if (G_VERSIONTYPE != $versionData['type']) { throw new EfrontSystemException(_KEYISNOTFORTHISEDITION, EfrontSystemException::INVALID_VERSION_KEY); } if (!$versionData['users'] || !eF_checkParameter($versionData['users'], 'int') && $versionData['users'] != 'unlimited' || (!$versionData['type'] || !isset($versionData['type'])) || (!$versionData['serial'] || !eF_checkParameter($versionData['serial'], 'int'))) { throw new EfrontSystemException(_INVALIDVERSIONKEY . ': ' . $key, EfrontSystemException::INVALID_VERSION_KEY); } //debug(); EfrontConfiguration::setValue('version_key', $key); EfrontConfiguration::setValue('version_users', $versionData['users']); EfrontConfiguration::setValue('version_serial', $versionData['serial']); EfrontConfiguration::setValue('version_type', $versionData['type']); EfrontConfiguration::setValue('version_activated', time()); EfrontConfiguration::setValue('version_upgrades', $versionData['upgrades']); //EfrontConfiguration :: setValue('version_paypal', $versionData['paypal']); //EfrontConfiguration :: setValue('version_hcd', $versionData['hcd']); // Going to educational version: check the existence of lesson and course skills if ($versionData['type'] == "educational") { eF_insertAutoLessonCourseSkills(); } return true; }
/** * * @param $fields * @return unknown_type */ public static function create($fields = array()) { !isset($fields['users_LOGIN']) || !eF_checkParameter($fields['users_LOGIN'], 'login') ? $fields['users_LOGIN'] = $_SESSION['s_login'] : null; $directory = G_UPLOADPATH . $fields['users_LOGIN'] . '/message_attachments/' . $fields['name']; if (!mkdir($directory, 0755)) { throw new EfrontFileException(_COULDNOTCREATEDIRECTORY . ': ' . $directory, EfrontFileException::GENERAL_ERROR); } eF_insertTableData("f_folders", $fields); }
private function doCourseLessonUsers() { $smarty = $this->getSmartyVar(); $currentUser = $this->getCurrentUser(); if (isset($_GET['lessons_ID'])) { $currentLesson = new EfrontLesson($_GET['lessons_ID']); $smarty->assign("T_CURRENT_LESSON", $currentLesson); $roles = EfrontUser::getRoles(true); $smarty->assign("T_ROLES", $roles); try { if ($_GET['ajax'] == 'usersTable') { $constraints = array('archive' => false, 'active' => 1, 'return_objects' => false) + createConstraintsFromSortedTable(); $dataSource = $currentLesson->getLessonUsersIncludingUnassigned($constraints); $totalEntries = $currentLesson->countLessonUsersIncludingUnassigned($constraints); $smarty->assign("T_SORTED_TABLE", $_GET['ajax']); $smarty->assign("T_TABLE_SIZE", $totalEntries); $smarty->assign("T_DATA_SOURCE", $dataSource); } if (isset($_GET['ajax']) && isset($_GET['reset_user'])) { $user = EfrontUserFactory::factory($_GET['reset_user']); $user->resetProgressInLesson($currentLesson); 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", "*", "archive = 0 and users_LOGIN='******'login'] . "' and lessons_ID=" . $currentLesson->lesson['id']); if (sizeof($result) == 0) { $currentLesson->addUsers($_GET['login'], $userType); } elseif ($result[0]['user_type'] != $userType) { $currentLesson->setRoles($_GET['login'], $userType); } else { $currentLesson->removeUsers($_GET['login']); } } else { if (isset($_GET['addAll'])) { $constraints = array('archive' => false, 'active' => 1, 'has_lesson' => 0, 'return_objects' => false) + createConstraintsFromSortedTable(); $dataSource = $currentLesson->getLessonUsersIncludingUnassigned($constraints); $userTypes = array(); foreach ($dataSource as $user) { $user['user_types_ID'] ? $userTypes[] = $user['user_types_ID'] : ($userTypes[] = $user['user_type']); } $currentLesson->addUsers($dataSource, $userTypes); } else { if (isset($_GET['removeAll'])) { $constraints = array('archive' => false, 'active' => 1, 'has_lesson' => 1, 'return_objects' => false) + createConstraintsFromSortedTable(); $dataSource = $currentLesson->getLessonUsersIncludingUnassigned($constraints); $currentLesson->archiveLessonUsers($dataSource); } } } exit; } } catch (Exception $e) { handleAjaxExceptions($e); } } }
/** * 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)); } } } } } } } }
<?php //This file cannot be called directly, only included. if (str_replace(DIRECTORY_SEPARATOR, "/", __FILE__) == $_SERVER['SCRIPT_FILENAME']) { exit; } if (is_dir("scorm_logs") && eF_checkParameter($_POST['content_ID'], 'id')) { $unit = new EfrontUnit($_POST['content_ID']); if ($unit['options']['scorm_logging']) { $lesson = new EfrontLesson($_SESSION['s_lessons_ID']); $str = formatTimestamp(time(), 'time') . ", {$currentUser->user['login']}, Committed data for '{$unit['name']} ({$_POST['content_ID']}) in lesson {$lesson->lesson['name']} ({$lesson->lesson['id']}):"; foreach ($_POST as $key => $value) { if ($key != 'content_ID' && $key != 'users_LOGIN' && $value) { $str .= " {$key}:{$value},"; } } file_put_contents("scorm_logs/" . date("Y_m_d") . ".scorm.log", $str . "\n", FILE_APPEND); } } try { //pr($_POST);pr($_GET); unset($_POST['_']); //id and credit are not stored in any table $credit = true; if ($_POST['credit'] == 'no-credit') { $credit = false; } unset($_POST['credit']); //unset ($_POST['session_time']); unset($_POST['id']); unset($_POST['popup']);
/** * * @param $fields * @return unknown_type */ public static function validateFields($fields) { //Check validity of parameters if (!isset($fields['name']) || !eF_checkParameter($fields['name'], 'alnum_general')) { throw new Exception(_INVALIDNAME, EfrontEntityException::INVALID_PARAMETER); } if (!isset($fields['options'])) { $fields['options'] = array(); } //!isset($fields['active']) ? $fields['active'] = 1 : null; if (!isset($fields['options']['sidebar_width']) || $fields['options']['sidebar_width'] < 50 || $fields['options']['sidebar_width'] > 500) { $fields['options']['sidebar_width'] = 175; } if (!isset($fields['options']['sidebar_interface']) || !in_array($fields['options']['sidebar_interface'], array(0, 1, 2))) { $fields['options']['sidebar_interface'] = 0; } if (!isset($fields['options']['show_header']) || !in_array($fields['options']['show_footer'], array(0, 1, 2))) { $fields['options']['show_header'] = 1; } if (!isset($fields['options']['show_footer']) || !in_array($fields['options']['show_footer'], array(0, 1, 2))) { $fields['options']['show_footer'] = 1; } if (!isset($fields['options']['images_displaying']) || !in_array($fields['options']['images_displaying'], array(0, 1, 2))) { $fields['options']['images_displaying'] = 0; } if (!isset($fields['layout'])) { $fields['layout'] = array(); } if (!isset($fields['layout']['positions'])) { $fields['positions'] = array(); } if (!isset($fields['layout']['positions']['layout']) || !in_array($fields['layout']['positions']['layout'], array('simple', 'left', 'right', 'three'))) { $fields['layout']['positions']['layout'] = 'three'; } if (!isset($fields['layout']['positions']['leftList'])) { $fields['layout']['positions']['leftList'] = array(); } else { if (isset($fields['layout']['positions']['leftList']) && !is_array($fields['layout']['positions']['leftList'])) { $fields['layout']['positions']['leftList'] = array($fields['layout']['positions']['leftList']); } } if (!isset($fields['layout']['positions']['centerList'])) { $fields['layout']['positions']['centerList'] = array(); } else { if (isset($fields['layout']['positions']['centerList']) && !is_array($fields['layout']['positions']['centerList'])) { $fields['layout']['positions']['centerList'] = array($fields['layout']['positions']['centerList']); } } if (!isset($fields['layout']['positions']['rightList'])) { $fields['layout']['positions']['rightList'] = array(); } else { if (isset($fields['layout']['positions']['rightList']) && !is_array($fields['layout']['positions']['rightList'])) { $fields['layout']['positions']['rightList'] = array($fields['layout']['positions']['rightList']); } } //$fields['layout']['positions']['layout'] = $fields['layout']['selected_layout']; //pr($fields);exit; $fields['options'] = serialize($fields['options']); $fields['layout'] = serialize($fields['layout']); return $fields; }
} elseif ($_GET['package_ID']) { $unit = new EfrontUnit($_GET['package_ID']); $currentLesson = new EfrontLesson($unit['lessons_ID']); } $_SESSION['s_lessons_ID'] = $currentLesson->lesson['id']; } $currentContent = new EfrontContentTree($currentLesson); if ($_student_) { $currentContent->markSeenNodes($currentUser); } } //Legal values are the array of entities that the current user may actually edit or change. foreach (new EfrontNodeFilterIterator(new RecursiveIteratorIterator(new RecursiveArrayIterator($currentContent->tree), RecursiveIteratorIterator::SELF_FIRST)) as $key => $value) { $legalValues[] = $key; } if (isset($_GET['add']) || isset($_GET['edit']) && in_array($_GET['edit'], $legalValues) && eF_checkParameter($_GET['edit'], 'id') && $_change_) { try { if ($_GET['edit']) { $currentUnit = $currentContent->seekNode($_GET['edit']); //The content tree does not hold data, so assign this unit its data $unitData = new EfrontUnit($_GET['edit']); $currentUnit['data'] = $unitData['data']; $currentUnitName = $unitData['name']; } else { unset($currentUnit); //Needed because we might have the &view_unit specified in the parameters } //This page has a file manager, so bring it on with the correct options $basedir = $currentLesson->getDirectory(); //Default options for the file manager if (!isset($currentUser->coreAccess['files']) || $currentUser->coreAccess['files'] == 'change') {
} $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; $legalValues[] = 0; //Add 0 to possible content units, since both parent and previous units may be 0 foreach ($_POST['node_orders'] as $value) { list($id, $parentContentId) = explode("-", $value); if ($id && in_array($id, $legalValues) && in_array($parentContentId, $legalValues) && eF_checkParameter($id, 'id') && eF_checkParameter($parentContentId, 'id') !== false) { try { //Putting the try/catch block here, makes the process to continue even if it fails for some units $unit = $currentContent->seekNode($id); $unit->offsetSet('previous_content_ID', $previousContentId); $unit->offsetSet('parent_content_ID', $parentContentId); //$unit -> offsetSet('data', $unit['data']); // vprountzos: I changed this because is was related to #5228 and used to empty the content $normalUnit = new EfrontUnit($unit['id']); $unit->offsetSet('data', $normalUnit['data']); $unit->persist(); $previousContentId = $id; } catch (Exception $e) { $errorMessages[] = $e->getMessage() . ' ' . $e->getCode(); } } }
} } $smarty->assign("_change_placements_", $_change_placements_); if ($currentUser->user['user_type'] != 'administrator') { $smarty->assign("T_SUPERVISES_BRANCHES", $currentEmployee->supervisesBranches); } if (isset($_GET['ajax']) && isset($_GET['delete_job']) && eF_checkParameter($_GET['delete_job'], 'id') && $_change_placements_) { try { $editedEmployee = $editedEmployee->removeJob($_GET['delete_job']); echo json_encode(array("status" => 1)); } catch (Exception $e) { handleAjaxExceptions($e); } exit; } else { if (isset($_GET['add_placement']) || isset($_GET['edit_placement']) && eF_checkParameter($_GET['edit_placement'], 'id')) { $branchTree = new EfrontBranchesTree(); $branches = $branchTree->toPathStringShortened(); foreach ($branches as $key => $branch) { if ($currentUser->user['user_type'] != 'administrator' && !in_array($key, $currentEmployee->supervisesBranches)) { unset($branches[$key]); } } reset($branches); if ($_POST['branch']) { $branch = new EfrontBranch($_POST['branch']); } elseif (isset($_GET['add_placement'])) { $branch = new EfrontBranch(key($branches)); } else { $currentJob = new EfrontJob($_GET['edit_placement']); $branch = new EfrontBranch($currentJob->job['branch_ID']);
$lessons = array(); foreach ($userLessons as $key => $lesson) { if (!$lesson->lesson['course_only']) { $lessons[$lesson->lesson['id']] = $lesson->lesson; } } isset($_GET['filter']) ? $lessons = eF_filterData($lessons, $_GET['filter']) : null; $editedUser->archiveUserLessons(array_keys($lessons)); } else { if (isset($_GET['addAllLessonsFromTest'])) { // The missing and required skill set is sent over with the ajax request $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']); }
/** * Convert a lesson argument to a lesson id * * @param mixed $lesson The lesson argument, can be an id or an EfrontLesson object * @return int The lesson id * @since 3.6.3 * @access public * @static */ public static function convertArgumentToLessonId($lesson) { if ($lesson instanceof EfrontLesson) { $lesson = $lesson->lesson['id']; } else { if (!eF_checkParameter($lesson, 'id')) { throw new EfrontLessonException(_INVALIDID, EfrontLessonException::INVALID_ID); } } return $lesson; }
//Set scorm content type through AJAX call if (isset($_GET['set_type']) && isset($_GET['id']) && in_array($_GET['id'], $valid12Units)) { $unit = new EfrontUnit($_GET['id']); $unit['ctg_type'] == 'scorm_test' ? $unit['ctg_type'] = 'scorm' : ($unit['ctg_type'] = 'scorm_test'); $unit->persist(); echo json_encode(array('id' => $unit['id'], 'ctg_type' => $unit['ctg_type'])); exit; } if (isset($_GET['reset_scorm']) && isset($_GET['id']) && in_array($_GET['id'], $valid12Units)) { //eF_deleteTableData("scorm_data", "id=".$_GET['delete']); //$user = EfrontUserFactory::factory($scormData[0]['users_LOGIN']); //$user -> setSeenUnit($scormData[0]['content_ID'], $currentLesson, false); } //Reset scorm data if (isset($_GET['reset_scorm']) && isset($_GET['id']) && in_array($_GET['id'], $valid2004Units)) { if (isset($_GET['login']) && eF_checkParameter($_GET['login'], 'login')) { //EfrontContentTreeSCORM :: resetSCORMContentOrganization($currentLesson, $_GET['id'], $_GET['login']); } else { EfrontContentTreeSCORM::resetSCORMContentOrganization($currentLesson, $_GET['id']); } } } catch (Exception $e) { header("HTTP/1.0 500 "); echo $e->getMessage() . ' (' . $e->getCode() . ')'; exit; } $smarty->assign("T_SCORM_TREE", $currentContent->toHTML($iterator, false, $options)); } } } //$scormOptions[] = array('text' => _SCORMEXPORT, 'image' => "32x32/export.png", 'href' => "scorm_export.php?lessons_ID=".$_SESSION['s_lessons_ID'], 'onClick' => "eF_js_showDivPopup(event, '"._SCORMEXPORT."', 2)", 'target' => 'POPUP_FRAME');
foreach ($events as $key => $event) { $events[$key]['avatar'] = $users_avatars[$event['users_LOGIN']]; try { $file = new EfrontFile($events[$key]['avatar']); list($events[$key]['avatar_width'], $events[$key]['avatar_height']) = eF_getNormalizedDims($file['path'], 50, 50); } catch (EfrontFileException $e) { $events[$key]['avatar'] = G_SYSTEMAVATARSPATH . "unknown_small.png"; $events[$key]['avatar_width'] = 50; $events[$key]['avatar_height'] = 50; } } } $count = sizeof($events); $smarty->assign("T_TIMELINE_EVENTS_SIZE", $count); if (isset($_GET['limit']) && eF_checkParameter($_GET['limit'], 'int')) { isset($_GET['offset']) && eF_checkParameter($_GET['offset'], 'int') ? $offset = $_GET['offset'] : ($offset = 0); $events = array_slice($events, $offset, $limit); } if ($count) { $smarty->assign("T_TIMELINE_EVENTS", $events); } if (isset($_GET['ajax'])) { $smarty->display($_SESSION['s_type'] . '.tpl'); exit; } } } } } } }
if ($pendingCourses) { $myCoursesOptions[] = array('text' => _SUPERVISORAPPROVAL, 'image' => "32x32/success.png", 'href' => "javascript:void(0)", 'onclick' => "eF_js_showDivPopup(event, '" . _SUPERVISORAPPROVAL . "', 2, 'supervisor_approvals_list')"); $smarty->assign("T_SUPERVISOR_APPROVALS", $pendingCourses); } if (isset($_GET['ajax']) && $_GET['ajax'] == 'approval') { try { $course = new EfrontCourse($_GET['course_id']); $course->confirm($_GET['users_login']); echo json_encode(array('status' => 1)); exit; } catch (Exception $e) { handleAjaxExceptions($e); } } elseif (isset($_GET['ajax']) && $_GET['ajax'] == 'cancel') { try { if (eF_checkParameter($_GET['course_id'], 'id')) { $course = new EfrontCourse($_GET['course_id']); $course->removeUsers($_GET['users_login']); $event = array("type" => EfrontEvent::COURSE_USER_REFUSAL, "users_LOGIN" => $_GET['users_login'], "lessons_ID" => $course->course['id'], "lessons_name" => $course->course['name']); EfrontEvent::triggerEvent($event); echo json_encode(array('status' => 1)); exit; } } catch (Exception $e) { handleAjaxExceptions($e); } } } } #cpp#endif if ($currentUser->coreAccess['dashboard'] != 'hidden') {
function checkToken($token) { if (eF_checkParameter($token, 'alnum')) { $tmp = ef_getTableData("tokens", "status", "token='{$token}'"); $token = $tmp[0]['status']; if ($token == 'logged') { return true; } } return false; }