setcookie('c_request', htmlspecialchars_decode(basename($_SERVER['REQUEST_URI'])), time() + 300, false, false, false, true); } eF_redirect("index.php?ctg=expired"); exit; } if (isset($_SESSION['s_index_comply'])) { eF_redirect("index.php?ctg=" . $_SESSION['s_index_comply']); exit; } if (!isset($_GET['ajax']) && !isset($_GET['postAjaxRequest']) && !isset($popup) && !isset($_GET['tabberajax'])) { $_SESSION['previousMainUrl'] = $_SERVER['REQUEST_URI']; } if (isset($_GET['toggle_mode'])) { //EfrontConfiguration::setValue('simple_mode', !$GLOBALS['configuration']['simple_mode']); $mode = eF_getTableData("users", "simple_mode", "login='******'s_login'] . "'"); eF_updateTableData("users", array('simple_mode' => !$mode[0]['simple_mode']), "login='******'s_login'] . "'"); } if (isset($_COOKIE['c_request']) && $_COOKIE['c_request']) { setcookie('c_request', '', time() - 86400); if (mb_strpos($_COOKIE['c_request'], '.php') !== false) { $urlParts = parse_url($_COOKIE['c_request']); if (basename($urlParts['path']) == 'professor.php') { eF_redirect($_COOKIE['c_request']); } } else { eF_redirect($_SESSION['s_type'] . '.php?' . $_COOKIE['c_request']); } } $roles = EfrontLessonUser::getLessonsRoles(); try { if (isset($_GET['view_unit']) || isset($_GET['package_ID'])) {
/** * Set configuration value * * This function is used to set a configuration value. Given a name/value pair, * this function first checks if it exists in the 'configuration' database table. * If so, it updates the variable with the new value, otherwise it inserts a new * entry. * <br/>Example: * <code> * $defaultConfig = EfrontConfiguration :: setValue('smtp_host', 'localhost'); //Set the configuration parameter 'smtp_host' to 'localhost' * </code> * * @param string $name The variable name * @param string $value The variable value * @return boolean The query result * @access public * @since 3.0 * @static */ public static function setValue($name, $value) { $value = trim($value); try { eF_insertTableData("configuration", array('name' => $name, 'value' => $value)); } catch (Exception $e) { //If exists, update it eF_updateTableData("configuration", array('value' => $value), "name = '{$name}'"); } $GLOBALS['configuration'][$name] = $value; EfrontCache::getInstance()->deleteCache('configuration'); return true; }
$smarty->assign('T_RENAME_CERTIFICATE_TEMPLATE_REDIRECT', $redirectUrl); } $tid = $_GET['template_id']; $postTarget = basename($_SERVER['PHP_SELF']) . '?' . $baseUrl . '&op=rename_certificate_template&template_id=' . $tid; $form = new HTML_QuickForm("rename_certificate_template_form", "post", $postTarget, "", null, true); $form->registerRule('checkParameter', 'callback', 'eF_checkParameter'); // Register this rule for checking user input with eF_checkParameter $form->addElement('text', 'certificate_name', _CERTIFICATENAME, 'class="inputText"'); $form->addRule('certificate_name', _THEFIELD . ' "' . _CERTIFICATENAME . '" ' . _ISMANDATORY, 'required', null, 'client'); $form->addElement('submit', 'rename_certificate_template', _SAVE, 'class="flatButton"'); $renameTemplate = eF_getTableData("certificate_templates", "certificate_name", "id=" . $tid); $form->setDefaults(array('certificate_name' => $renameTemplate[0]['certificate_name'])); if ($form->isSubmitted() && $form->validate()) { $formValues = $form->exportValues(); $dbFields = array("certificate_name" => $formValues['certificate_name']); if (eF_updateTableData("certificate_templates", $dbFields, "id=" . $tid)) { $message = _SUCCESSFULLYRENAMECERTIFICATETEMPLATE; $message_type = 'success'; } else { $message = _PROBLEMRENAMECERTIFICATETEMPLATE; $message_type = 'failure'; } $redirectUrl = "" . basename($_SERVER['PHP_SELF']) . "?" . $baseUrl . "&op=format_certificate&message=" . urlencode($message); $redirectUrl .= "&message_type=" . $message_type . "&reset_popup=1&tid=" . $tid; $smarty->assign('T_RENAME_CERTIFICATE_TEMPLATE_REDIRECT', $redirectUrl); } $renderer = prepareFormRenderer($form); $smarty->assign('T_RENAME_CERTIFICATE_TEMPLATE_FORM', $renderer->toArray()); } #cpp#endif } else {
} $editLesson->lesson = array_merge($editLesson->lesson, $fields_update); if ($values['price'] && $values['recurring'] && in_array($values['recurring'], array_keys($recurringOptions))) { $editLesson->options['recurring'] = $values['recurring']; if ($editLesson->options['recurring']) { $editLesson->options['recurring_duration'] = $form->exportValue($editLesson->options['recurring'] . '_duration'); } } else { unset($editLesson->options['recurring']); } try { $editLesson->persist(); $lesson_forum = eF_getTableData("f_forums", "id", "lessons_ID=" . $_GET['edit_lesson']); //update lesson's forum names as well if (sizeof($lesson_forum) > 0) { eF_updateTableData("f_forums", array('title' => $values['name']), "id=" . $lesson_forum[0]['id']); } eF_redirect(basename(basename($_SERVER['PHP_SELF'])) . '?ctg=lessons&message=' . urlencode(_LESSONUPDATED) . '&message_type=success'); } catch (Exception $e) { $smarty->assign("T_EXCEPTION_TRACE", $e->getTraceAsString()); $message = _SOMEPROBLEMOCCURED . ': ' . $e->getMessage() . ' (' . $e->getCode() . ') <a href = "javascript:void(0)" onclick = "eF_js_showDivPopup(event, \'' . _ERRORDETAILS . '\', 2, \'error_details\')">' . _MOREINFO . '</a>'; $message_type = 'failure'; } } } } $renderer = new HTML_QuickForm_Renderer_ArraySmarty($smarty); //Create a smarty renderer $renderer->setRequiredTemplate('{$html}{if $required} <span class = "formRequired">*</span> {/if}');
$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'; } } } $renderer = new HTML_QuickForm_Renderer_ArraySmarty($smarty); $renderer->setRequiredTemplate('{$html}{if $required} <span class = "formRequired">*</span> {/if}'); $form->setJsWarnings(_BEFOREJAVASCRIPTERROR, _AFTERJAVASCRIPTERROR); $form->setRequiredNote(_REQUIREDNOTE);
$form->setDefaults(array('topic_description' => $topic[0]['title'])); } $renderer = new HTML_QuickForm_Renderer_ArraySmarty($smarty); $renderer->setRequiredTemplate('{$html}{if $required} <span class = "formRequired">*</span> {/if}'); //LESSONTIMELINE DATA SUBMISSION if ($form->isSubmitted()) { if ($form->validate()) { $topic_content = array('title' => $form->exportValue('topic_description'), 'lessons_ID' => $currentLesson->lesson['id']); if (isset($_GET['add_topic'])) { eF_insertTableData("lessons_timeline_topics", $topic_content); $message = _SUCCESSFULLYCREATEDLESSONTIMELINETOPIC; $message_type = 'success'; } elseif (isset($_GET['edit_topic'])) { eF_updateTableData("lessons_timeline_topics", $topic_content, "id = '" . $_GET['edit_topic'] . "'"); $message = _LESSONTIMELINETOPICDATAUPDATED; $message_type = 'success'; } // Return to previous url stored in a hidden - that way, after the insertion we can immediately return to where we were echo "<script>!/\\?/.test(parent.location) ? parent.location = '" . basename($form->exportValue('previous_url')) . "&message=" . urlencode($message) . "&message_type=" . $message_type . "' : parent.location = '" . basename($form->exportValue('previous_url')) . "&message=" . urlencode($message) . "&message_type=" . $message_type . "';</script>"; //eF_redirect("".$form->exportValue('previous_url')."&message=". $message . "&message_type=" . $message_type . "&tab=skills"); exit; } } $form->setJsWarnings(_BEFOREJAVASCRIPTERROR, _AFTERJAVASCRIPTERROR); $form->setRequiredNote(_REQUIREDNOTE); $form->accept($renderer); $smarty->assign('T_LESSONTIMELINE_TOPIC_FORM', $renderer->toArray()); } }
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>"; } } else { echo "<xml>";
public function setCache($key, $data, $timeout = null) { $key = self::_encode($parameters); $values = array("cache_key" => $key, "value" => serialize($data), "timestamp" => time()); if ($timeout && eF_checkParameter($timeout, 'int')) { $values['timeout'] = $timeout; } if (sizeof(eF_getTableData("cache", "value", "cache_key='" . $key . "'")) > 0) { $result = eF_updateTableData("cache", $values, "cache_key='{$key}'"); } else { $result = eF_insertTableData("cache", $values); } return $result; }
public function getSmartyTpl() { $smarty = $this->getSmartyVar(); $smarty->assign("T_RSS_MODULE_BASEURL", $this->moduleBaseUrl); $smarty->assign("T_RSS_MODULE_BASELINK", $this->moduleBaseLink); $smarty->assign("T_RSS_PROVIDED_FEEDS_MODES", $this->feedProviderModes); $smarty->assign("T_RSS_PROVIDED_FEEDS_TYPES", $this->providedFeeds); $smarty->assign("T_RSS_PROVIDED_FEEDS_LESSON_TYPES", $this->lessonProvidedFeeds); if (isset($_GET['delete_feed']) && eF_checkParameter($_GET['delete_feed'], 'id')) { try { if ($_GET['type'] == 'provider') { eF_deleteTableData("module_rss_provider", "id=" . $_GET['delete_feed']); } else { eF_deleteTableData("module_rss_feeds", "id=" . $_GET['delete_feed']); } } catch (Exception $e) { handleAjaxExceptions($e); } exit; } elseif (isset($_GET['deactivate_feed']) && eF_checkParameter($_GET['deactivate_feed'], 'id')) { try { if ($_GET['type'] == 'provider') { eF_updateTableData("module_rss_provider", array("active" => 0), "id=" . $_GET['deactivate_feed']); } else { eF_updateTableData("module_rss_feeds", array("active" => 0), "id=" . $_GET['deactivate_feed']); } echo 0; } catch (Exception $e) { handleAjaxExceptions($e); } exit; } elseif (isset($_GET['activate_feed']) && eF_checkParameter($_GET['activate_feed'], 'file')) { //Although db operations do not support exceptions (yet), we leave this here for future support try { if ($_GET['type'] == 'provider') { eF_updateTableData("module_rss_provider", array("active" => 1), "id=" . $_GET['activate_feed']); } else { eF_updateTableData("module_rss_feeds", array("active" => 1), "id=" . $_GET['activate_feed']); } echo 1; } catch (Exception $e) { handleAjaxExceptions($e); } exit; } else { if (isset($_GET['add_feed']) || isset($_GET['edit_feed']) && eF_checkParameter($_GET['edit_feed'], 'id')) { if ($_SESSION['s_lesson_user_type']) { $type = $_SESSION['s_lesson_user_type']; } else { $type = $this->getCurrentUser()->getType(); } $smarty->assign("T_RSS_USERTYPE", $type); $feeds = $this->getFeeds(); $lessons = array(-1 => _RSS_NONE, 0 => _ALLLESSONS); $result = EfrontLesson::getLessons(); foreach ($result as $key => $lesson) { $lessons[$key] = $lesson['name']; } isset($_GET['add_feed']) ? $postTarget = "&add_feed=1" : ($postTarget = "&edit_feed=" . $_GET['edit_feed']); $form = new HTML_QuickForm("add_feed_form", "post", $this->moduleBaseUrl . $postTarget, "", null, true); $form->registerRule('checkParameter', 'callback', 'eF_checkParameter'); $form->addElement('text', 'title', _RSS_FEEDTITLE, 'class = "inputText"'); $form->addElement('text', 'url', _RSS_FEEDURL, 'class = "inputText"'); $form->addElement('select', 'lessons_ID', _LESSON, $lessons); if ($type != 'administrator' && $_SESSION['s_lessons_ID']) { $form->setDefaults(array('lessons_ID' => $_SESSION['s_lessons_ID'])); $form->freeze(array('lessons_ID')); } $form->addElement("advcheckbox", "active", _RSS_ACTIVE, null, 'class = "inputCheckBox"', array(0, 1)); $form->setDefaults(array('active' => 1)); $form->addElement("advcheckbox", "only_summary", _RSS_ONLYSUMMARY, null, 'class = "inputCheckBox"', array(0, 1)); $form->addRule('title', _THEFIELD . ' "' . _RSS_FEEDTITLE . '" ' . _ISMANDATORY, 'required', null, 'client'); $form->addRule('url', _THEFIELD . ' "' . _RSS_FEEDURL . '" ' . _ISMANDATORY, 'required', null, 'client'); $form->addRule('title', _INVALIDFIELDDATA, 'checkParameter', 'text'); $form->addElement('submit', 'submit', _SUBMIT, 'class = "flatButton"'); if (isset($_GET['edit_feed'])) { $editFeed = $feeds[$_GET['edit_feed']]; $form->setDefaults($editFeed); } if ($form->isSubmitted() && $form->validate()) { //If the form is submitted and validated $values = $form->exportValues(); $fields = array("title" => $values['title'], "url" => $values['url'], "active" => $values['active'], "only_summary" => $values['only_summary'], "lessons_ID" => $values['lessons_ID']); if (isset($_GET['add_feed'])) { eF_insertTableData("module_rss_feeds", $fields); $smarty->assign("T_RSS_RSS_MESSAGE", _RSS_SUCCESSFULLYADDEDFEED); } else { eF_updateTableData("module_rss_feeds", $fields, "id=" . $_GET['edit_feed']); $smarty->assign("T_RSS_RSS_MESSAGE", _RSS_SUCCESSFULLYEDITEDFEED); EfrontCache::getInstance()->deleteCache('rss_cache:' . $_GET['edit_feed']); } } $smarty->assign("T_RSS_ADD_RSS_FORM", $form->toArray()); } else { if (isset($_GET['add_feed_provider']) || isset($_GET['edit_feed_provider']) && eF_checkParameter($_GET['edit_feed_provider'], 'id')) { if ($_SESSION['s_lesson_user_type']) { $type = $_SESSION['s_lesson_user_type']; } else { $type = $this->getCurrentUser()->getType(); } $smarty->assign("T_RSS_USERTYPE", $type); $feeds = $this->getProvidedFeeds(); isset($_GET['add_feed_provider']) ? $postTarget = "&add_feed_provider=1" : ($postTarget = "&edit_feed_provider=" . $_GET['edit_feed_provider']); !isset($_GET['lesson']) or $postTarget .= '&lesson=1'; $form = new HTML_QuickForm("add_feed_provider_form", "post", $this->moduleBaseUrl . $postTarget . '&tab=rss_provider', "", null, true); $form->registerRule('checkParameter', 'callback', 'eF_checkParameter'); if ($_GET['lesson']) { $lessons = array(0 => _ALLLESSONS); $result = EfrontLesson::getLessons(); foreach ($result as $key => $lesson) { $lessons[$key] = $lesson['name']; } $form->addElement('select', 'feeds_provided', _RSS_PROVIDEDFEEDS, $this->lessonProvidedFeeds); $form->addElement('select', 'lessons_ID', _LESSON, $lessons); if ($type != 'administrator' && $_SESSION['s_lessons_ID']) { $form->setDefaults(array('lessons_ID' => $_SESSION['s_lessons_ID'])); $form->freeze(array('lessons_ID')); } } else { $form->addElement('select', 'feeds_provided', _RSS_PROVIDEDFEEDS, $this->providedFeeds); } $form->addElement("advcheckbox", "active", _RSS_ACTIVE, null, 'class = "inputCheckBox"', array(0, 1)); $form->setDefaults(array('active' => 1)); $form->addElement('submit', 'submit', _SUBMIT, 'class = "flatButton"'); if (isset($_GET['edit_feed_provider'])) { $editFeed = $feeds[$_GET['edit_feed_provider']]; $form->setDefaults($editFeed); } try { if ($form->isSubmitted() && $form->validate()) { //If the form is submitted and validated $values = $form->exportValues(); $fields = array("mode" => $_GET['lesson'] ? 'lesson' : 'system', "type" => $values['feeds_provided'], "active" => $values['active'], "lessons_ID" => $values['lessons_ID']); foreach ($feeds as $feed) { if ($feed['type'] == $fields['type'] && $feed['mode'] == $fields['mode'] && $feed['lessons_ID'] == $fields['lessons_ID']) { throw new Exception(_FEEDALREADYEXISTS); } } if (isset($_GET['add_feed_provider'])) { eF_insertTableData("module_rss_provider", $fields); $smarty->assign("T_RSS_RSS_MESSAGE", _RSS_SUCCESSFULLYADDEDFEED); } else { eF_updateTableData("module_rss_provider", $fields, "id=" . $_GET['edit_feed_provider']); $smarty->assign("T_RSS_RSS_MESSAGE", _RSS_SUCCESSFULLYEDITEDFEED); } } } catch (Exception $e) { $smarty->assign("T_EXCEPTION_TRACE", $e->getTraceAsString()); $message = $e->getMessage() . ' (' . $e->getCode() . ') <a href = "javascript:void(0)" onclick = "eF_js_showDivPopup(event, \'' . _ERRORDETAILS . '\', 2, \'error_details\')">' . _MOREINFO . '</a>'; $message_type = 'failure'; } $smarty->assign("T_RSS_PROVIDE_RSS_FORM", $form->toArray()); } else { if (isset($_GET['ajax'])) { echo $this->getRssFeeds($_GET['refresh']); //echo $this -> getRssFeeds(true); exit; } else { $lessons = array(0 => _ALLLESSONS); $result = EfrontLesson::getLessons(); foreach ($result as $key => $lesson) { $lessons[$key] = $lesson['name']; } $smarty->assign("T_LESSON_NAMES", $lessons); if ($_SESSION['s_lesson_user_type']) { $type = $_SESSION['s_lesson_user_type']; $smarty->assign("T_RSS_PROVIDED_FEEDS", $this->getProvidedFeeds($_SESSION['s_lessons_ID'])); $smarty->assign("T_RSS_FEEDS", $this->getFeeds(false, $_SESSION['s_lessons_ID'])); } else { $type = $this->getCurrentUser()->getType(); $smarty->assign("T_RSS_PROVIDED_FEEDS", $this->getProvidedFeeds()); $smarty->assign("T_RSS_FEEDS", $this->getFeeds()); } $smarty->assign("T_RSS_USERTYPE", $type); } } } } if ($message) { $this->setMessageVar($message, $message_type); } return $this->moduleBaseDir . "module_rss.tpl"; }
/** * Persist group values * * This function is used to persist any changes made to the current * group. * <br/>Example: * <code> * $group = new EfrontGroup(3); //Instantiate group with id 3 * $group -> group['name'] = 'new name'; //Change a group's value * $group -> persist(); //Store changes values to the database * </code> * * @return boolean True if everything is ok * @since 3.5.0 * @access public */ public function persist() { // Remove the current default group if ($this->group['is_default']) { eF_updateTableData("groups", array("is_default" => 0), "1=1"); } $ok = eF_updateTableData("groups", $this->group, "id=" . $this->group['id']); return $ok; }
/** * Experimental function for merging lessons and courses to the main tree * */ public function reset2() { $directions = eF_getTableData("directions", "*", "", "name"); $result = eF_getTableData("lessons", "*"); $lessons = array(); foreach ($result as $value) { $lessons[$value['directions_ID']][] = new EfrontLesson($value); } $result = eF_getTableData("courses", "*"); $courses = array(); foreach ($result as $value) { $courses[$value['directions_ID']][] = new EfrontCourse($value); } if (sizeof($directions) == 0) { $this->tree = new RecursiveArrayIterator(array()); return; } foreach ($directions as $node) { //Assign previous direction ids as keys to the previousNodes array, which will be used for sorting afterwards $nodes[$node['id']] = new EfrontDirection($node); //We convert arrays to array objects, which is best for manipulating data through iterators $nodes[$node['id']]['lessons'] = $lessons[$node['id']]; $nodes[$node['id']]['courses'] = $lessons[$node['id']]; } $rejected = array(); $tree = $nodes; $count = 0; //$count is used to prevent infinite loops while (sizeof($tree) > 1 && $count++ < 1000) { //We will merge all branches under the main tree branch, the 0 node, so its size will become 1 foreach ($nodes as $key => $value) { if ($value['parent_direction_ID'] == 0 || in_array($value['parent_direction_ID'], array_keys($nodes))) { //If the unit parent is in the $nodes array keys - which are the unit ids- or it is 0, then it is valid $parentNodes[$value['parent_direction_ID']][] = $value; //Find which nodes have children and assign them to $parentNodes $tree[$value['parent_direction_ID']][$value['id']] = array(); //We create the "slots" where the node's children will be inserted. This way, the ordering will not be lost } else { $rejected = $rejected + array($value['id'] => $value); //Append units with invalid parents to $rejected list unset($nodes[$key]); //Remove the invalid unit from the units array, as well as from the parentUnits, in case a n entry for it was created earlier unset($parentNodes[$value['parent_direction_ID']]); } } if (isset($parentNodes)) { //If the unit was rejected, there won't be a $parentNodes array $leafNodes = array_diff(array_keys($nodes), array_keys($parentNodes)); //Now, it's easy to see which nodes are leaf nodes, just by subtracting $parentNodes from the whole set foreach ($leafNodes as $leaf) { $parent_id = $nodes[$leaf]['parent_direction_ID']; //Get the leaf's parent $tree[$parent_id][$leaf] = $tree[$leaf]; //Append the leaf to its parent's tree branch unset($tree[$leaf]); //Remove the leaf from the main tree branch unset($nodes[$leaf]); //Remove the leaf from the nodes set } unset($parentNodes); //Reset $parentNodes; new ones will be calculated at the next loop } } if (sizeof($tree) > 0 && !isset($tree[0])) { //This is a special case, where only one node exists in the tree $tree = array($tree); } foreach ($tree as $key => $value) { if ($key != 0) { $rejected[$key] = $value; } } if (sizeof($rejected) > 0) { //Append rejected nodes to the end of the tree array, updating their parent/previous information foreach ($rejected as $key => $value) { eF_updateTableData("directions", array("parent_direction_ID" => 0), "id=" . $key); $value['parent_direction_ID'] = 0; $tree[0][] = $value; } } $this->tree = new RecursiveArrayIterator($tree[0]); }
//@todo: remove package_ID from $_SESSION, beware package_ID is needed in lms_commit if (isset($_SESSION['package_ID']) && !$_GET['commit_lms']) { unset($_SESSION['package_ID']); } try { if (isset($_GET['view_unit']) && eF_checkParameter($_GET['view_unit'], 'id')) { $currentContent = new EfrontContentTree($currentLesson); //Initialize content $currentContent->markSeenNodes($currentUser); if ($currentLesson->lesson['access_limit']) { $result = eF_getTableData("users_to_lessons", "access_counter", "users_LOGIN='******'login'] . "' and lessons_ID='" . $currentLesson->lesson['id'] . "'"); if ($result[0]['access_counter'] >= $currentLesson->lesson['access_limit']) { eF_redirect(basename($_SERVER['PHP_SELF']) . "?ctg=lessons&message=" . urlencode(_ACCESSDEPLETED) . "&message_type=failure"); } else { if (!$_SESSION['visited_lesson'][$currentLesson->lesson['id']]) { eF_updateTableData("users_to_lessons", array('access_counter' => $result[0]['access_counter'] + 1), "users_LOGIN='******'login'] . "' and lessons_ID='" . $currentLesson->lesson['id'] . "'"); $_SESSION['visited_lesson'][$currentLesson->lesson['id']] = 1; } } } if ($currentUser->coreAccess['content'] == 'hidden') { eF_redirect("" . basename($_SERVER['PHP_SELF']) . "?ctg=control_panel&message=" . urlencode(_UNAUTHORIZEDACCESS) . "&message_type=failure"); } if (!$currentLesson || !$currentContent) { eF_redirect("" . basename($_SERVER['PHP_SELF'])); } $currentUnit = $currentContent->seekNode($_GET['view_unit']); //Initialize current unit //The content tree does not hold data, so assign this unit its data $unitData = new EfrontUnit($_GET['view_unit']); //$_SESSION['s_time_target'] = array($_GET['view_unit'] => 'unit');
/** * The main functionality * * (non-PHPdoc) * @see libraries/EfrontModule#getModule() */ public function getModule() { $smarty = $this->getSmartyVar(); $smarty->assign("T_MODULE_BASEDIR", $this->moduleBaseDir); $smarty->assign("T_MODULE_BASELINK", $this->moduleBaseLink); $smarty->assign("T_MODULE_BASEURL", $this->moduleBaseUrl); $smarty->assign("T_TABLE_OPTIONS", array(array('image' => $this->moduleBaseLink . 'img/order.png', 'text' => _MODULE_SECURITY_RECHECKLOCALFILES, 'href' => $this->moduleBaseUrl . '&delete_local_list=1'), array('image' => $this->moduleBaseLink . 'img/refresh.png', 'text' => _MODULE_SECURITY_RECHECKSERVERFILES, 'href' => $this->moduleBaseUrl . '&delete_remote_list=1'), array('image' => $this->moduleBaseLink . 'img/rules.png', 'text' => _MODULE_SECURITY_RESETIGNORELIST, 'href' => $this->moduleBaseUrl . '&delete_ignore_list=1'))); if (isset($_GET['download_ignore_list'])) { try { $file = new EfrontFile($this->getIgnoreListName()); $file->sendFile(true); } catch (Exception $e) { $this->setMessageVar('The list is empty', 'failure'); } } else { if ($_GET['delete_remote_list']) { $file = new EfrontFile($this->getCachedRemoteListName()); $file->delete(); } else { if ($_GET['delete_local_list']) { $file = new EfrontFile($this->getLocalListName()); $file->delete(); } else { if ($_GET['delete_ignore_list']) { try { $file = new EfrontFile($this->getIgnoreListName()); $file->delete(); } catch (Exception $e) { } } } } } if (isset($_GET['download'])) { $_GET['download'] = base64_decode($_GET['download']); } $form = new HTML_QuickForm("demo_form", "post", $this->moduleBaseUrl . "&type=" . $_GET['type'], "", null, true); switch ($_GET['type']) { case 'install': $form->addElement('submit', 'submit_delete_install', _MODULE_SECURITY_DELETEINSTALLDIRECTORY, 'class = "flatButton"'); break; case 'magic_quotes_gpc': break; case 'default_accounts': $form->addElement('submit', 'submit_deactivate', _MODULE_SECURITY_DEACTIVATEDEFAULTACCOUNTS, 'class = "flatButton" title = "Click this to deactivate these accounts"'); break; case 'changed_files': list($changed_files, $new_files) = $this->checksumCheck(); $smarty->assign("T_CHANGED_FILES", $changed_files); if (isset($_GET['download']) && in_array($_GET['download'], array_keys($changed_files)) && $_GET['download'] != 'libraries/configuration.php') { try { $file = new EfrontFile(G_ROOTPATH . $_GET['download']); $file->sendFile(true); exit; } catch (Exception $e) { $this->setMessageVar(_MODULE_SECURITY_FILECOULDNOTBEDELETED, 'failure'); } } else { if (isset($_GET['ignore']) && in_array($_GET['ignore'], array_keys($changed_files))) { $this->addToIgnoreList($_GET['ignore']); echo json_encode(array('success' => true)); exit; } } $form->addElement('submit', 'submit_recheck', _MODULE_SECURITY_RECHECKFILES, 'class = "flatButton" '); $form->addElement('submit', 'reset_ignore_list', _MODULE_SECURITY_RESETIGNORELIST, 'class = "flatButton" '); $form->addElement('submit', 'ignore_changed_all', _MODULE_SECURITY_IGNOREALL, 'class = "flatButton" '); break; case 'new_files': list($changed_files, $new_files) = $this->checksumCheck(); if (isset($_GET['download']) && in_array($_GET['download'], array_keys($new_files)) && $_GET['download'] != 'libraries/configuration.php') { try { $file = new EfrontFile(G_ROOTPATH . $_GET['download']); $file->sendFile(true); exit; } catch (Exception $e) { $this->setMessageVar(_MODULE_SECURITY_FILECOULDNOTBEDELETED, 'failure'); } } else { if (isset($_GET['ignore']) && in_array($_GET['ignore'], array_keys($new_files))) { $this->addToIgnoreList($_GET['ignore']); } else { if (isset($_GET['delete']) && in_array($_GET['delete'], array_keys($new_files))) { try { $file = new EfrontFile(G_ROOTPATH . $_GET['delete']); $file->delete(); } catch (Exception $e) { } $file = new EfrontFile($this->getLocalListName()); $file->delete(); list($changed_files, $new_files) = $this->checksumCheck(); } } } $smarty->assign("T_NEW_FILES", $new_files); $form->addElement('submit', 'submit_recheck', _MODULE_SECURITY_RECHECKFILES, 'class = "flatButton" '); $form->addElement('submit', 'reset_ignore_list', _MODULE_SECURITY_RESETIGNORELIST, 'class = "flatButton" '); $form->addElement('submit', 'ignore_new_all', _MODULE_SECURITY_IGNOREALL, 'class = "flatButton" '); break; default: $smarty->assign("T_SECURITY_FEEDS", $this->getRssFeeds()); try { $smarty->assign("T_LOCAL_ISSUES", $this->checkLocalIssues()); } catch (Exception $e) { $this->setMessageVar($e->getMessage(), 'failure'); } break; } if ($form->isSubmitted() && $form->validate()) { try { $values = $form->exportValues(); if ($values['submit_recheck']) { $file = new EfrontFile($this->getLocalListName()); $file->delete(); eF_redirect($this->moduleBaseUrl . '&type=' . $_GET['type'] . '&message=' . urlencode(_OPERATIONCOMPLETEDSUCCESSFULLY) . '&message_type=success'); } else { if ($values['submit_delete_install']) { file_get_contents(G_SERVERNAME . 'index.php?delete_install=1'); eF_redirect($this->moduleBaseUrl . '&type=' . $_GET['type'] . '&message=' . urlencode(_OPERATIONCOMPLETEDSUCCESSFULLY) . '&message_type=success'); } else { if ($values['submit_deactivate']) { $result = eF_updateTableData("users", array('active' => 0), "(login = '******' and password = '******') or (login = '******' and password = '******')"); eF_redirect($this->moduleBaseUrl . '&message=' . urlencode(_OPERATIONCOMPLETEDSUCCESSFULLY) . '&message_type=success'); } else { if ($values['reset_ignore_list']) { try { $file = new EfrontFile($this->getIgnoreListName()); $file->delete(); eF_redirect($this->moduleBaseUrl . '&type=' . $_GET['type'] . '&message=' . urlencode(_OPERATIONCOMPLETEDSUCCESSFULLY) . '&message_type=success'); } catch (Exception $e) { $this->setMessageVar(_MODULE_SECURITY_THELISTISEMTPY, 'failure'); } } else { if ($values['ignore_new_all']) { list($changed_files, $new_files) = $this->checksumCheck(); foreach ($new_files as $key => $value) { $this->addToIgnoreList($key); } eF_redirect($this->moduleBaseUrl . '&type=new_files&message=' . urlencode(_OPERATIONCOMPLETEDSUCCESSFULLY) . '&message_type=success'); } else { if ($values['ignore_changed_all']) { list($changed_files, $new_files) = $this->checksumCheck(); foreach ($changed_files as $key => $value) { $this->addToIgnoreList($key); } eF_redirect($this->moduleBaseUrl . '&type=changed_files&message=' . urlencode(_OPERATIONCOMPLETEDSUCCESSFULLY) . '&message_type=success'); } } } } } } } catch (Exception $e) { $smarty->assign("T_EXCEPTION_TRACE", $e->getTraceAsString()); $message = $e->getMessage() . ' (' . $e->getCode() . ') <a href = "javascript:void(0)" onclick = "eF_js_showDivPopup(event, \'' . _ERRORDETAILS . '\', 2, \'error_details\')">' . _MOREINFO . '</a>'; $this->setMessageVar($message, 'failure'); } } $renderer = prepareFormRenderer($form); $smarty->assign('T_SECURITY_FORM', $renderer->toArray()); //$feeds = $this->getRssFeeds(true, false); //$smarty->assign("T_SECURITY_FEEDS", $feeds); return true; }
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; }
} } } if ($currentUnit['options']['complete_unit_setting'] == EfrontUnit::COMPLETION_OPTIONS_ACCEPTTERMSCOMPLETION) { $accept_term_message = _ACCEPTTERMCOMPLETIONMESSAGE; if ($accept_term_message) { $smarty->assign("T_ACCEPT_TERM_COMPLETION_MESSAGE", $accept_term_message); $res = eF_getTableData("users_to_content", "pending", "users_LOGIN='******'login'] . "' and content_ID=" . $currentUnit['id']); if (sizeof($_POST) > 0) { try { if ($_POST['accept_terms'] === 'true') { $currentUser->setSeenUnit($currentUnit, $currentLesson, true); echo 'accept'; } elseif ($_POST['accept_terms'] === 'false') { if (sizeof($res) > 0) { eF_updateTableData("users_to_content", array('pending' => 1), "users_LOGIN='******'login'] . "' and content_ID=" . $currentUnit['id']); } else { eF_insertTableData("users_to_content", array("pending" => 1, "users_LOGIN" => $currentUser->user['login'], "content_ID" => $currentUnit['id'], "lessons_ID" => $currentLesson->lesson['id'])); } } } catch (Exception $e) { //handleAjaxExceptions($e); } exit; } elseif (in_array($currentUnit['id'], array_keys($seenContent))) { $smarty->assign("T_ACCEPT_TERM_COMPLETION_CHECKED", 'accepted'); } elseif ($res[0]['pending']) { $smarty->assign("T_ACCEPT_TERM_COMPLETION_CHECKED", 'rejected'); } } }
$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) { handleNormalFlowExceptions($e); } } } $renderer = prepareFormRenderer($form);
/** * Assign a skill to this lesson or update an existing skill description * * This function is used to correlate a skill to the lesson - if the * lesson is completed then this skill is assigned to the user that completed it * * <br/>Example: * <code> * $lesson -> assignSkill(2, "Beginner PHP knowledge"); // The lesson will offer skill with id 2 and "Beginner PHP knowledge" * </code> * * @param $skill_ID the id of the skill to be assigned * @return boolean true/false * @since 3.5.0 * @access public */ public function assignSkill($skill_ID, $specification) { $this->getSkills(); // Check if the skill is not assigned as offered by this lesson if ($this->skills[$skill_ID]['lesson_ID'] == "") { if ($ok = eF_insertTableData("module_hcd_lesson_offers_skill", array("skill_ID" => $skill_ID, "lesson_ID" => $this->lesson['id'], "specification" => $specification))) { $this->skills[$skill_ID]['lesson_ID'] = $this->lesson['id']; $this->skills[$skill_ID]['specification'] = $specification; } else { throw new EfrontLessonException(_EMPLOYEESRECORDCOULDNOTBEUPDATED, EfrontLessonException::DATABASE_ERROR); } } else { if ($ok = eF_updateTableData("module_hcd_lesson_offers_skill", array("specification" => $specification), "skill_ID = '" . $skill_ID . "' AND lesson_ID = '" . $this->lesson['id'] . "'")) { $this->skills[$skill_ID]['specification'] = $specification; } else { throw new EfrontLessonException(_EMPLOYEESRECORDCOULDNOTBEUPDATED, EfrontLessonException::DATABASE_ERROR); } } return true; }
/** * Repair tree * * This function is the "last resort": It rearranges all the * lesson's units so that they are visible to the system. It * revokes any succession information and creates a flat * tree, where units are arbitrarily sorted. * <br/>Example: * <code> * $content = new EfrontContentTree(4); //Create the content tree for lesson with id 4 * $content -> repairTree(); //Repair tree. Now, the content tree will be flat, containing all the lesson units * </code> * * @since 3.5.0 * @access public * @static */ public function repairTree() { $units = eF_getTableData("content", "*", "lessons_ID=" . $this->lessonId); //Get all lesson units $previous = 0; foreach ($units as $key => $value) { eF_updateTableData("content", array("previous_content_ID" => $previous, "parent_content_ID" => 0), "id=" . $value['id']); //Update succession information and erase parent information $previous = $value['id']; } }
protected function importData($line, $type, $data) { //pr($line);exit; try { switch ($type) { case "users": $newUser = EfrontUser::createUser($data); $this->log["success"][] = _LINE . " {$line}: " . _IMPORTEDUSER . " " . $newUser->login; break; case "users_to_courses": //Check if a user exists and whether it has the same case $userFound = false; if (!in_array($data['users_login'], $this->allUserLogins)) { //For case-insensitive matches foreach ($this->allUserLogins as $login) { if (mb_strtolower($data['users_login']) == mb_strtolower($login)) { $data['users_login'] = $login; $userFound = true; } } } else { $userFound = true; } if ($userFound) { $courses_name = trim($data['course_name']); $courses_ID = $this->getCourseByName($courses_name); unset($data['course_name']); if ($courses_ID) { foreach ($courses_ID as $course_ID) { $data['courses_ID'] = $course_ID; $course = new EfrontCourse($course_ID); if (is_null($this->course_users[$course_ID])) { $result = eF_getTableDataFlat("users_to_courses", "users_LOGIN", "courses_ID={$course_ID} AND archive=0"); $this->course_users[$course_ID] = array_combine($result['users_LOGIN'], $result['users_LOGIN']); } if (isset($this->course_users[$course_ID][$data['users_login']])) { throw new Exception("User is already assigned to the course", self::USER_TO_COURSE_EXISTS); } //$course -> addUsers($data['users_login'], (isset($data['user_type']) && $data['user_type']?$data['user_type']:"student")); $course->addUsers($data['users_login'], isset($data['user_type']) ? $data['user_type'] : "student"); $where = "users_login = '******'users_login'] . "' AND courses_ID = " . $data['courses_ID']; $data['completed'] ? $data['completed'] = 1 : ($data['completed'] = 0); EfrontCourse::persistCourseUsers($data, $where, $data['courses_ID'], $data['users_login']); if ($data['active']) { $course->confirm($data['users_login']); } else { $course->unconfirm($data['users_login']); } $this->course_users[$course_ID][$data['users_login']] = $data['users_login']; $this->log["success"][] = _LINE . " {$line}: " . _NEWCOURSEASSIGNMENT . " " . $courses_name . " - " . $data['users_login']; } } else { if ($courses_name != "") { $course = EfrontCourse::createCourse(array("name" => $courses_name)); $this->log["success"][] = _LINE . " {$line}: " . _NEWCOURSE . " " . $courses_name; $course->addUsers($data['users_login'], isset($data['user_type']) ? $data['user_type'] : "student"); $courses_ID = $course->course['id']; $this->courseNamesToIds[$courses_name] = array($courses_ID); $where = "users_login = '******'users_login'] . "' AND courses_ID = " . $courses_ID; EfrontCourse::persistCourseUsers($data, $where, $courses_ID, $data['users_login']); if ($data['active']) { $course->confirm($data['users_login']); } else { $course->unconfirm($data['users_login']); } $this->log["success"][] = _LINE . " {$line}: " . _NEWCOURSEASSIGNMENT . " " . $courses_name . " - " . $data['users_login']; } else { $this->log["failure"][] = _LINE . " {$line}: " . _COULDNOTFINDCOURSE . " " . $courses_name; } } } else { $this->log["failure"][] = _LINE . " {$line}: " . _USERDOESNOTEXIST . ": " . $data['users_login']; } break; case "users_to_lessons": //Check if a user exists and whether it has the same case $userFound = false; if (!in_array($data['users_login'], $this->allUserLogins)) { //For case-insensitive matches foreach ($this->allUserLogins as $login) { if (mb_strtolower($data['users_login']) == mb_strtolower($login)) { $data['users_login'] = $login; $userFound = true; } } } else { $userFound = true; } if ($userFound) { $lessons_name = trim($data['lesson_name']); $lessons_ID = $this->getLessonByName($lessons_name); unset($data['lesson_name']); if ($lessons_ID) { foreach ($lessons_ID as $lesson_ID) { $data['lessons_ID'] = $lesson_ID; $lesson = new EfrontLesson($lesson_ID); if (is_null($this->lesson_users[$lesson_ID])) { $result = eF_getTableDataFlat("users_to_lessons", "users_LOGIN", "lessons_ID={$lesson_ID} AND archive=0"); $this->lesson_users[$lesson_ID] = array_combine($result['users_LOGIN'], $result['users_LOGIN']); } if (isset($this->lesson_users[$lesson_ID][$data['users_login']])) { throw new Exception("User is already assigned to the lesson", self::USER_TO_LESSON_EXISTS); } if (!$lesson->lesson['course_only']) { $lesson->addUsers($data['users_login'], isset($data['user_type']) ? $data['user_type'] : "student"); } $data['completed'] ? $data['completed'] = 1 : ($data['completed'] = 0); eF_updateTableData("users_to_lessons", $data, "users_login = '******'users_login'] . "' AND lessons_ID = " . $data['lessons_ID']); if (!$lesson->lesson['course_only']) { if ($data['active']) { $lesson->confirm($data['users_login']); } else { $lesson->unconfirm($data['users_login']); } } $this->log["success"][] = _LINE . " {$line}: " . _NEWLESSONASSIGNMENT . " " . $lessons_name . " - " . $data['users_login']; } } else { if ($lessons_name != "") { $lesson = EfrontLesson::createLesson(array("name" => $lessons_name, 'course_only' => false)); $this->log["success"][] = _LINE . " {$line}: " . _NEWLESSON . " " . $lessons_name; $lesson->addUsers($data['users_login'], isset($data['user_type']) ? $data['user_type'] : "student"); $lessons_ID = $lesson->lesson['id']; $this->lessonNamesToIds[$lessons_name] = array($lessons_ID); eF_updateTableData("users_to_lessons", $data, "users_login = '******'users_login'] . "' AND lessons_ID = " . $lessons_ID); if ($data['active']) { $lesson->confirm($data['users_login']); } else { $lesson->unconfirm($data['users_login']); } $this->log["success"][] = _LINE . " {$line}: " . _NEWLESSONASSIGNMENT . " " . $lessons_name . " - " . $data['users_login']; } else { $this->log["failure"][] = _LINE . " {$line}: " . _COULDNOTFINDLESSON . " " . $lessons_name; } } } else { $this->log["failure"][] = _LINE . " {$line}: " . _USERDOESNOTEXIST . ": " . $data['users_login']; } break; case "users_to_groups": //debug(); $groups_ID = $this->getGroupByName($data['groups.name']); $group_name = $data['groups.name']; unset($data['groups.name']); foreach ($groups_ID as $group_ID) { $data['groups_ID'] = $group_ID; $group = new EfrontGroup($group_ID); $group->addUsers(array($data['users_login'])); $this->log["success"][] = _LINE . " {$line}: " . _NEWGROUPASSIGNMENT . " " . $group_name . " - " . $data['users_login']; } break; //debug(false); #cpp#ifdef ENTERPRISE //debug(false); #cpp#ifdef ENTERPRISE case "employees": $this->cleanUpEmptyValues($data); // a bit customized here, based on the fact that employees are always created together AFTER users (so the object should exist) eF_updateTableData("module_hcd_employees", $data, "users_login='******'users_login'] . "'"); break; case "branches": // If no father defined - root, else we may need to create the father first $data['father_branch_ID'] = $this->getFatherBranchId($data['father_branch_name']); $father_name = $data['father_branch_name']; $branch_ID = $this->getBranchByName($data['name']); $branch_name = $data['name']; if (sizeof($branch_ID) > 0 && $data['name'] != $data['father_branch_name']) { //TODO unset($data['father_branch_name']); $data['branch_ID'] = $branch_ID[0]; throw new EfrontBranchException(_BRANCHALREADYEXISTS, EfrontBranchException::BRANCH_EXISTS); } else { unset($data['father_branch_name']); $data['url'] = EfrontBranch::getBranchUrl($data['name']); $branch = EfrontBranch::createBranch($data); $this->setBranchByName($branch_name, $branch->branch['branch_ID']); } $this->log["success"][] = _LINE . " {$line}: " . _NEWBRANCH . " " . $branch_name; break; case "job_descriptions": if ($data['branch_name'] == "") { $data['branch_ID'] = "all"; // this denotes to the createJob class to put the job in all branches } else { $data['branch_ID'] = $this->getBranchByName($data['branch_name']); if (sizeof($data['branch_ID']) > 0) { //TODO: maybe different handling when multiple branches are found $data['branch_ID'] = $data['branch_ID'][0]; } else { throw new EfrontJobException(_BRANCHDESIGNATEDFORTHISJOBDESCRIPTIONDOESNOTEXIST, EfrontJobException::BRANCH_NOT_EXISTS); } } unset($data['branch_name']); if ($data['description'] != "") { $job_ID = $this->getJobByName($data['description']); if (sizeof($job_ID) > 0) { $data['job_description_ID'] = $job_ID[0]; throw new EfrontJobException(_JOBDESCRIPTIONEXISTSALREADY, EfrontJobException::JOB_ALREADY_EXISTS); } else { EfrontJob::createJob($data); $this->log["success"][] = _LINE . " {$line}: " . _NEWJOB . " " . $data['description']; } } else { $this->log["failure"][] = _LINE . " {$line}: " . _NOTITLEPROVIDEDFORNEWJOB; } break; case "skills": if ($data['skill_category'] == "") { throw new EfrontSkillException(_MISSINGSKILLCATEGORY, EfrontSkillException::INVALID_SKILL_CATEGORY); } else { $data['categories_ID'] = $this->getSkillCategoryByName($data['skill_category']); if ($data['categories_ID'][0] != "") { $data['categories_ID'] = $data['categories_ID'][0]; } else { // create skill category $data['categories_ID'] = eF_insertTableData("module_hcd_skill_categories", array('description' => $data['skill_category'])); $this->setSkillCategoryByName($data['skill_category'], $data['categories_ID']); } } unset($data['skill_category']); $skill_ID = $this->getSkillByName($data['description']); if ($skill_ID) { //TODO: another double issue $data['skill_ID'] = $skill_ID[0]; throw new EfrontSkillException(_SKILLALREADYEXISTS, EfrontSkillException::SKILL_EXISTS); } else { EfrontSkill::createSkill($data); $this->log["success"][] = _LINE . " {$line}: " . _NEWSKILL . " " . $data['description']; } break; case "users_to_jobs": // Get user $user = EfrontUserFactory::factory($data["users_login"]); // Get branch id $branch_ID = $this->getBranchByName($data['branch_name']); $branch_name = $data['branch_name']; if ($branch_ID[0] != "") { if (sizeof($branch_ID) == 1) { $branch_ID = $branch_ID[0]; } else { throw new EfrontBranchException(_BRANCHNAMEAMBIGUOUS, EfrontBranchException::BRANCH_AMBIGUOUS); } } else { throw new EfrontBranchException(_BRANCHDOESNOTEXIST, EfrontBranchException::BRANCH_NOT_EXISTS); } // Get job id $job_name = $data['description']; if ($job_name != "") { $new_job_description_ID = eF_getJobDescriptionId($job_name, $branch_ID); } else { throw new EfrontJobException(_MISSING_JOB_DESCRIPTION, EfrontJobException::MISSING_JOB_DESCRIPTION); } // Get hcd employee object if ($data['supervisor']) { $employee = new EfrontSupervisor(array("users_login" => $data["users_login"])); $position = 1; } else { $employee = new EfrontEmployee(array("users_login" => $data["users_login"])); $position = 0; } // Assign job try { $employee->addJob($user, $new_job_description_ID, $branch_ID, $position); $this->log["success"][] = _LINE . " {$line}: " . _NEWJOBASSIGNMENT . " " . $data["users_login"] . " - (" . $branch_name . " - " . $job_name . ") "; } catch (Exception $e) { if ($this->options['replace_existing']) { $employee->removeJob($new_job_description_ID); $employee->addJob($user, $new_job_description_ID, $branch_ID, $position); $this->log["success"][] = _LINE . " {$line}: " . _NEWJOBASSIGNMENT . " " . $data["users_login"] . " - (" . $branch_name . " - " . $job_name . ") "; } } break; case "users_to_skills": $skill_ID = $this->getSkillByName($data['description']); $skill_name = $data['description']; if ($skill_ID[0] != "") { if (sizeof($skill_ID) == 1) { $skill_ID = $skill_ID[0]; } else { throw new EfrontSkillException(_SKILLNAMEAMBIGUOUS, EfrontSkillException::SKILL_AMBIGUOUS); } } else { throw new EfrontSkillException(_SKILLDOESNOTEXIST, EfrontSkillException::SKILL_NOT_EXISTS); } $skill = new EfrontSkill($skill_ID); $skill->assignToEmployee($data['users_login'], $data['specification']); $this->log["success"][] = _LINE . " {$line}: " . _NEWSKILLASSIGNMENT . " " . $data["users_login"] . " - " . $skill_name; break; case "courses_to_branches": $branchId = $this->getBranchByName($data['branch_name']); if (!$branchId[0]) { $fields = array('name' => $data['branch_name'], 'url' => EfrontBranch::getBranchUrl($data['branch_name'])); $branch = EfrontBranch::createBranch($fields); } else { $branch = new EfrontBranch($branchId[0]); } $courseId = $this->getCourseByName($data['course_name']); if ($courseId[0]) { $branch->addCoursesToBranch($courseId[0]); } $this->log["success"][] = _LINE . " {$line}: " . _NEWCOURSETOBRANCHASSIGNMENT . " " . $data['course_name'] . " - " . $data['branch_name']; break; #cpp#endif } } catch (Exception $e) { if ($this->options['replace_existing']) { if ($this->isAlreadyExistsException($e->getCode(), $type)) { $this->updateExistingData($line, $type, $data); } else { $this->log["failure"][] = _LINE . " {$line}: " . $e->getMessage(); // ." ". str_replace("\n", "<BR>", $e->getTraceAsString()); } } else { $this->log["failure"][] = _LINE . " {$line}: " . $e->getMessage(); // ." ". str_replace("\n", "<BR>", $e->getTraceAsString()); } } }
/** * The main functionality * * (non-PHPdoc) * @see libraries/EfrontModule#getModule() */ public function getModule() { $smarty = $this->getSmartyVar(); $currentUser = $this->getCurrentUser(); $directionsTree = new EfrontDirectionsTree(); $directionsPaths = $directionsTree->toPathString(); $smarty->assign("T_MODULE_OUTLOOK_INVITATION_DIRECTION_PATHS", $directionsPaths); $temp = eF_getTableData("module_outlook_invitation as m,courses as c", "m.*,c.name,c.directions_ID", "m.courses_ID=c.id"); $events = array(); foreach ($temp as $value) { $events[$value['courses_ID']] = $value; } if (isset($_GET['delete_event']) && eF_checkParameter($_GET['delete_event'], 'id') && in_array($_GET['delete_event'], array_keys($events))) { try { $event = $events[$_GET['delete_event']]; $course = new EfrontCourse($event['courses_ID']); $users = $course->getCourseUsers(array('active' => true, archive => false, 'return_objects' => false)); $recipients = array(); foreach ($users as $value) { $recipients[] = $value['email']; } $this->cancelInvitation($course->course['id'], $recipients); eF_deleteTableData("module_outlook_invitation", "courses_ID=" . $_GET['delete_event']); } catch (Exception $e) { header("HTTP/1.0 500 "); echo $e->getMessage() . ' (' . $e->getCode() . ')'; } exit; } if ($_SESSION['s_type'] != 'administrator') { $userCourses = $currentUser->getUserCourses(array('archive' => 0, 'active' => true, 'return_objects' => false)); if (G_VERSIONTYPE == 'enterprise') { if ($_SESSION['s_current_branch']) { $result = eF_getTableData("module_hcd_course_to_branch", "courses_ID", "branches_ID='{$_SESSION['s_current_branch']}'"); } else { if ($currentUser->aspects['hcd']->isSupervisor()) { $result = eF_getTableData("module_hcd_course_to_branch", "courses_ID", "branches_ID in (select branches_ID from module_hcd_employee_works_at_branch where users_login='******'login']}' and supervisor=1)"); } } $branchCourses = array(); foreach ($result as $value) { $branchCourses[$value['courses_ID']] = $value['courses_ID']; } foreach ($events as $key => $value) { if (!isset($branchCourses[$key]) && !isset($userCourses[$key])) { unset($events[$key]); } } } else { foreach ($events as $key => $value) { if (!isset($userCourses[$key])) { unset($events[$key]); } } } } if (!isset($_GET['course'])) { $dataSource = $events; $tableName = 'outlookInvitationsTable'; 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')) { $sort = $_GET['sort']; isset($_GET['order']) && $_GET['order'] == 'desc' ? $order = 'desc' : ($order = 'asc'); } else { $sort = 'login'; } $dataSource = eF_multiSort($dataSource, $sort, $order); $smarty->assign("T_TABLE_SIZE", sizeof($dataSource)); if (isset($_GET['filter'])) { $dataSource = eF_filterData($dataSource, $_GET['filter']); } if (isset($_GET['limit']) && eF_checkParameter($_GET['limit'], 'int')) { isset($_GET['offset']) && eF_checkParameter($_GET['offset'], 'int') ? $offset = $_GET['offset'] : ($offset = 0); $dataSource = array_slice($dataSource, $offset, $limit); } $smarty->assign("T_DATA_SOURCE", $dataSource); } else { $course = new EfrontCourse($_GET['course']); $form = new HTML_QuickForm("import_outlook_invitation_form", "post", $this->moduleBaseUrl . "&course={$course->course['id']}&add_event=1" . (isset($_GET['popup']) ? '&popup=1' : ''), "", null, true); $form->registerRule('checkParameter', 'callback', 'eF_checkParameter'); //Register this rule for checking user input with our function, eF_checkParameter $form->addElement('text', 'email', _SENDER, 'class = "inputText"'); $form->addElement('text', 'location', _LOCATION, 'class = "inputText"'); $form->addElement('text', 'subject', _SUBJECT, 'class = "inputText"'); $form->addElement('textarea', 'description', _DESCRIPTION, 'class = "inputTestTextarea" style = "width:80%;height:6em;"'); //$form -> addElement('checkbox', 'calendar', _MODULE_OUTLOOK_INVITATION_CREATE_CALENDAR); //$form -> addElement('static', 'static', _MODULE_OUTLOOK_INVITATION_INFO); $form->addElement('submit', 'submit_event_all', _MODULE_OUTLOOK_INVITATION_SENDALL, 'class=flatButton'); $form->addElement('submit', 'submit_event_new', _MODULE_OUTLOOK_INVITATION_SENDNEW, 'class=flatButton'); if (empty($events[$course->course['id']])) { //new invitation $currentEvent = null; $form->setDefaults(array('email' => $currentUser->user['email'], 'subject' => 'Invitation to attend training: ' . $course->course['name'])); } else { //existing invitation $currentEvent = $events[$course->course['id']]; $form->setDefaults(array('email' => $currentEvent['email'], 'description' => $currentEvent['description'], 'subject' => $currentEvent['subject'], 'location' => $currentEvent['location'])); } if ($form->isSubmitted() && $form->validate()) { try { $message = ""; // Set info to store into database $permanent_info = array("courses_ID" => $course->course['id'], "email" => $form->exportValue('email') ? $form->exportValue('email') : $GLOBALS['configuration']['system_email'], "location" => $form->exportValue('location'), "subject" => $form->exportValue('subject'), "description" => $form->exportValue('description')); if ($currentEvent) { $permanent_info['sequence'] = $currentEvent['sequence'] + 1; eF_updateTableData("module_outlook_invitation", $permanent_info, "courses_ID={$course->course['id']}"); } else { eF_insertTableData("module_outlook_invitation", $permanent_info); } if ($form->exportValue('submit_event_all')) { $users = $course->getCourseUsers(array('active' => true, archive => false, 'return_objects' => false)); $recipients = array(); foreach ($users as $value) { $recipients[] = $value['email']; } $this->sendInvitation($course->course['id'], $recipients); } // $smarty->assign('T_RELOAD', true); if (isset($_GET['popup'])) { $this->setMessageVar(_OPERATIONCOMPLETEDSUCCESSFULLY, 'success'); } else { eF_redirect($this->moduleBaseUrl . "&message=" . urlencode(_OPERATIONCOMPLETEDSUCCESSFULLY) . "&message_type=success"); } } catch (Exception $e) { $smarty->assign("T_EXCEPTION_TRACE", $e->getTraceAsString()); $this->setMessageVar($e->getMessage() . ' (' . $e->getCode() . ') <a href = "javascript:void(0)" onclick = "eF_js_showDivPopup(event, \'' . _ERRORDETAILS . '\', 2, \'error_details\')">' . _MOREINFO . '</a>', 'failure'); } } $form->setJsWarnings(_BEFOREJAVASCRIPTERROR, _AFTERJAVASCRIPTERROR); $form->setRequiredNote(_REQUIREDNOTE); $smarty->assign('T_MODULE_OUTLOOK_INVITATION_FORM', $form->toArray()); } $smarty->assign("T_MODULE_BASEDIR", $this->moduleBaseDir); $smarty->assign("T_MODULE_BASELINK", $this->moduleBaseLink); $smarty->assign("T_MODULE_BASEURL", $this->moduleBaseUrl); return true; }
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); } }
} catch (Exception $e) { $module->onUninstall(); $message = _PROBLEMINSERTINGPARSEDXMLVALUESORMODULEEXISTS; $message_type = 'failure'; //$dir = new EfrontDirectory(G_MODULESPATH.$module_folder.'/'); //$dir -> delete(); //eF_deleteFolder(G_MODULESPATH.$module_folder.'/'); } } else { // If the module is to be installed to a different than the existing folder that // already exists (like the directory name of another module) then the upgrade should // be aborted // If everything went ok, then upgrade the module if ($module->onUpgrade()) { // If the upgrade is successful, then update the modules table if (eF_updateTableData("modules", $fields, "className ='" . $_GET['upgrade'] . "'")) { // Delete the existing module folder $message = _MODULESUCCESFULLYUPGRADED; $message_type = 'success'; eF_redirect("" . basename($_SERVER['PHP_SELF']) . "?ctg=modules&message=" . urlencode($message) . "&message_type=" . $message_type); } else { $message = _PROBLEMINSERTINGPARSEDXMLVALUESORMODULEEXISTS; $message_type = 'failure'; } } else { $message = _MODULEDBERRORONUPGRADECHECKUPGRADEFUNCTION; $message_type = 'failure'; } } } } else {
/** * 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)); } } } } } } } }
} catch (EfrontFileException $e) { $posts[$key]['avatar'] = G_SYSTEMAVATARSPATH . "unknown_small.png"; $posts[$key]['avatar_width'] = 150; $posts[$key]['avatar_height'] = 150; } } // $forum = eF_getTableData("f_forums", "*", "id=".$topic[0]['f_forums_ID']); $smarty->assign("T_USER_POSTS", $user_posts); $smarty->assign("T_POSTS", $posts); $smarty->assign("T_TOPIC", $topic[0]); // $smarty -> assign("T_FORUM", $forum[0]); $current_topic[0]['viewed_by'] ? $viewed_by = unserialize($topic[0]['viewed_by']) : ($viewed_by = array()); if (!in_array($_SESSION['s_login'], $viewed_by)) { $viewed_by[] = $_SESSION['s_login']; $fields_update = array("views" => ++$topic[0]['views'], "viewed_by" => serialize($viewed_by)); eF_updateTableData("f_topics", $fields_update, "id=" . $_GET['topic']); } $parent_forum = $topic[0]['f_forums_ID']; } else { if (isset($_GET['poll']) && in_array($_GET['poll'], $legalPollValues)) { $result = eF_getTableData("f_users_to_polls", "*", "f_poll_ID=" . $_GET['poll'] . " and users_LOGIN='******'s_login'] . "'"); if (sizeof($result) > 0 || isset($_GET['action']) && $_GET['action'] == 'view' || $currentUser->coreAccess['forum'] && $currentUser->coreAccess['forum'] != 'change') { $smarty->assign("T_ACTION", "view"); } $poll_data = eF_getTableData("f_poll", "*", "id=" . $_GET['poll']); $parent_forum = $poll_data[0]['f_forums_ID']; $poll_data[0]['options'] = array_values(unserialize($poll_data[0]['options'])); //Array values are put here to reindex array, if the keys are not in order $poll_votes = eF_getTableData("f_users_to_polls", "*", "f_poll_ID=" . $_GET['poll']); $poll_data[0]['timestamp_end'] > time() ? $poll_data[0]['isopen'] = true : ($poll_data[0]['isopen'] = false); $votes_distrib = array();
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); }
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']); } }
/** * * @return unknown_type */ public function applySettings($mode = false) { $file = G_THEMESPATH . $this->{$this->entity}['path'] . 'theme.xml'; $fields = self::parseFile($file); if (is_file($fields['path'] . 'images/logo.png')) { $fields['options']['logo'] = $fields['path'] . 'images/logo.png'; } if (is_file($fields['path'] . 'images/favicon.png')) { $fields['options']['favicon'] = $fields['path'] . 'images/favicon.png'; } $fields = self::validateFields($fields); if ($mode == 'layout') { eF_updateTableData($this->entity, array('layout' => $fields['layout']), "id=" . $this->{$this->entity}['id']); } else { eF_updateTableData($this->entity, $fields, "id=" . $this->{$this->entity}['id']); } EfrontCache::getInstance()->deleteCache('themes'); }
//Insert a new entry that relates the current user with this SCO } } if ($credit && $seenUnit) { $scoUser->setSeenUnit($scoUnit, $scoLesson, true); } $remaining_times = -1; if ($credit) { if ($seenUnit || strtolower($fields['completion_status']) == 'failed' || strtolower($fields['lesson_status']) == 'failed') { $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'] . "'");
/** * Set seen unit * * This function is used to set the designated unit as seen or not seen, * according to $seen parameter. It also sets current unit to be the seen * unit, if we are setting a unit as seen. Otherwise, the current unit is * either leaved unchanged, or, if it matches the unset unit, it points * to another seen unit. * <br/>Example: * <code> * $user -> setSeenUnit(32, 2, true); //Set the unit with id 32 in lesson 2 as seen * $user -> setSeenUnit(32, 2, false); //Set the unit with id 32 in lesson 2 as not seen * </code> * From version 3.5.2 and above, this function also sets the lesson as completed, if the conditions are met * * @param mixed $unit The unit to set status for, can be an id or an EfrontUnit object * @param mixed $lesson The lesson that the unit belongs to, can be an id or an EfrontLesson object * @param boolean $seen Whether to set the unit as seen or not * @return boolean true if the lesson was completed as well * @since 3.5.0 * @access public */ public function setSeenUnit($unit, $lesson, $seen) { if (isset($this->coreAccess['content']) && $this->coreAccess['content'] != 'change') { //If user type is not plain 'student' and is not set to 'change' mode, do nothing return true; } if ($unit instanceof EfrontUnit) { //Check validity of $unit $unit = $unit['id']; } elseif (!eF_checkParameter($unit, 'id')) { throw new EfrontContentException(_INVALIDID . ": {$unit}", EfrontContentException::INVALID_ID); } if ($lesson instanceof EfrontLesson) { //Check validity of $lesson $lesson = $lesson->lesson['id']; } elseif (!eF_checkParameter($lesson, 'id')) { throw new EfrontLessonException(_INVALIDID . ": {$lesson}", EfrontLessonException::INVALID_ID); } $lessons = $this->getLessons(); if (!in_array($lesson, array_keys($lessons))) { //Check if the user is actually registered in this lesson throw new EfrontUserException(_USERDOESNOTHAVETHISLESSON . ": " . $lesson, EfrontUserException::USER_NOT_HAVE_LESSON); } $result = eF_getTableData("users_to_lessons", "done_content, current_unit", "users_LOGIN='******'login'] . "' and lessons_ID=" . $lesson); sizeof($result) > 0 ? $doneContent = unserialize($result[0]['done_content']) : ($doneContent = array()); $current_unit = 0; if ($seen) { $doneContent[$unit] = $unit; $current_unit = $unit; } else { if (isset($doneContent[$unit])) { //Because of Fatal error: Cannot unset string offsets error unset($doneContent[$unit]); } if ($unit == $result[0]['current_unit']) { sizeof($doneContent) ? $current_unit = end($doneContent) : ($current_unit = 0); } } sizeof($doneContent) ? $doneContent = serialize($doneContent) : ($doneContent = null); eF_updateTableData("users_to_lessons", array('done_content' => $doneContent, 'current_unit' => $current_unit), "users_LOGIN='******'login'] . "' and lessons_ID=" . $lesson); // $cacheKey = "user_lesson_status:lesson:".$lesson."user:"******"type" => EfrontEvent::CONTENT_COMPLETION, "users_LOGIN" => $this->user['login'], "lessons_ID" => $lesson, "entity_ID" => $current_unit)); } //Set the lesson as complete, if it can be. $completedLesson = false; $userProgress = EfrontStats::getUsersLessonStatus($lesson, $this->user['login']); $userProgress = $userProgress[$lesson][$this->user['login']]; //eF_updateTableData("users_to_lessons", array('progress' => $userProgress['overall_progress']), "users_LOGIN='******'login']."' and lessons_ID=".$lesson); if ($seen) { if ($userProgress['lesson_passed'] && !$userProgress['completed']) { $lesson = new EfrontLesson($lesson); if ($lesson->options['auto_complete']) { $userProgress['tests_avg_score'] ? $avgScore = $userProgress['tests_avg_score'] : ($avgScore = 100); $timestamp = _AUTOCOMPLETEDAT . ': ' . date("Y/m/d, H:i:s"); $this->completeLesson($lesson, $avgScore, $timestamp); $completedLesson = true; } } 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->onCompleteUnit($unit, $this->user['login']); } } return $completedLesson; }
} elseif (isset($_GET['add_evaluation']) || isset($_GET['edit_evaluation']) && eF_checkParameter($_GET['edit_evaluation'], 'id') && $_change_evaluations_) { $load_editor = true; $form = new HTML_QuickForm("evaluations_form", "post", basename($_SERVER['PHP_SELF']) . "?ctg=personal&user="******"&op=evaluations&" . (isset($_GET['edit_evaluation']) ? "&edit_evaluation=" . $_GET['edit_evaluation'] : "&add_evaluation=1"), "", null, true); $form->addElement('textarea', 'specification', _EVALUATIONCOMMENT, 'class = "simpleEditor" style = "width:400px;"'); $form->addElement('submit', 'submit', _SUBMIT, 'class = "flatButton"'); if (isset($_GET['edit_evaluation'])) { $evaluations = eF_getTableData("module_hcd_events", "*", "event_ID = '" . $_GET['edit_evaluation'] . "'"); $form->setDefaults(array('specification' => $evaluations[0]['specification'])); } try { if ($form->isSubmitted() && $form->validate()) { $evaluation_content = array('specification' => $form->exportValue('specification'), 'event_code' => 10, 'users_login' => $editedUser->user['login'], 'author' => $currentUser->user['login'], 'timestamp' => time()); if (isset($_GET['add_evaluation'])) { eF_insertTableData("module_hcd_events", $evaluation_content); } elseif (isset($_GET['edit_evaluation'])) { eF_updateTableData("module_hcd_events", $evaluation_content, "event_ID = '" . $_GET['edit_evaluation'] . "'"); } $message = _OPERATIONCOMPLETEDSUCCESSFULLY; $message_type = 'success'; } } catch (Exception $e) { handleNormalFlowExceptions($e); } $smarty->assign("T_EVALUATIONS_FORM", $form->toArray()); } else { $evaluations = eF_getTableData("module_hcd_events", "*", "users_login = '******'login'] . "' AND event_code >=10", "timestamp"); $smarty->assign("T_EVALUATIONS", $evaluations); } } #cpp#endif /*** Evaluations are deleted either by administrators or by the users who wrote them ***/