//These are the entities that will be automatically replaced in custom header/footer $systemEntities = array('logo.png', '#siteName', '#siteMoto', '#languages', '#path', '#version'); $smarty->assign("T_SYSTEM_ENTITIES", $systemEntities); //And these are the replacements of the above entities $systemEntitiesReplacements = array('{$T_LOGO}', '{$T_CONFIGURATION.site_name}', '{$T_CONFIGURATION.site_motto}', '{$smarty.capture.header_language_code}', '{$title}', '{$smarty.const.G_VERSION_NUM}'); $load_editor = true; $layout_form = new HTML_QuickForm("add_block_form", "post", basename($_SERVER['PHP_SELF']) . "?ctg=themes&theme=" . $layoutTheme->{$layoutTheme->entity}['id'] . (isset($_GET['edit_block']) ? '&edit_block=' . $_GET['edit_block'] : '&add_block=1') . (isset($_GET['theme_layout']) ? '&theme_layout=' . $_GET['theme_layout'] : ''), "", null, true); $layout_form->registerRule('checkParameter', 'callback', 'eF_checkParameter'); $layout_form->addElement('text', 'title', _BLOCKTITLE, 'class = "inputText"'); $layout_form->addElement('textarea', 'content', _BLOCKCONTENT, 'id="editor_data" class = "mceEditor" style = "width:100%;height:300px;"'); $layout_form->addElement('submit', 'submit_block', _SAVE, 'class = "flatButton"'); $layout_form->addRule('title', _THEFIELD . ' "' . _BLOCKTITLE . '" ' . _ISMANDATORY, 'required', null, 'client'); if (isset($_GET['edit_block'])) { $customBlocks[$_GET['edit_block']]['content'] = file_get_contents($basedir . $customBlocks[$_GET['edit_block']]['name'] . '.tpl'); $layout_form->setDefaults($customBlocks[$_GET['edit_block']]); $layout_form->freeze(array('name')); } if ($layout_form->isSubmitted() && $layout_form->validate()) { $values = $layout_form->exportValues(); if (isset($_GET['edit_block'])) { // not rename blocks by editing. It created many unused files $values['name'] = $customBlocks[$_GET['edit_block']]['name']; } else { $values['name'] = time(); //Use the timestamp as name } $block = array('name' => $values['name'], 'title' => $values['title']); file_put_contents($basedir . $values['name'] . '.tpl', applyEditorOffset($values['content'])); if (isset($_GET['edit_block'])) { $customBlocks[$_GET['edit_block']] = $block; } else {
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"; }
$editCourse = new EfrontCourse($_GET['edit_course']); $smarty->assign('T_EDIT_COURSE', $editCourse); $editCourse->course['price'] = number_format($editCourse->course['price'], 2, '.', ''); $form->setDefaults($editCourse->options); $form->setDefaults($editCourse->course); $form->setDefaults(array($editCourse->options['recurring'] . '_duration' => $editCourse->options['recurring_duration'])); if (G_VERSIONTYPE != 'community') { #cpp#ifndef COMMUNITY if (G_VERSIONTYPE != 'standard') { #cpp#ifndef STANDARD if ($editCourse->course['instance_source']) { $instanceSource = new EfrontCourse($editCourse->course['instance_source']); $courseInstances = $instanceSource->getInstances(); //Instances inherit course code and direction from their source $form->setDefaults(array("directions_ID" => $instanceSource->course['directions_ID'])); $form->freeze(array('directions_ID')); $smarty->assign("T_INSTANCE_SOURCE", $editCourse->course['instance_source']); } else { $courseInstances = $editCourse->getInstances(); $smarty->assign("T_INSTANCE_SOURCE", $editCourse->course['id']); } $smarty->assign("T_COURSE_INSTANCES", $courseInstances); } #cpp#endif } #cpp#endif } else { $form->setDefaults(array('active' => 1, 'show_catalog' => 1, 'price' => 0, 'languages_NAME' => $GLOBALS['configuration']['default_language'])); } if (!$_change_) { $form->freeze();
public function getSmartyTpl() { $smarty = $this->getSmartyVar(); $currentUser = $this->getCurrentUser(); $currentLesson = $this->getCurrentLesson(); $currentLessonID = $currentLesson->lesson['id']; if ($currentUser->getRole($this->getCurrentLesson()) == 'professor' || $currentUser->getRole($this->getCurrentLesson()) == 'student') { // XXX $workbookLessonName = _WORKBOOK_NAME . ' [' . $this->getWorkbookLessonName($currentLessonID) . ']'; $smarty->assign("T_WORKBOOK_LESSON_NAME", $workbookLessonName); $lessonQuestions = $this->getLessonQuestions($currentLessonID); $workbookLessons = $this->isWorkbookInstalledByUser($currentUser, $currentUser->getRole($this->getCurrentLesson()), $currentLessonID); $workbookItems = $this->getWorkbookItems($currentLessonID); $nonOptionalQuestionsNr = $this->getNonOptionalQuestionsNr($workbookItems); if ($nonOptionalQuestionsNr != 0) { $questionPercentage = (double) (100 / $nonOptionalQuestionsNr); $questionPercentage = round($questionPercentage, 2); } $isWorkbookPublished = $this->isWorkbookPublished($currentLessonID); } if ($currentUser->getRole($this->getCurrentLesson()) == 'student') { $workbookSettings = $this->getWorkbookSettings($currentLessonID); $smarty->assign("T_WORKBOOK_SETTINGS", $workbookSettings); } $smarty->assign("T_WORKBOOK_BASEURL", $this->moduleBaseUrl); $smarty->assign("T_WORKBOOK_BASELINK", $this->moduleBaseLink); global $popup; isset($popup) && $popup == 1 ? $popup_ = '&popup=1' : ($popup_ = ''); if (isset($_REQUEST['question_preview']) && $_REQUEST['question_preview'] == '1' && isset($_REQUEST['question_id']) && eF_checkParameter($_REQUEST['question_id'], 'id')) { $id = $_REQUEST['question_id']; if (!in_array($id, array_keys($lessonQuestions))) { // reused item $reusedQuestion = $this->getReusedQuestionDetails($id); $type = $reusedQuestion['type']; } else { $type = $lessonQuestions[$id]['type']; } echo $this->questionToHtml($id, $type); exit; } if (isset($_REQUEST['get_progress']) && $_REQUEST['get_progress'] == '1') { $isWorkbookCompleted = $this->isWorkbookCompleted($currentUser->user['login'], $currentLessonID, array_keys($workbookItems), $nonOptionalQuestionsNr); $studentProgress = $this->getStudentProgress($currentUser->user['login'], $currentLessonID); if ($isWorkbookCompleted['is_completed'] == 1) { $unitToComplete = $workbookSettings['unit_to_complete']; $result = eF_updateTableData('module_workbook_progress', array('completion_date' => time()), "lessons_ID='" . $currentLessonID . "' AND users_LOGIN='******'login'] . "'"); if ($unitToComplete != -1) { $currentUser->setSeenUnit($unitToComplete, $currentLessonID, true); } } echo $studentProgress . '-' . $isWorkbookCompleted['id']; exit; } if (isset($_GET['edit_settings']) && $_GET['edit_settings'] == '1') { if ($_SESSION['s_type'] != 'professor') { $message = _WORKBOOK_NOACCESS; $message_type = 'failure'; $this->setMessageVar(urlencode($message), $message_type); } $content = new EfrontContentTree($currentLessonID); $iterator = new EfrontNodeFilterIterator(new RecursiveIteratorIterator(new RecursiveArrayIterator($content->tree), RecursiveIteratorIterator::SELF_FIRST), array('ctg_type' => 'theory')); $contentOptions = $content->toHTMLSelectOptions($iterator); $contentOptions = array(-1 => '-------------') + $contentOptions; $workbookSettings = $this->getWorkbookSettings($currentLessonID); if ($isWorkbookPublished == 1) { $contentOptions[$workbookSettings['unit_to_complete']] = str_replace(' ', '', $contentOptions[$workbookSettings['unit_to_complete']]); $contentOptions[$workbookSettings['unit_to_complete']] = str_replace('»', '', $contentOptions[$workbookSettings['unit_to_complete']]); } $form = new HTML_QuickForm("edit_settings_form", "post", $this->moduleBaseUrl . "&edit_settings=1", "", null, true); $form->addElement('text', 'lesson_name', _WORKBOOK_LESSON_NAME, 'class="inputText"'); $form->addRule('lesson_name', _THEFIELD . ' "' . _WORKBOOK_LESSON_NAME . '" ' . _ISMANDATORY, 'required', null, 'client'); $form->addElement('advcheckbox', 'allow_print', _WORKBOOK_ALLOW_PRINT, null, 'class="inputCheckBox"', array(0, 1)); $form->addElement('advcheckbox', 'allow_export', _WORKBOOK_ALLOW_EXPORT, null, 'class="inputCheckBox"', array(0, 1)); $form->addElement('advcheckbox', 'edit_answers', _WORKBOOK_EDIT_ANSWERS, null, 'class="inputCheckBox"', array(0, 1)); $form->addElement('select', 'unit_to_complete', _WORKBOOK_UNIT_TO_COMPLETE, $contentOptions); $form->addElement('submit', 'submit', _UPDATE, 'class="flatButton"'); if ($isWorkbookPublished == 1) { $form->freeze('unit_to_complete'); } $form->setDefaults($workbookSettings); if ($form->isSubmitted() && $form->validate()) { $values = $form->exportValues(); $fields = array("lesson_name" => $values['lesson_name'], "allow_print" => $values['allow_print'], "allow_export" => $values['allow_export'], "edit_answers" => $values['edit_answers'], "unit_to_complete" => $values['unit_to_complete']); if (eF_updateTableData("module_workbook_settings", $fields, "id=" . $workbookSettings['id'])) { $smarty->assign("T_WORKBOOK_MESSAGE", _WORKBOOK_SETTINGS_SUCCESSFULLY_EDITED); $smarty->assign("T_WORKBOOK_MESSAGE_TYPE", 'success'); } else { $smarty->assign("T_WORKBOOK_MESSAGE", _WORKBOOK_SETTINGS_EDIT_PROBLEM); $smarty->assign("T_WORKBOOK_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->accept($renderer); $smarty->assign('T_WORKBOOK_EDIT_SETTINGS_FORM', $renderer->toArray()); } if (isset($_GET['reuse_item']) && $_GET['reuse_item'] == '1') { if ($_SESSION['s_type'] != 'professor') { $message = _WORKBOOK_NOACCESS; $message_type = 'failure'; $this->setMessageVar(urlencode($message), $message_type); } $form = new HTML_QuickForm("reuse_item_form", "post", $this->moduleBaseUrl . "&reuse_item=1", "", null, true); $form->addElement('text', 'item_id', _WORKBOOK_ITEM_ID, 'class="inputText"'); $form->addRule('item_id', _THEFIELD . ' "' . _WORKBOOK_ITEM_ID . '" ' . _ISMANDATORY, 'required', null, 'client'); $form->addElement('submit', 'submit', _WORKBOOK_REUSE_ITEM, 'class="flatButton"'); if ($form->isSubmitted() && $form->validate()) { $values = $form->exportValues(); $existingIDs = $this->getItemsUniqueIDs(); if (!in_array($values['item_id'], $existingIDs)) { $message = _WORKBOOK_INVALID_UNIQUE_ID; $message_type = 'failure'; $this->setMessageVar(urlencode($message), $message_type); } else { $item = $this->getItemByUniqueID($values['item_id']); $fields = array("item_title" => $item['item_title'], "item_text" => $item['item_text'], "item_question" => $item['item_question'], "question_text" => $item['question_text'], "check_answer" => $item['check_answer'], "lessons_ID" => $currentLessonID, "unique_ID" => $this->generateItemID(), "position" => $this->itemPosition($currentLessonID)); if (eF_insertTableData("module_workbook_items", $fields)) { $smarty->assign("T_WORKBOOK_MESSAGE", urlencode(_WORKBOOK_ITEM_SUCCESSFULLY_ADDED)); $smarty->assign("T_WORKBOOK_MESSAGE_TYPE", 'success'); } else { $smarty->assign("T_WORKBOOK_MESSAGE", _WORKBOOK_ITEM_ADD_PROBLEM); $smarty->assign("T_WORKBOOK_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->accept($renderer); $smarty->assign('T_WORKBOOK_REUSE_ITEM_FORM', $renderer->toArray()); } if (isset($_GET['move_item']) && eF_checkParameter($_GET['move_item'], 'id') && in_array($_GET['move_item'], array_keys($workbookItems))) { if ($_SESSION['s_type'] != 'professor') { $message = _WORKBOOK_NOACCESS; $message_type = 'failure'; $this->setMessageVar(urlencode($message), $message_type); } $smarty->assign("T_WORKBOOK_ITEMS_COUNT", count($workbookItems)); $itemPosition = $workbookItems[$_GET['move_item']]['position']; $availablePositions = array(); foreach ($workbookItems as $key => $value) { if ($value['position'] != $itemPosition) { $availablePositions[$value['position']] = $value['position']; } } $form = new HTML_QuickForm("move_item_form", "post", $this->moduleBaseUrl . "&move_item=" . $_GET['move_item'], "", null, true); $form->addElement('select', 'item_position', _WORKBOOK_ITEM_NEW_POSITION, $availablePositions, ''); $form->addElement('submit', 'submit', _WORKBOOK_MOVE_ITEM, 'class="flatButton"'); if ($form->isSubmitted() && $form->validate()) { $values = $form->exportValues(); $newPosition = $values['item_position']; if ($newPosition > $itemPosition) { foreach ($workbookItems as $key => $value) { if ($value['position'] > $itemPosition && $value['position'] <= $newPosition) { eF_updateTableData("module_workbook_items", array('position' => $value['position'] - 1), "id=" . $key); } } } else { foreach ($workbookItems as $key => $value) { if ($value['position'] < $itemPosition && $value['position'] >= $newPosition) { eF_updateTableData("module_workbook_items", array('position' => $value['position'] + 1), "id=" . $key); } } } eF_updateTableData("module_workbook_items", array('position' => $newPosition), "id=" . $_GET['move_item']); $smarty->assign("T_WORKBOOK_MESSAGE", _WORKBOOK_ITEM_SUCCESSFULLY_MOVED); $smarty->assign("T_WORKBOOK_MESSAGE_TYPE", 'success'); } $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->accept($renderer); $smarty->assign('T_WORKBOOK_MOVE_ITEM_FORM', $renderer->toArray()); } if (isset($_GET['delete_item']) && eF_checkParameter($_GET['delete_item'], 'id') && in_array($_GET['delete_item'], array_keys($workbookItems))) { $item_id = $_GET['delete_item']; $itemPosition = $workbookItems[$item_id]['position']; foreach ($workbookItems as $key => $value) { if ($value['position'] > $itemPosition) { eF_updateTableData("module_workbook_items", array('position' => $value['position'] - 1), "id=" . $key); } } eF_deleteTableData("module_workbook_items", "id=" . $item_id); } if (isset($_GET['switch_lesson']) && eF_checkParameter($_GET['switch_lesson'], 'id') && in_array($_GET['switch_lesson'], array_keys($workbookLessons))) { $lessonID = $_GET['switch_lesson']; eF_redirect("location:" . $this->moduleBaseUrl . "&lessons_ID=" . $lessonID . $popup_); } if (isset($_GET['add_item']) && $_GET['add_item'] == '1' || isset($_GET['edit_item']) && eF_checkParameter($_GET['edit_item'], 'id') && in_array($_GET['edit_item'], array_keys($workbookItems))) { if ($_SESSION['s_type'] != "professor") { eF_redirect($this->moduleBaseUrl . "&message=" . urlencode(_WORKBOOK_NOACCESS) . $popup_); } global $load_editor; $load_editor = true; $questionsText = array(); $questionsText[-1] = "-----------------------"; foreach ($lessonQuestions as $key => $value) { $questionsText[$key] = $this->truncateText(strip_tags($value['text']), 70); } if (isset($_GET['edit_item'])) { $editItemID = $_GET['edit_item']; $editItemQuestion = $workbookItems[$editItemID]['item_question']; if ($editItemQuestion != '-1' && !in_array($editItemQuestion, array_keys($questionsText))) { // reused item $reusedQuestion = $this->getReusedQuestionDetails($editItemQuestion); $questionsText[$editItemQuestion] = $this->truncateText(strip_tags($reusedQuestion['text']), 70); } } isset($_GET['add_item']) ? $postTarget = "&add_item=1" : ($postTarget = "&edit_item=" . $_GET['edit_item']); $form = new HTML_QuickForm("add_edit_item_form", "post", $this->moduleBaseUrl . $postTarget, "", null, true); $form->addElement('text', 'item_title', _WORKBOOK_ITEM_TITLE, 'class="inputText" style="width:500px;"'); $form->addElement('textarea', 'item_text', _WORKBOOK_ITEM_TEXT, 'class="mceEditor" style="width:99%;height:300px;" id="editor_content_data"'); $form->addElement('select', 'item_question', _WORKBOOK_ITEM_QUESTION, $questionsText, 'onchange="questionPreview(this)"'); $form->addElement('advcheckbox', 'check_answer', _WORKBOOK_ITEM_GRADE_ANSWER, null, 'class="inputCheckBox"', array(0, 1)); if (isset($_GET['add_item'])) { $form->addElement('submit', 'submit', _WORKBOOK_ADD_ITEM, 'class="flatButton"'); } else { $form->addElement('submit', 'submit', _WORKBOOK_UPDATE_ITEM, 'class="flatButton"'); } if (isset($_GET['edit_item'])) { $editItem = $workbookItems[$_GET['edit_item']]; $form->setDefaults($editItem); if ($isWorkbookPublished == '1') { $editItem['question_title'] = $questionsText[$editItem['item_question']]; if ($editItem['check_answer'] == '1') { $editItem['check_answer_text'] = _YES; } else { $editItem['check_answer_text'] = _NO; } } $smarty->assign('T_WORKBOOK_EDIT_ITEM_DETAILS', $editItem); } if ($form->isSubmitted() && $form->validate()) { $values = $form->exportValues(); isset($_GET['add_item']) ? $lessonID = $currentLessonID : ($lessonID = $editItem['lessons_ID']); isset($_GET['add_item']) ? $uniqueID = $this->generateItemID() : ($uniqueID = $editItem['unique_ID']); isset($_GET['add_item']) ? $position = $this->itemPosition($currentLessonID) : ($position = $editItem['position']); if ($values['item_question'] != '-1') { $id = $values['item_question']; if (!in_array($id, array_keys($lessonQuestions))) { // edit reused item $reusedQuestion = $this->getReusedQuestionDetails($id); $type = $reusedQuestion['type']; } else { $type = $lessonQuestions[$id]['type']; } $questionText = $this->questionToHtml($id, $type); } else { $questionText = ''; } $fields = array("item_title" => $values['item_title'], "item_text" => $values['item_text'], "item_question" => $values['item_question'], "question_text" => $questionText, "check_answer" => $values['check_answer'], "lessons_ID" => $lessonID, "unique_ID" => $uniqueID, "position" => $position); if ($values['item_title'] == '' && $values['item_text'] == '' && $values['item_question'] == '-1') { $message = _WORKBOOK_ITEM_EMPTY_FIELDS; if (isset($_GET['add_item'])) { eF_redirect($this->moduleBaseUrl . "&message=" . urlencode($message) . "&message_type=failure&add_item=1" . $popup_); } else { $itemID = $_GET['edit_item']; eF_redirect($this->moduleBaseUrl . "&message=" . urlencode($message) . "&message_type=failure&edit_item=" . $itemID . $popup_); } } if (isset($_GET['add_item'])) { if (eF_insertTableData("module_workbook_items", $fields)) { $message = _WORKBOOK_ITEM_SUCCESSFULLY_ADDED; eF_redirect($this->moduleBaseUrl . "&message=" . urlencode($message) . "&message_type=success" . $popup_); } else { $message = _WORKBOOK_ITEM_ADD_PROBLEM; eF_redirect($this->moduleBaseUrl . "&message=" . urlencode($message) . "&message_type=failure" . $popup_); } } else { if (eF_updateTableData("module_workbook_items", $fields, "id=" . $_GET['edit_item'])) { $message = _WORKBOOK_ITEM_SUCCESSFULLY_EDITED; eF_redirect($this->moduleBaseUrl . "&message=" . urlencode($message) . "&message_type=success" . $popup_); } else { $message = _WORKBOOK_ITEM_EDIT_PROBLEM; eF_redirect($this->moduleBaseUrl . "&message=" . urlencode($message) . "&message_type=failure" . $popup_); } } } $renderer = new HTML_QuickForm_Renderer_ArraySmarty($smarty); $form->setJsWarnings(_BEFOREJAVASCRIPTERROR, _AFTERJAVASCRIPTERROR); $form->setRequiredNote(_REQUIREDNOTE); $form->accept($renderer); $smarty->assign('T_WORKBOOK_ADD_EDIT_ITEM_FORM', $renderer->toArray()); $basedir = $currentLesson->getDirectory(); $options = array('lessons_ID' => $currentLessonID, 'metadata' => 0); $url = $_SERVER['REQUEST_URI']; $extraFileTools = array(array('image' => 'images/16x16/arrow_right.png', 'title' => _INSERTEDITOR, 'action' => 'insert_editor')); include "file_manager.php"; } if (isset($_GET['publish_workbook']) && $_GET['publish_workbook'] == '1') { $result = eF_getTableData("module_workbook_publish", "publish", "lessons_ID=" . $currentLessonID); if (count($result) == 0) { if (eF_insertTableData("module_workbook_publish", array('lessons_ID' => $currentLessonID, 'publish' => 1))) { $message = _WORKBOOK_SUCCESSFULLY_PUBLISHED; eF_redirect($this->moduleBaseUrl . "&message=" . urlencode($message) . "&message_type=success" . $popup_); } else { $message = _WORKBOOK_PUBLISH_PROBLEM; eF_redirect($this->moduleBaseUrl . "&message=" . urlencode($message) . "&message_type=failure" . $popup_); } } else { if (eF_updateTableData("module_workbook_publish", array('publish' => 1), "lessons_ID=" . $currentLessonID)) { $message = _WORKBOOK_SUCCESSFULLY_PUBLISHED; eF_redirect($this->moduleBaseUrl . "&message=" . urlencode($message) . "&message_type=success" . $popup_); } else { $message = _WORKBOOK_PUBLISH_PROBLEM; eF_redirect($this->moduleBaseUrl . "&message=" . urlencode($message) . "&message_type=failure" . $popup_); } } } if (isset($_GET['reset_workbook_professor']) && $_GET['reset_workbook_professor'] == '1') { eF_updateTableData("module_workbook_publish", array('publish' => 0), "lessons_ID=" . $currentLessonID); foreach ($workbookItems as $key => $value) { eF_deleteTableData("module_workbook_answers", "item_id=" . $key); eF_deleteTableData("module_workbook_autosave", "item_id=" . $key); eF_deleteTableData("module_workbook_progress", "lessons_ID=" . $currentLessonID); } } if (isset($_GET['reset_workbook_student']) && eF_checkParameter($_GET['reset_workbook_student'], 'id')) { $id = $_GET['reset_workbook_student']; $result = eF_getTableData("module_workbook_progress", "users_LOGIN", "id=" . $id); if ($result[0]['users_LOGIN'] != $currentUser->user['login']) { eF_redirect($this->moduleBaseUrl . "&message=" . urlencode(_WORKBOOK_NOACCESS) . $popup_); } eF_deleteTableData("module_workbook_progress", "id=" . $id); foreach ($workbookItems as $key => $value) { eF_deleteTableData("module_workbook_answers", "item_id=" . $key . " AND users_LOGIN='******'login'] . "'"); } $unitToComplete = $workbookSettings['unit_to_complete']; if ($unitToComplete != -1) { $currentUser->setSeenUnit($unitToComplete, $currentLessonID, false); } } if (isset($_GET['download_as']) && $_GET['download_as'] == 'doc') { include dirname(__FILE__) . "/classes/html_to_doc.inc.php"; $workbookAnswers = $this->getWorkbookAnswers($currentUser->user['login'], array_keys($workbookItems)); $workbookHTML = ''; foreach ($workbookItems as $key => $value) { $workbookHTML .= '<div style="width:98%;float:left;border:1px dotted #808080;padding: 5px 10px;">'; $workbookHTML .= '<div style="background-color: #EAEAEA;border: 1px solid #AAAAAA;padding: 2px;font-weight: bold;">'; $workbookHTML .= _WORKBOOK_ITEMS_COUNT . $value['position']; if ($value['item_title'] != '') { $workbookHTML .= ' - ' . $value['item_title']; } $workbookHTML .= '</div><br/>'; if ($value['item_text'] != '') { $workbookHTML .= '<div>' . $value['item_text'] . '</div><br/>'; } if ($value['item_question'] != '-1') { $questionType = $lessonQuestions[$value['item_question']]['type']; if ($workbookAnswers[$value['id']] == '') { if ($questionType == 'drag_drop') { $dragDrop = eF_getTableData("questions", "options, answer, text", "id=" . $value['item_question']); $options = unserialize($dragDrop[0]['options']); $answer = unserialize($dragDrop[0]['answer']); shuffle($options); shuffle($answer); $workbookHTML .= $dragDrop[0]['text']; for ($i = 0; $i < count($options); $i++) { $workbookHTML .= '<div>' . $options[$i] . ' '; $workbookHTML .= $answer[$i] . '</div>'; } } else { $workbookHTML .= '<div>' . $value['question_text'] . '</div>'; } } else { $workbookHTML .= '<div>' . $workbookAnswers[$value['id']] . '</div>'; } } $workbookHTML .= '</div><br/>'; } $workbookHTML = preg_replace('/<script\\b[^>]*>(.*?)<\\/script>/is', "", $workbookHTML); $fileName = _WORKBOOK_NAME . '_' . $this->getWorkbookLessonName($currentLessonID); $fileName = preg_replace('/[\\s]+/', '_', $fileName); $htmltodoc = new HTML_TO_DOC(); $htmltodoc->createDoc($workbookHTML, $fileName, true); exit(0); } if (isset($_GET['download_as']) && $_GET['download_as'] == 'pdf') { $pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true); $pdf->SetCreator(PDF_CREATOR); $pdf->SetAuthor(PDF_AUTHOR); $pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT); $pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM); $pdf->setFontSubsetting(false); $pdf->AddPage(); $completion_date = ''; $resutlt = eF_getTableData('module_workbook_progress', 'completion_date', "users_LOGIN='******'login'] . "' and lessons_ID='" . $currentLessonID . "'"); if ($resutlt) { $completion_date = $resutlt[0]['completion_date']; } $workbookHTML = ''; $workbookHTML .= '<table>'; $workbookHTML .= '<tr>'; $workbookHTML .= '<td colspan="2">'; $workbookHTML .= formatLogin($currentUser->user['login']); $workbookHTML .= '</td>'; $workbookHTML .= '</tr>'; $workbookHTML .= '<tr>'; $workbookHTML .= '<td>'; $workbookHTML .= $workbookLessonName; $workbookHTML .= '</td>'; $workbookHTML .= '<td>'; $workbookHTML .= formatTimestamp($completion_date); $workbookHTML .= '</td>'; $workbookHTML .= '</tr>'; $workbookHTML .= '</table>'; $pdf->writeHTML($workbookHTML, true, false, true, false, ''); $pdf->SetHeaderMargin(PDF_MARGIN_HEADER); $pdf->SetFooterMargin(PDF_MARGIN_FOOTER); $pdf->setHeaderFont(array('Freeserif', 'I', 11)); $pdf->setFooterFont(array('Freeserif', '', 8)); $pdf->setHeaderData('', '', '', $workbookLessonName); $pdf->AliasNbPages(); $pdf->SetFont('Freeserif', '', 10); $pdf->SetTextColor(0, 0, 0); $pdf->SetFont('Freeserif', '', 10); $pdf->SetTextColor(0, 0, 0); $workbookAnswers = $this->getWorkbookAnswers($currentUser->user['login'], array_keys($workbookItems)); $pdf->AddPage(); $workbookHTML .= ''; $itemLogo = new EfrontFile(G_DEFAULTIMAGESPATH . "32x32/unit.png"); $itemLogoUrl = $itemLogo['path']; foreach ($workbookItems as $key => $value) { $workbookHTML .= '<div id="pdf-block" style="width:98%;float:left;border:1px dotted #808080;page-break-after:always;">'; $workbookHTML .= '<div style="background-color: #EAEAEA;font-weight: bold;">'; $workbookHTML .= '<img src="' . $itemLogoUrl . '"/> ' . _WORKBOOK_ITEMS_COUNT . $value['position']; if ($value['item_title'] != '') { $workbookHTML .= ' - ' . $value['item_title']; } $workbookHTML .= '</div>'; if ($value['item_text'] != '') { $workbookHTML .= '<div>' . $value['item_text'] . '</div>'; } if ($value['item_question'] != '-1') { $questionType = $lessonQuestions[$value['item_question']]['type']; if ($workbookAnswers[$value['id']] == '') { if ($questionType == 'drag_drop') { $dragDrop = eF_getTableData("questions", "options, answer, text", "id=" . $value['item_question']); $options = unserialize($dragDrop[0]['options']); $answer = unserialize($dragDrop[0]['answer']); shuffle($options); shuffle($answer); $workbookHTML .= $dragDrop[0]['text']; for ($i = 0; $i < count($options); $i++) { $workbookHTML .= '<div>' . $options[$i] . ' '; $workbookHTML .= $answer[$i] . '</div>'; } } else { $workbookHTML .= '<div>' . $value['question_text'] . '</div>'; } } else { $workbookHTML .= '<div>' . $workbookAnswers[$value['id']] . '</div>'; } } $workbookHTML .= '</div><br/>'; } $workbookHTML = preg_replace('/<script\\b[^>]*>(.*?)<\\/script>/is', "", $workbookHTML); $pdf->writeHTML($workbookHTML, true, false, true, false, ''); $fileName = _WORKBOOK_NAME . '_' . str_replace(' ', '_', $this->getWorkbookLessonName($currentLessonID)) . '.pdf'; header("Content-type: application/pdf"); header("Content-disposition: attachment; filename=" . $fileName); echo $pdf->Output('', 'S'); exit(0); } if (isset($_GET['check_workbook_progress']) && $_GET['check_workbook_progress'] == '1') { $lessonStudents = $currentLesson->getUsers('student'); $workbookStudents = array(); foreach ($lessonStudents as $userLogin => $value) { if ($nonOptionalQuestionsNr != 0) { $studentProgress = $this->getStudentProgress($userLogin, $currentLessonID); $studentProgress .= '%'; } else { $studentProgress = '-'; } $workbookStudents[$userLogin] = array('login' => $userLogin, 'progress' => $studentProgress); } $smarty->assign("T_WORKBOOK_STUDENTS", $workbookStudents); } if (isset($_GET['preview_workbook']) && $_GET['preview_workbook'] == '1' && isset($_GET['student']) && eF_checkParameter($_GET['student'], 'login')) { $userLogin = $_GET['student']; $studentProgress = $this->getStudentProgress($userLogin, $currentLessonID); $smarty->assign("T_WORKBOOK_PREVIEW_STUDENT_PROGRESS", $studentProgress); $workbookAnswers = $this->getWorkbookAnswers($userLogin, array_keys($workbookItems)); $smarty->assign("T_WORKBOOK_PREVIEW_ANSWERS", $workbookAnswers); } if (isset($_GET['get_reset_message']) && $_GET['get_reset_message'] == '1') { echo $this->getResetMessage(array_keys($workbookItems)); exit; } if (isset($_POST['item_submitted'])) { $itemID = $_POST['item_submitted']; $questionID = $workbookItems[$itemID]['item_question']; $checkAnswer = $workbookItems[$itemID]['check_answer']; if (!in_array($questionID, array_keys($lessonQuestions))) { // reused item $reusedQuestion = $this->getReusedQuestionDetails($questionID); $questionType = $reusedQuestion['type']; } else { $questionType = $lessonQuestions[$questionID]['type']; } $question = QuestionFactory::factory($questionID); $question->setDone($_POST['question'][$questionID]); $results = $question->correct(); if ($questionType != 'raw_text' && !ef_compare_float($results['score'], 1)) { print '-1'; } else { $form = new HTML_QuickForm("questionForm", "post", "", "", null, true); $fields = array('item_id' => $itemID, 'html_solved' => $question->toHTMLSolved($form), 'users_LOGIN' => $currentUser->user['login']); eF_insertTableData("module_workbook_answers", $fields); if ($checkAnswer == '1') { $this->updateStudentProgress($currentUser->user['login'], $currentLessonID, $questionPercentage, $nonOptionalQuestionsNr); } echo $question->toHTMLSolved($form); } eF_deleteTableData("module_workbook_autosave", "item_id=" . $itemID . " AND users_LOGIN='******'login'] . "'"); exit(0); } if (isset($_POST['item_submitted_autosave'])) { $itemID = $_POST['item_submitted_autosave']; $questionID = $workbookItems[$itemID]['item_question']; $question = QuestionFactory::factory($questionID); $form = new HTML_QuickForm("questionForm", "post", "", "", null, true); $form->setDefaults($_POST); $fields = array('item_id' => $itemID, 'autosave_text' => $question->toHTML($form), 'users_LOGIN' => $currentUser->user['login']); eF_deleteTableData("module_workbook_autosave", "item_id=" . $itemID . " AND users_LOGIN='******'login'] . "'"); eF_insertTableData("module_workbook_autosave", $fields); exit(0); } if (isset($_POST['item_to_update'])) { $itemID = $_POST['item_to_update']; $questionID = $workbookItems[$itemID]['item_question']; $question = QuestionFactory::factory($questionID); $question->userAnswer = urldecode($_POST['ans']); $form = new HTML_QuickForm("questionForm", "post", "", "", null, true); $form->setDefaults($_POST); print $question->toHTML($form); exit(0); } if (isset($_POST['item_updated'])) { $itemID = $_POST['item_updated']; $questionID = $workbookItems[$itemID]['item_question']; $question = QuestionFactory::factory($questionID); $question->setDone($_POST['question'][$questionID]); $form = new HTML_QuickForm("questionForm", "post", "", "", null, true); $answerToUpdate = eF_getTableData("module_workbook_answers", "id", "item_id=" . $itemID . " AND users_LOGIN='******'login'] . "'"); eF_updateTableData("module_workbook_answers", array('html_solved' => $question->toHTMLSolved($form)), "id=" . $answerToUpdate[0]['id']); echo $question->toHTMLSolved($form); eF_deleteTableData("module_workbook_autosave", "item_id=" . $itemID . " AND users_LOGIN='******'login'] . "'"); exit(0); } else { if ($currentUser->getRole($this->getCurrentLesson()) == 'professor' || $currentUser->getRole($this->getCurrentLesson()) == 'student') { $workbookItems = $this->getWorkbookItems($currentLessonID); $smarty->assign("T_WORKBOOK_ITEMS", $workbookItems); $smarty->assign("T_WORKBOOK_LESSONS", $workbookLessons); $isWorkbookPublished = $this->isWorkbookPublished($currentLessonID); $smarty->assign("T_WORKBOOK_IS_PUBLISHED", $isWorkbookPublished); $smarty->assign("T_WORKBOOK_NON_OPTIONAL_QUESTIONS_NR", $nonOptionalQuestionsNr); } if ($currentUser->getRole($this->getCurrentLesson()) == 'professor') { $workbookOptions[] = array('text' => _SETTINGS, 'image' => $this->moduleBaseLink . 'images/settings.png', 'href' => $this->moduleBaseUrl . '&edit_settings=1&popup=1', 'onClick' => "eF_js_showDivPopup(event, '" . _SETTINGS . "', 0)", 'target' => 'POPUP_FRAME', 'id' => 'edit_settings'); $workbookOptions[] = array('text' => _WORKBOOK_POPUP_INFO, 'image' => $this->moduleBaseLink . 'images/info.png', 'href' => $this->moduleBaseUrl . '&popup_info=1&popup=1', 'onClick' => "eF_js_showDivPopup(event, '" . _WORKBOOK_POPUP_INFO . "', 2)", 'target' => 'POPUP_FRAME', 'id' => 'popup_info'); $smarty->assign("T_WORKBOOK_OPTIONS", $workbookOptions); } else { if ($currentUser->getRole($this->getCurrentLesson()) == 'student') { $workbookAnswers = $this->getWorkbookAnswers($currentUser->user['login'], array_keys($workbookItems)); $smarty->assign("T_WORKBOOK_ANSWERS", $workbookAnswers); $autoSaveAnswers = $this->getAutoSaveAnswers($currentUser->user['login'], array_keys($workbookItems)); $smarty->assign("T_WORKBOOK_AUTOSAVE_ANSWERS", $autoSaveAnswers); $studentProgress = $this->getStudentProgress($currentUser->user['login'], $currentLessonID); $smarty->assign("T_WORKBOOK_STUDENT_PROGRESS", $studentProgress); $isWorkbookCompleted = $this->isWorkbookCompleted($currentUser->user['login'], $currentLessonID, array_keys($workbookItems), $nonOptionalQuestionsNr); $smarty->assign("T_WORKBOOK_IS_COMPLETED", $isWorkbookCompleted); } } } if ($currentUser->getRole($this->getCurrentLesson()) == 'professor') { return $this->moduleBaseDir . "module_workbook_professor.tpl"; } else { if ($currentUser->getRole($this->getCurrentLesson()) == 'student') { return $this->moduleBaseDir . "module_workbook_student.tpl"; } } }
private function _validate() { if ($this->action == TIP_FORM_ACTION_DELETE || $this->action == TIP_FORM_ACTION_CUSTOM) { // Special case: GET driven form $this->_form->freeze(); return TIP::getGet('process', 'int') == 1; } // Add element and form rules isset($this->validator) && $this->_form->addFormRule($this->validator); foreach (array_keys($this->fields) as $id) { if ($this->_form->elementExists($id)) { $this->_addGuessedRules($id); $this->_addCustomRules($id); } } $stage_id = $this->id . '.stage'; $last_stage = HTTP_Session2::get($stage_id); if (!$this->_form->isSubmitted() || isset($last_stage) && $last_stage < $this->_stage) { HTTP_Session2::set($stage_id, $this->_stage); $valid = false; } elseif (is_null($last_stage)) { // No last stage defined TIP::notifyError('double'); $valid = null; } else { // Validation $this->_form->applyFilter('__ALL__', array('TIP', 'extendedTrim')); $valid = $this->_form->validate(); } // Perform uploads (if needed) if (is_callable(array('HTML_QuickForm_attachment', 'doUploads'))) { HTML_QuickForm_attachment::doUploads($this->_form); } return $valid; }
} } #cpp#endif } else { if ($_GET['op'] == 'course_rules') { $courseLessons = $currentCourse->getCourseLessons(); if ($currentCourse->course['depends_on']) { try { $dependsOn = new EfrontCourse($currentCourse->course['depends_on']); $smarty->assign("T_DEPENDSON_COURSE", $dependsOn->course['name']); } catch (Exception $e) { } } $rules_form = new HTML_QuickForm("course_rules_form", "post", basename($_SERVER['PHP_SELF']) . "?" . $baseUrl . "&op=course_rules", "", null, true); if (isset($currentUser->coreAccess['course_settings']) && $currentUser->coreAccess['course_settings'] != 'change') { $rules_form->freeze(); } else { $rules_form->addElement('submit', 'submit_rule', _SUBMIT, 'class = "flatButton"'); if ($rules_form->isSubmitted() && $rules_form->validate()) { foreach ($_POST['rules'] as $rule_lesson) { if (sizeof(array_unique($rule_lesson['lesson'])) != sizeof($rule_lesson['lesson'])) { $duplicate = true; } } if (!isset($duplicate)) { try { $currentCourse->rules = $_POST['rules']; $currentCourse->persist(); eF_redirect("" . basename($_SERVER['PHP_SELF']) . "?" . $baseUrl . "&op=course_rules&message=" . urlencode(_SUCCESFULLYSETORDER) . "&message_type=success"); } catch (Exception $e) { $smarty->assign("T_EXCEPTION_TRACE", $e->getTraceAsString());
$generalSMTPForm->registerRule('checkParameter', 'callback', 'eF_checkParameter'); $generalSMTPForm->addElement("text", "system_email", _SYSTEMEMAIL, 'class = "inputText"'); $generalSMTPForm->addElement("text", "smtp_host", _SMTPSERVER, 'class = "inputText"'); $generalSMTPForm->addElement("static", "", _IFUSESSLTHENPHPOPENSSL); $generalSMTPForm->addElement("text", "smtp_user", _SMTPUSER, 'class = "inputText"'); $generalSMTPForm->addElement("password", "smtp_pass", _SMTPPASSWORD, 'class = "inputText"'); $generalSMTPForm->addElement("text", "smtp_port", _SMTPPORT, 'class = "inputText"'); $generalSMTPForm->addElement("text", "smtp_timeout", _SMTPTIMEOUT, 'class = "inputText"'); $generalSMTPForm->addElement("advcheckbox", "smtp_auth", _SMTPAUTH, null, 'class = "inputCheckBox"', array(0, 1)); $generalSMTPForm->setDefaults($GLOBALS['configuration']); $generalSMTPForm->addRule('system_email', _INVALIDFIELDDATA, 'checkParameter', 'email'); $generalSMTPForm->addRule('system_email', _THEFIELD . ' ' . _SYSTEMEMAIL . ' ' . _ISMANDATORY, 'required', null, 'client'); $generalSMTPForm->addRule('smtp_port', _INVALIDFIELDDATA, 'checkParameter', 'uint'); $generalSMTPForm->addRule('smtp_timeout', _INVALIDFIELDDATA, 'checkParameter', 'uint'); if (isset($currentUser->coreAccess['configuration']) && $currentUser->coreAccess['configuration'] != 'change') { $generalSMTPForm->freeze(); } else { $generalSMTPForm->addElement("submit", "check_smtp", _CHECKSETTINGS, 'class = "flatButton"'); $generalSMTPForm->addElement("submit", "submit", _SAVE, 'class = "flatButton"'); if ($generalSMTPForm->isSubmitted() && $generalSMTPForm->validate()) { $values = $generalSMTPForm->exportValues(); unset($values['submit']); if (!isset($values['check_smtp'])) { foreach ($values as $key => $value) { $result = EfrontConfiguration::setValue($key, $value); } eF_redirect(basename($_SERVER['PHP_SELF']) . "?ctg=system_config&op=general&tab=smtp&message=" . urlencode(_SUCCESFULLYUPDATECONFIGURATION) . "&message_type=success"); } else { $user_mail = eF_getTableData("users", "email", "login='******'s_login'] . "'"); $header = array('From' => $values['system_email'], 'To' => $user_mail[0]['email'], 'Subject' => 'Test email', 'Content-type' => 'text/plain;charset="UTF-8"', 'Content-Transfer-Encoding' => '7bit', 'Date' => date("r")); $smtp = Mail::factory('smtp', array('auth' => $values['smtp_auth'] ? true : false, 'host' => $values['smtp_host'], 'password' => $values['smtp_pass'], 'port' => $values['smtp_port'], 'username' => $values['smtp_user'], 'timeout' => $values['smtp_timeout'], 'localhost' => $_SERVER["HTTP_HOST"]));
$form->addElement('submit', 'submit_question_another', _SAVEQUESTIONANDCREATENEW, 'class = "flatButton"'); } if (isset($currentQuestion)) { //If we are changing an existing question //pr($currentQuestion); $form->setDefaults(array('content_ID' => $currentQuestion->question['content_ID'], 'question_type' => $currentQuestion->question['type'], 'difficulty' => $currentQuestion->question['difficulty'], 'question_text' => $currentQuestion->question['text'], 'explanation' => $currentQuestion->question['explanation'])); if ($currentQuestion->question['estimate']) { $interval = eF_convertIntervalToTime($currentQuestion->question['estimate']); $form->setDefaults(array('estimate_min' => $interval['minutes'], 'estimate_sec' => $interval['seconds'])); } /* if ($currentQuestion -> question['type'] == "raw_text" && strpos($currentQuestion -> question['answer'],"<a href") !== false) { $smarty -> assign("T_HTML_ANSWER",$currentQuestion -> question['answer']); } */ $form->freeze('question_type'); //The question type cannot be changed $smarty->assign("T_HAS_EXPLANATION", $currentQuestion->question['explanation']); //If the question has an explanation, use this smarty tag to set explanation field to be visible by default. } switch ($_GET['question_type']) { //Depending on the question type, the user might have added new form fields. We need to recreate the form, in order to be able to handle them both in case of succes or failure. case 'multiple_one': if ($form->isSubmitted() || isset($currentQuestion)) { if (isset($currentQuestion) && !$form->isSubmitted()) { $values['multiple_one'] = array_values(unserialize($currentQuestion->question['options'])); //We put array_values to make sure that the array starts from zero // Types are from K1-K4 for multiple_one //$qtype_ans = (sizeof($values['multiple_one']) < 6)?sizeof($values['multiple_one']):5; //$smarty -> assign("T_QUESTION_TYPE_CODE", "K" . ($qtype_ans-1)); $values['correct_multiple_one'] = unserialize($currentQuestion->question['answer']);
$multipleLogins = array('global' => $values['global'] ? 1 : 0, 'user_types' => $values['user_types'], 'groups' => $values['groups']); EfrontConfiguration::setValue('multiple_logins', serialize($multipleLogins)); eF_redirect(basename($_SERVER['PHP_SELF']) . "?ctg=system_config&op=user&tab=multiple_logins&message=" . urlencode(_SUCCESFULLYUPDATECONFIGURATION) . "&message_type=success"); } } $smarty->assign("T_USER_MULTIPLE_LOGINS_FORM", $userMultipleLoginsForm->toArray()); $userWebserverAuthenticationForm = new HTML_QuickForm("user_webserver_authentication_form", "post", basename($_SERVER['PHP_SELF']) . "?ctg=system_config&op=user&tab=webserver_authentication", "", null, true); $userWebserverAuthenticationForm->registerRule('checkParameter', 'callback', 'eF_checkParameter'); $userWebserverAuthenticationForm->addElement("advcheckbox", "webserver_auth", _WEBSERVERAUTHENTICATION, null, 'class = "inputCheckBox"', array(0, 1)); $userWebserverAuthenticationForm->addElement("advcheckbox", "webserver_registration", _WEBSERVERREGISTRATION, null, 'class = "inputCheckBox"', array(0, 1)); $userWebserverAuthenticationForm->addElement("text", "error_page", _ERRORPAGEFORINVALIDLOGIN, 'class = "inputText"'); $userWebserverAuthenticationForm->addElement("text", "unauthorized_page", _ERRORPAGEFORUNAUTHORIZED, 'class = "inputText"'); $userWebserverAuthenticationForm->addElement("text", "username_variable", _VARIABLEFORUSERNAME, 'class = "inputText"'); $userWebserverAuthenticationForm->addElement("text", "registration_file", _INCLUDEFILETHATHANDLESUSERCREATION, 'class = "inputText"'); eval('$usernameVar=' . $GLOBALS['configuration']['username_variable'] . ';'); $userWebserverAuthenticationForm->addRule('webserver_auth', str_replace(array("%x", "%y"), array($GLOBALS['configuration']['username_variable'], $_SESSION['s_login']), _VARIABLEMUSTCONTAINLOGIN), 'callback', create_function('$checkbox', "if (\$GLOBALS['usernameVar'] == \$_SESSION['s_login']) {return true;}")); $userWebserverAuthenticationForm->setDefaults($GLOBALS['configuration']); if (isset($currentUser->coreAccess['configuration']) && $currentUser->coreAccess['configuration'] != 'change') { $userWebserverAuthenticationForm->freeze(); } else { $userWebserverAuthenticationForm->addElement("submit", "submit", _SAVE, 'class = "flatButton"'); if ($userWebserverAuthenticationForm->isSubmitted() && $userWebserverAuthenticationForm->validate()) { $values = $userWebserverAuthenticationForm->exportValues(); unset($values['submit']); foreach ($values as $key => $value) { EfrontConfiguration::setValue($key, $value); } eF_redirect(basename($_SERVER['PHP_SELF']) . "?ctg=system_config&op=user&tab=webserver_authentication&message=" . urlencode(_SUCCESFULLYUPDATECONFIGURATION) . "&message_type=success"); } } $smarty->assign("T_USER_WEBSERVER_AUTHENTICATION_FORM", $userWebserverAuthenticationForm->toArray());
$externalFacebookForm = new HTML_QuickForm("external_fb_form", "post", basename($_SERVER['PHP_SELF']) . "?ctg=system_config&op=external&tab=facebook", "", null, true); $externalFacebookForm->registerRule('checkParameter', 'callback', 'eF_checkParameter'); $externalFacebookForm->addElement("advcheckbox", "social_" . FB_FUNC_DATA_ACQUISITION, _FACEBOOKDATAACQUISITION, null, 'class = "inputCheckBox"', array(0, 1)); $externalFacebookForm->addElement("advcheckbox", "social_" . FB_FUNC_LOGGING, _FACEBOOKEXTERNALLOGGING, null, 'class = "inputCheckBox"', array(0, 1)); $externalFacebookForm->addElement("advcheckbox", "social_" . FB_FUNC_CONNECT, _FACEBOOKCONNECT, null, 'class = "inputCheckBox"', array(0, 1)); $externalFacebookForm->addElement("text", "facebook_api_key", _FACEBOOKAPIKEY, 'class = "inputText"'); $externalFacebookForm->addElement("text", "facebook_secret", _FACEBOOKSECRET, 'class = "inputText"'); // Initialize values for ($i = 1; $i < $all_social_enabled_value; $i = $i << 1) { if ($i & $socialModulesActivated) { $externalFacebookForm->setDefaults(array('social_' . $i => 1)); } } $externalFacebookForm->setDefaults(array("facebook_api_key" => $GLOBALS['configuration']['facebook_api_key'], "facebook_secret" => $GLOBALS['configuration']['facebook_secret'])); if (isset($currentUser->coreAccess['configuration']) && $currentUser->coreAccess['configuration'] != 'change') { $externalFacebookForm->freeze(); } else { $externalFacebookForm->addElement("submit", "submit", _SAVE, 'class = "flatButton"'); if ($externalFacebookForm->isSubmitted() && $externalFacebookForm->validate()) { $values = $externalFacebookForm->exportValues(); unset($values['submit']); EfrontConfiguration::setValue('facebook_api_key', $values['facebook_api_key']); unset($values['facebook_api_key']); EfrontConfiguration::setValue('facebook_secret', $values['facebook_secret']); unset($values['facebook_secret']); // Create the new binary map $socialModulesToBeActivated = 0; foreach ($values as $key => $value) { if ($value == 1) { $socialModulesToBeActivated += intval(substr($key, 7)); }
//$form -> registerRule('checkNotExist', 'callback', 'eF_checkNotExist'); $form->addElement('text', 'name', _TYPENAME, 'class = "inputText"'); $form->addRule('name', _THEFIELD . ' ' . _TYPENAME . ' ' . _ISMANDATORY, 'required', null, 'client'); //$form -> addRule('name', _INVALIDFIELDDATA, 'checkParameter', 'text'); //$form -> addRule('name', _USERTYPE.' "'.($form -> exportValue('name')).'" '._ALREADYEXISTS, 'checkNotExist', 'user_type'); $form->addElement('select', 'basic_user_type', _BASICUSERTYPE, $basicTypes, 'id="basic_user_type" class = "inputSelect" onchange = "location = \'administrator.php?ctg=user_types&' . $postTarget . '&basic_type=\'+this.options[this.selectedIndex].value+\'&name=\'+document.getElementsByName(\'name\')[0].value"'); foreach ($options as $key => $value) { if ($key == 'module_itself' || $key == 'professor_courses' || $key == 'insert_group_key') { $form->addElement("select", "core_access[{$key}]", $value, array('change' => _CHANGE, 'hidden' => _HIDE)); } else { $form->addElement("select", "core_access[{$key}]", $value, array('change' => _CHANGE, 'view' => _VIEW, 'hidden' => _HIDE)); } } $form->setDefaults(array('basic_user_type' => $basicType, 'name' => $_GET['name'])); if (isset($_GET['edit_user_type'])) { $form->freeze(array('basic_user_type')); $form->setDefaults(array('name' => $result[0]['name'], 'basic_user_type' => $result[0]['basic_user_type'], 'core_access' => unserialize($result[0]['core_access']))); $smarty->assign("T_USER_TYPE_NAME", $result[0]['name']); } if (isset($currentUser->coreAccess['user_types']) && $currentUser->coreAccess['user_types'] != 'change' || $currentUser->user['user_types_ID'] == $_GET['edit_user_type']) { $form->freeze(); } else { $form->addElement('submit', 'submit_type', _SAVE, 'class = "flatButton"'); if ($form->isSubmitted() && $form->validate()) { $values = $form->exportValues(); $fields = array("name" => $values['name'], "basic_user_type" => $values['basic_user_type'], "core_access" => serialize($values['core_access'])); if (isset($_GET['edit_user_type'])) { if (eF_updateTableData("user_types", $fields, "id=" . $_GET['edit_user_type'])) { $message = _SUCCESFULLYUPDATEDUSERTYPE; $message_type = 'success'; eF_redirect("" . basename($_SERVER['PHP_SELF']) . "?ctg=user_types&message=" . urlencode($message) . "&message_type=" . $message_type);
/** * Get an upload form * * This function is responsible for creating an "upload file" * form, as well as the equivalent HTML code. * <br/>Example: * <code> * $basedir = G_LESSONSPATH.'test/'; * $filesystem = new FileSystemTree($basedir); //Set the base directory that the file manager displayes * $url = 'administrator.php?ctg=file_manager'; //Set the url where file manager resides * $uploadForm = new HTML_QuickForm("upload_file_form", "post", $url, "", "", true); * $uploadFormString = $filesystem -> getUploadForm($uploadForm); * echo $uploadFormString; * </code> * * @param HTML_QuickForm $form The form to populate * @return string The HTML code of the form * @since 3.5.0 * @access public */ public function getUploadForm(&$form) { $form->registerRule('checkParameter', 'callback', 'eF_checkParameter'); //Register this rule for checking user input with our function, eF_checkParameter $form->addElement('file', 'file_upload[0]', null, 'class = "inputText"'); $form->addElement('file', 'file_upload[1]', null, 'class = "inputText"'); $form->addElement('file', 'file_upload[2]', null, 'class = "inputText"'); $form->addElement('file', 'file_upload[3]', null, 'class = "inputText"'); $form->addElement('file', 'file_upload[4]', null, 'class = "inputText"'); $form->addElement('file', 'file_upload[5]', null, 'class = "inputText"'); $form->addElement('file', 'file_upload[6]', null, 'class = "inputText"'); $form->addElement('advcheckbox', 'overwrite', _OVERWRITE, null, 'class = "inputCheckbox"' . $readonly); if ($_SESSION['s_type'] == 'student') { $form->freeze('overwrite'); } else { $form->setDefaults(array('overwrite' => '0')); } $form->addElement('text', 'url_upload', null, 'id = "url_upload" class = "inputText"'); $form->addElement('hidden', 'upload_current_directory', null, 'id = "upload_current_directory" class = "inputText"'); $form->addElement('submit', 'submit_upload_file', _UPLOAD, 'class = "flatButton" onclick = "$(\'uploading_image\').show()"'); $form->setMaxFileSize($this->getUploadMaxSize() * 1024); //getUploadMaxSize returns size in KB $renderer = new HTML_QuickForm_Renderer_ArraySmarty($smarty); $form->accept($renderer); $formArray = $renderer->toArray(); $formString = ' ' . $formArray['javascript'] . ' <form ' . $formArray['attributes'] . '> ' . $formArray['hidden'] . ' <table width = "100%"> <tr><td class = "labelCell">' . _UPLOADFILE . ': </td> <td class = "elementCell">' . $formArray['file_upload'][0]['html'] . '</td></tr> <tr style = "display:none"><td class = "labelCell">' . _UPLOADFILE . ': </td> <td class = "elementCell">' . $formArray['file_upload'][1]['html'] . '</td></tr> <tr style = "display:none"><td class = "labelCell">' . _UPLOADFILE . ': </td> <td class = "elementCell">' . $formArray['file_upload'][2]['html'] . '</td></tr> <tr style = "display:none"><td class = "labelCell">' . _UPLOADFILE . ': </td> <td class = "elementCell">' . $formArray['file_upload'][3]['html'] . '</td></tr> <tr style = "display:none"><td class = "labelCell">' . _UPLOADFILE . ': </td> <td class = "elementCell">' . $formArray['file_upload'][4]['html'] . '</td></tr> <tr style = "display:none"><td class = "labelCell">' . _UPLOADFILE . ': </td> <td class = "elementCell">' . $formArray['file_upload'][5]['html'] . '</td></tr> <tr style = "display:none"><td class = "labelCell">' . _UPLOADFILE . ': </td> <td class = "elementCell">' . $formArray['file_upload'][6]['html'] . '</td></tr> <tr style = "display:none"><td class = "labelCell">' . _UPLOADFILE . ': </td> <tr><td></td> <td class = "elementCell"> <img src = "images/16x16/add.png" alt = "' . _ADDFILE . '" title = "' . _ADDFILE . '" onclick = "addUploadBox(this)"/></td></tr> <tr><td></td> <td class = "infoCell"><span id="messageError" class = "severeWarning"></span></td></tr> <tr><td></td> <td class = "infoCell">' . _MAXIMUMUPLOADSIZE . ': ' . $this->getUploadMaxSize() . ' ' . _KB . '</td></tr> <tr><td class = "labelCell">' . _UPLOADFILEFROMURL . ': </td> <td class = "elementCell">' . $formArray['url_upload']['html'] . '</td></tr> <tr><td class = "labelCell">' . $formArray['overwrite']['label'] . ': </td> <td class = "elementCell">' . $formArray['overwrite']['html'] . '</td></tr> <tr><td></td> <td class = "submitCell"> ' . $formArray['submit_upload_file']['html'] . ' </td></tr> </table> </form> <img src = "images/others/progress_big.gif" id = "uploading_image" title = "' . _UPLOADING . '" alt = "' . _UPLOADING . '" style = "display:none;margin-left:auto;margin-right:auto;margin-top:30px;vertical-align:middle;"/>'; return $formString; }
} #cpp#endif if (G_VERSIONTYPE != 'community') { #cpp#ifndef COMMUNITY $modeForm->addElement("static", "separator", '<span style="font-weight:bold">' . _SOCIALOPTIONS . '</span>'); //$modeForm -> addElement("select", "mode_social_events", _EVENTSLOGGING, $modes); $modeForm->addElement("select", "mode_system_timeline", _SYSTEMTIMELINES, $modes); $modeForm->addElement("select", "mode_lessons_timeline", _LESSONTIMELINES, $modes); $modeForm->addElement("select", "mode_func_people", _PEOPLECONNECTIONS, $modes); $modeForm->addElement("select", "mode_func_comments", _COMMENTSWALL, $modes); $modeForm->addElement("select", "mode_func_userstatus", _USERSTATUS, $modes); } #cpp#endif $modeForm->setDefaults($GLOBALS['configuration']); if (isset($currentUser->coreAccess['configuration']) && $currentUser->coreAccess['configuration'] != 'change') { $modeForm->freeze(); } else { $modeForm->addElement("submit", "submit", _SAVE, 'class = "flatButton"'); if ($modeForm->isSubmitted() && $modeForm->validate()) { //If the form is submitted and validated $values = $modeForm->exportValues(); unset($values['submit']); foreach ($values as $key => $value) { EfrontConfiguration::setValue($key, $value); } //@TODO review by mixalis /* $socialModulesToBeActivated = EfrontUser::isOptionVisible('system_timeline') & EfrontUser::isOptionVisible('lessons_timeline') & EfrontUser::isOptionVisible('func_people') &
$form->setDefaults(array('action_on_submit' => 5, 'maintain_history' => 5, 'publish' => 1, 'keep_best' => 0, 'mastery_score' => $_GET['ctg'] != 'feedback' ? 50 : 0, 'redoable' => 1)); if (isset($_GET['from_unit'])) { $form->setDefaults(array('parent_content' => $_GET['from_unit'])); } } else { if (isset($_GET['edit_test'])) { if (!$skillgap_tests) { $testUnit = new EfrontUnit($currentTest->test['content_ID']); } if ($_GET['ctg'] != 'feedback') { $form->addElement('submit', 'submit_test', _SAVETEST, 'class = "flatButton"'); $form->addElement('submit', 'submit_test_new', _SAVEASNEWTEST, 'class = "flatButton"'); } else { $form->addElement('submit', 'submit_test', _SAVE, 'class = "flatButton"'); } $form->freeze('parent_content'); $form->setDefaults($currentTest->options); if ($currentTest->options['redirect']) { $submitaction = 0; } elseif ($currentTest->options['show_answers_if_pass']) { $submitaction = 5; } elseif ($currentTest->options['answers']) { $submitaction = 4; } elseif ($currentTest->options['show_score']) { $submitaction = 3; } elseif ($currentTest->options['given_answers']) { $submitaction = 2; } else { $submitaction = 1; } $form->setDefaults(array('name' => $currentTest->test['name'], 'duration' => $currentTest->options['duration'] ? round($currentTest->options['duration'] / 60) : '', 'redoable' => $currentTest->options['redoable'] ? $currentTest->options['redoable'] : '', 'publish' => $currentTest->test['publish'], 'keep_best' => $currentTest->test['keep_best'], 'description' => $currentTest->test['description'], 'action_on_submit' => $submitaction, 'mastery_score' => $currentTest->test['mastery_score']));
try { $pdfFile = new EfrontFile($pdfId[1]); } 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'; } $form->setDefaults(array('pdf_content' => $pdfFile['physical_name'])); } $form->setDefaults(array('pdf_check' => 1)); $smarty->assign("T_EDITPDFCONTENT", true); } //You can't change a unit's parent from this form. You must use the content tree management page if ($_GET['edit']) { $form->setDefaults(array('parent_content_ID' => $currentUnit['parent_content_ID'])); $form->freeze(array('parent_content_ID')); } //If the form was submitted with pdf content, take special care if ($form->isSubmitted() && $form->validate()) { try { $values = $form->exportValues(); if ($_FILES['pdf_upload']['name'] != "") { if (strpos($_FILES['pdf_upload']['name'], ".pdf") !== false) { $destinationDir = new EfrontDirectory(G_LESSONSPATH . $_SESSION['s_lessons_ID']); $filesystem = new FileSystemTree(G_LESSONSPATH . $_SESSION['s_lessons_ID']); $uploadedFile = $filesystem->uploadFile('pdf_upload', $destinationDir); $values['data'] = '<iframe src="view_file.php?file=' . $uploadedFile['id'] . '" name="pdfaccept" width="100%" height="600"></iframe>'; //$values['data'] = '<iframe src="'.$currentLesson -> getDirectoryUrl().'/'.$uploadedFile["physical_name"].'" name="pdfaccept" width="100%" height="600"></iframe>'; } else { throw new Exception(_YOUMUSTUPLOADAPDFFILE); }
$config_form->setDefaults(array($conf_option => $GLOBALS['configuration'][$conf_option])); } if ($config_form->isSubmitted()) { foreach ($notification_configurations as $conf_option) { EfrontConfiguration::setValue($conf_option, $config_form->exportValue($conf_option)); } // Clear the stored sent messages according to the new limitations EfrontNotification::clearSentMessages(); $message = _NOTIFICATIONCONFIGURATIONSUPDATEDSUCCESSFULLY; $message_type = 'success'; eF_redirect("" . $_SESSION['s_type'] . ".php?ctg=digests&message=" . urlencode($message) . "&message_type=" . $message_type); } $renderer = new HTML_QuickForm_Renderer_ArraySmarty($smarty); //Create a smarty renderer $renderer->setRequiredTemplate('{$html}{if $required} <span class = "formRequired">*</span> {/if}'); if (isset($currentUser->coreAccess['notifications']) && $currentUser->coreAccess['notifications'] != 'change') { $config_form->freeze(); } $config_form->setJsWarnings(_BEFOREJAVASCRIPTERROR, _AFTERJAVASCRIPTERROR); //Set javascript error messages $config_form->setRequiredNote(_REQUIREDNOTE); $config_form->accept($renderer); //Assign this form to the renderer, so that corresponding template code is created $smarty->assign('T_NOTIFICATION_VARIABLES_FORM', $renderer->toArray()); //Assign the form to the template $options = array(array('image' => '16x16/go_into.png', 'text' => _RESTOREDEFAULTNOTIFICATIONS, 'href' => 'administrator.php?ctg=digests&add_default=1')); $smarty->assign("T_TABLE_OPTIONS", $options); } }
foreach (EfrontSystem::getLanguages() as $key => $value) { if ($value['active']) { $languages[$key] = $value['translation']; } } $form->addElement('select', 'languages_NAME', _LANGUAGE, $languages, 'class = "inputSelect" onchange = "location = \'index.php?ctg=signup&bypass_language=\'+this.options[this.selectedIndex].value"'); //A select drop down for languages if ($_SESSION['s_language']) { $form->setDefaults(array('languages_NAME' => $_SESSION['s_language'])); //The default language is also the selected one } else { $form->setDefaults(array('languages_NAME' => $GLOBALS['configuration']['default_language'])); //The default language is also the selected one } if ($GLOBALS['configuration']['onelanguage']) { $form->freeze(array('languages_NAME')); } if (G_VERSIONTYPE != 'community') { #cpp#ifndef COMMUNITY if (G_VERSIONTYPE == 'enterprise') { #cpp#ifdef ENTERPRISE require_once "../libraries/module_hcd_tools.php"; } #cpp#endif $user_profile = eF_getTableData("user_profile", "*", "active=1 and visible=1", "field_order"); //Get admin-defined form fields for user registration $userProfileFields = array(); foreach ($user_profile as $field) { //Add custom fields, defined in user_profile database table if ($field['type'] != 'branchinfo' && $field['type'] != 'groupinfo') { $userProfileFields[] = $field['name'];
unset($condition_types['specific_test']); } $form->addElement('select', 'condition_types', null, $condition_types, 'class = "inputSelect" onchange = "selectCondition(this)"'); $form->addRule('condition_types', _INVALIDCONDITION, 'in_array', array_keys($condition_types)); $form->addElement('text', 'percentage_units', null, 'style = "width:2.5em"'); $form->setDefaults(array('percentage_units' => 50)); $form->addRule('percentage_units', _THEFIELD . ' ' . _ISMANDATORY, 'required', null, 'client'); $form->addRule('percentage_units', _INVALIDPERCENTAGE, 'numeric'); $form->addElement('text', 'time_in_lesson', _MINUTES, 'style = "width:5em"'); $form->addRule('time_in_lesson', _INVALIDDATA, 'numeric', null, 'client'); $form->addElement('select', 'relation', null, array('and' => _AND, 'or' => _OR)); $form->addElement('submit', 'submit_complete_lesson_condition', _SUBMIT, 'class = "flatButton"'); if (isset($_GET['edit_condition'])) { $smarty->assign('T_CURRENT_CONDITION', $conditions[$_GET['edit_condition']]); $form->setDefaults(array('condition_types' => $conditions[$_GET['edit_condition']]['type'], 'relation' => $conditions[$_GET['edit_condition']]['relation'])); $form->freeze('condition_types'); $options = $conditions[$_GET['edit_condition']]['options']; switch ($conditions[$_GET['edit_condition']]['type']) { case 'percentage_units': $defaults = array('percentage_units' => $options[0]); break; case 'specific_unit': $defaults = array('specific_unit' => $options[0]); break; case 'time_in_lesson': $defaults = array('time_in_lesson' => $options[0]); break; //case 'all_tests': $defaults = array('all_tests' => $options[0]); break; //case 'specific_test': $defaults = array('specific_test' => $options[0]); break; //case 'all_tests': $defaults = array('all_tests' => $options[0]); break; //case 'specific_test': $defaults = array('specific_test' => $options[0]); break;
$tax_rates = $ushop->getTaxRates(true); foreach ($tax_rates as $rate) { $opts[$rate->tax_rate_id] = ucwords($rate->tax_rate); } $form->addElement('html', '<fieldset>'); $form->addElement('header', 'edit_tax_code', 'Edit Tax Code'); $form->addElement('text', 'tax_code', 'Tax Code:', array('size' => 2, 'maxlength' => 2, 'class' => 'inputbox')); $s->loadArray($opts); $form->addElement($s); $form->addElement('text', 'description', 'Description:', array('size' => 20, 'maxlength' => 20, 'class' => 'inputbox')); $form->addElement('html', '</fieldset>'); $form->addRule('description', 'Please enter a decription', 'required'); $form->addRule('tax_code', 'Please enter a tax code', 'required'); $form->addRule('tax_code', 'Tax codes have only letters', 'lettersonly'); if ($form->validate()) { $form->freeze(); $values = $form->process(array(&$this, 'formValues'), false); $menuBar['back'] = '/ushop/tax/overview'; $values['tax_code'] = strtoupper($values['tax_code']); //check then enter the record. $res = $this->update($values, $ushop->db_name . 'tax_codes', array('where' => 'tax_code_id=' . $this->registry->params['id'])); if ($res) { $params['TYPE'] = 'pass'; $params['MESSAGE'] = '<h2>Tax code was successfully edited.</h2>'; } else { $params['TYPE'] = 'error'; $params['MESSAGE'] = '<h2>Tax code could not be edited due to an error.</h2>'; } // done! } else { $form->setDefaults(array('tax_code' => $rows[0]->tax_code, 'tax_rate_id' => $rows[0]->tax_rate_id, 'description' => $rows[0]->description));
require_once $path . 'tools.php'; if ($_GET['upgrade']) { $currentVersion = Installation::checkCurrentVersion(); $smarty->assign("T_CURRENT_VERSION", $currentVersion); } //Initialize ADODB $ADODB_CACHE_DIR = $path . "adodb/cache"; $ADODB_FETCH_MODE = ADODB_FETCH_ASSOC; $form = new HTML_QuickForm("info_form", "post", $_SERVER['PHP_SELF'] . "?step=2" . ($_GET['upgrade'] ? '&upgrade=1' : ''), "", "class = 'indexForm'", true); $form->registerRule('checkParameter', 'callback', 'eF_checkParameter'); //Register this rule for checking user input with our function, eF_checkParameter $form->addElement('select', 'db_type', null, array('mysql' => 'MySQL', 'mssql' => 'MSSQL')); $form->addRule('db_type', 'Invalid database type', 'checkParameter', 'string'); //The database type can only be string and is mandatory $form->setDefaults(array('db_type' => 'mysql')); $form->freeze(array('db_type')); //Freeze this element, since it can't change for now $form->addElement('text', 'db_host', null, 'class = "inputText"'); $form->addRule('db_host', 'The field "Database host" is mandatory', 'required', null, 'client'); //The database type can only be string and is mandatory $form->addElement('text', 'db_user', null, 'class = "inputText"'); $form->addRule('db_user', 'The field "Database user" is mandatory', 'required', null, 'client'); //The database type can only be string and is mandatory $form->addRule('db_user', 'Invalid database user', 'checkParameter', 'alnum'); //The database user can only be string $form->addElement('password', 'db_password', null, 'class = "inputText"'); $form->addElement('text', 'db_name', null, 'class = "inputText"'); $form->addRule('db_name', 'The field "Database name" is mandatory', 'required', null, 'client'); //The database type can only be string and is mandatory $form->addRule('db_name', 'Invalid database name', 'checkParameter', 'alnum'); //The database name can only be string