public function __construct() { parent::__construct('delete_interest', 'Delete Interest', 'Admin/delete_interest.php'); if ($this->loginError) { return; } $form = new HTML_QuickForm('deleter'); $interest_list = new pdAuthInterests($this->db); $form->addElement('select', 'interests', 'Select interest(s) to delete:', $interest_list->list, array('multiple' => 'multiple', 'size' => 15)); $form->addGroup(array(HTML_QuickForm::createElement('button', 'cancel', 'Cancel', array('onclick' => 'history.back()')), HTML_QuickForm::createElement('submit', 'submit', 'Delete')), null, null, ' ', false); if ($form->validate()) { $values = $form->exportValues(); foreach ($values['interests'] as $interest_id) { $names[] = $interest_list->list[$interest_id]; } $interest_list->dbDelete($this->db, $values['interests']); echo 'You have successfully removed the following interest from the ', 'database: <br/><b>', implode(', ', $names), '</b></p>', '<br><a href="', $_SERVER['PHP_SELF'], '">Delete another interest</a>'; } else { $renderer =& $form->defaultRenderer(); $form->accept($renderer); $this->form =& $form; $this->renderer =& $renderer; echo '<h3>Delete Interest </h3>'; } }
public function __construct() { parent::__construct('aicml_stats'); if ($this->loginError) { return; } $this->loadHttpVars(true, false); if (isset($this->csv_output)) { assert('isset($_SESSION["aicml_stats"])'); $this->stats =& $_SESSION['aicml_stats']; return; } $pubs =& $this->getMachineLearningPapers(); // populate $this->aicml_pi_authors $this->getPiAuthors(); // populate $this->aicml_pdf_students_staff_authors $this->getPdfStudentsAndStaffAuthors(); $this->collectStats($pubs); $_SESSION['aicml_stats'] =& $this->stats; $form = new HTML_QuickForm('aicml_stats', 'get', 'aicml_stats.php'); $form->addElement('submit', 'csv_output', 'Export to CSV'); // create a new renderer because $form->defaultRenderer() creates // a single copy $renderer = new HTML_QuickForm_Renderer_Default(); $form->accept($renderer); echo $renderer->toHtml(); echo $this->allPiPublicationTable(); echo $this->fiscalYearTotalsTable('pi', 'PI Fiscal Year Totals'); foreach ($this->aicml_pi_authors as $pi_author) { echo $this->piPublicationsTable($pi_author); } echo $this->staffPublicationsTable(); echo $this->fiscalYearTotalsTable('staff', 'Staff Fiscal Year Totals'); echo $this->studentTotalsTable(); }
/** * * @return array */ public function toSmarty() { $this->formRenderer = new \HTML_QuickForm_Renderer_ArraySmarty($this->tpl, true); $this->formRenderer->setRequiredTemplate('{label}<font color="red" size="1">*</font>'); $this->formRenderer->setErrorTemplate('<font color="red">{error}</font><br />{html}'); $this->formProcessor->accept($this->formRenderer); $smartyArrayFormat = $this->formatForSmarty(); $this->tpl->assign('eventValidation', $this->eventValidation); $this->tpl->assign('submitValidation', $this->submitValidation); return $smartyArrayFormat; }
public function __construct() { parent::__construct('view_publication', 'View Publication', 'view_publication.php'); if ($this->loginError) { return; } $this->loadHttpVars(); if (!isset($this->pub_id) || !is_numeric($this->pub_id)) { $this->pageError = true; return; } $pub = new pdPublication(); $result = $pub->dbLoad($this->db, $this->pub_id); if (!$result) { echo 'Publication does not exist'; return; } if (isset($this->submit_pending) && $this->submit_pending) { // check if this pub entry is pending $q = $this->db->selectRow('pub_pending', '*', array('pub_id' => $this->pub_id)); assert('$q'); $form = new HTML_QuickForm('submit_pending'); $form->addElement('hidden', 'submit_pending', true); $form->addElement('hidden', 'pub_id', $this->pub_id); $elements = array(); $elements[] = HTML_QuickForm::createElement('advcheckbox', 'valid', null, 'Valid', null, array(0, 1)); $elements[] = HTML_QuickForm::createElement('submit', 'submit', 'Submit'); $form->addGroup($elements, 'elgroup', '', ' ', false); // create a new renderer because $form->defaultRenderer() creates // a single copy $renderer = new HTML_QuickForm_Renderer_Default(); $form->accept($renderer); if ($form->validate()) { $values =& $form->exportValues(); $pub->markValid($this->db); echo 'Publication entry marked as valid.'; return; } else { echo "<h2>This publication entry requires validation</h2>\n"; echo $renderer->toHtml(); } } $this->showPublication($pub); }
public function __construct() { parent::__construct('tag_non_ml'); if ($this->loginError) { return; } $this->loadHttpVars(); $pubs =& $this->getNonMachineLearningPapers(); $form = new HTML_QuickForm('tag_non_ml_form', 'post', './tag_ml_submit.php'); $form->addElement('header', null, 'Citation</th><th style="width:7%">Is ML'); $count = 0; foreach ($pubs as &$pub) { $pub->dbLoad($this->db, $pub->pub_id, pdPublication::DB_LOAD_VENUE | pdPublication::DB_LOAD_CATEGORY | pdPublication::DB_LOAD_AUTHOR_FULL); ++$count; $form->addGroup(array(HTML_QuickForm::createElement('static', null, null, $pub->getCitationHtml() . ' ' . getPubIcons($this->db, $pub, 0x7)), HTML_QuickForm::createElement('advcheckbox', 'pub_tag[' . $pub->pub_id . ']', null, null, null, array('no', 'yes'))), 'tag_ml_group', $count, '</td><td>', false); } $form->addElement('submit', 'submit', 'Submit'); $renderer =& $form->defaultRenderer(); $form->accept($renderer); $this->renderer =& $renderer; }
$flexy->setData('images', $images); if ($isPopUp) { $flexy->setData('showForm', true); } } else { if (empty($isError) || $isPopUp) { $flexy->setData('showForm', true); } } // }}} // {{{ output // フォームをテンプレート用オブジェクトに変換 $r = new HTML_QuickForm_Renderer_ObjectFlexy($flexy); //$r->setLabelTemplate('_label.tpl.html'); //$r->setHtmlTemplate('_html.tpl.html'); $qf->accept($r); $qfObj = $r->toObject(); // 動的JavaScript $js = $qf->getValidationScript(); $js .= <<<EOS <script type="text/javascript"> // <![CDATA[ function ic2g_onload() { \tsetWinTitle(); EOS; if ($execDL && $autoClose > 0) { $js .= "\twindow.setTimeout('window.close();', {$autoClose});\n"; } $js .= <<<EOS
$importForm->accept($renderer); $smarty->assign('T_IMPORT_FORM', $renderer->toArray()); // ******************************************* Export form ******************************************* $exportForm = new HTML_QuickForm("export_form", "post", basename($_SERVER['PHP_SELF']) . "?ctg=import_export&op=export&tab=export", "", null, true); unset($import_export_types['anything']); $exportForm->addElement('select', 'export_type', _DATATYPE, $import_export_types, 'class = "inputCheckbox"', array(0, 1)); $exportForm->addElement("select", "date_format", _DATEFORMAT, array("DD/MM/YYYY" => "DD/MM/YYYY", "MM/DD/YYYY" => "MM/DD/YYYY", "YYYY/MM/DD" => "YYYY/MM/DD")); $exportForm->addElement('radio', 'export_separator', _KEEPEXISTINGUSERS, null, 'csvA'); $exportForm->addElement('radio', 'export_separator', _KEEPEXISTINGUSERS, null, 'csvB'); $exportForm->setDefaults(array('export_separator' => "csvA")); $exportForm->addElement('submit', 'submit_export', _EXPORTDATA, 'class = "flatButton"'); if ($exportForm->isSubmitted() && $exportForm->validate()) { $exportForm->exportValue('export_separator') == 'csvA' ? $separator = ',' : ($separator = ';'); try { $options = array("separator" => $separator, "date_format" => $exportForm->exportValue('date_format')); $exporter = EfrontExportFactory::factory("csv", $options); $file = $exporter->export($exportForm->exportValue('export_type')); header("content-type:" . $file['mime_type']); header('content-disposition: attachment; filename= "' . $file['name'] . '"'); readfile($file['path']); exit; } catch (Exception $e) { $smarty->assign("T_EXCEPTION_TRACE", $e->getTraceAsString()); $message = _ERRORRESTORINGFILE . ': ' . $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_EXPORTED_FILE", $file); } $renderer = new HTML_QuickForm_Renderer_ArraySmarty($smarty); $exportForm->accept($renderer); $smarty->assign('T_EXPORT_FORM', $renderer->toArray());
public function getSmartyTpl() { $smarty = $this->getSmartyVar(); $smarty->assign('T_CHAT_ERROR_RATE', ""); $smarty->assign('T_CHAT_ERROR2_RATE', ""); if (isset($_POST['rate']) && isset($_POST['rate2'])) { $ok = true; if ($_POST['rate'] < 1) { $smarty->assign('T_CHAT_ERROR_RATE', " New Rate must be greater or equal to 1."); $ok = false; } if ($_POST['rate2'] < 1) { $smarty->assign('T_CHAT_ERROR2_RATE', " New Rate must be greater or equal to 1."); $ok = false; } if ($ok) { $this->setChatHeartbeat($_POST['rate'] * 1000); $this->setRefresh_rate($_POST['rate2'] * 1000); } } $r = $this->getChatHeartbeat(); $r2 = $this->getRefresh_rate(); $smarty->assign('T_CHAT_CURRENT_RATE', $r / 1000); $form = new HTML_QuickForm("change_chatheartbeat_form", "post", $this->moduleBaseUrl . "&setChatHeartBeat=1", "", null, true); $form->addElement('text', 'rate', "rate", 'class="inputText" value="' . $r / 1000 . '" style="width:100px;"'); $form->addRule('rate', _THEFIELD . ' "Rate" ' . _ISMANDATORY, 'required', null, 'client'); $form->addRule('rate', "Non numeric Value", 'numeric', null, 'client'); $form->addRule('rate', "Rate must be greater than 1", 'callback', create_function('$rate', 'return ($rate >= 1);')); $form->addElement('text', 'rate2', "rate2", 'class="inputText" value="' . $r2 / 1000 . '" style="width:100px;"'); $form->addRule('rate2', _THEFIELD . ' "Rate" ' . _ISMANDATORY, 'required', null, 'client'); $form->addRule('rate2', "Non numeric Value", 'numeric', null, 'client'); $form->addElement('submit', 'submit1', _SUBMIT, 'class="flatButton"'); $renderer = new HTML_QuickForm_Renderer_ArraySmarty($smarty); $form->setJsWarnings(_BEFOREJAVASCRIPTERROR, _AFTERJAVASCRIPTERROR); $form->setRequiredNote("mesh"); $form->accept($renderer); $smarty->assign('T_CHAT_CHANGE_CHATHEARTBEAT_FORM', $renderer->toArray()); /////////////////////////////////////////////////////////////////////////////////////////////////////////////////// /*$smarty->assign('T_CHAT_ERROR2_RATE', ""); if (isset($_POST['rate2'])){ if ($_POST['rate2'] >= 1) $this -> setRefresh_rate($_POST['rate2']*1000); else $smarty->assign('T_CHAT_ERROR2_RATE', " New Rate must be greater or equal to 1."); } $r2 = $this->getRefresh_rate(); $smarty->assign('T_CHAT_CURRENT_REFRESH_RATE', $r2/1000); $form = new HTML_QuickForm("change_refreshrate_form", "post", $this->moduleBaseUrl."&setRefresh_rate=1", "", null, true); $form->addElement('text', 'rate2', "rate2", 'class="inputText" value="'.($r2/1000).'" style="width:100px;"'); $form->addRule('rate2', _THEFIELD.' "New Rate" '._ISMANDATORY, 'required', null, 'client'); $form->addRule('rate2', "Non numeric Value", 'numeric', null, 'client'); $form->addElement('submit', 'submit2', _SUBMIT, 'class="flatButton"'); $renderer = new HTML_QuickForm_Renderer_ArraySmarty($smarty); $form->setJsWarnings(_BEFOREJAVASCRIPTERROR, _AFTERJAVASCRIPTERROR); $form->setRequiredNote("mesh"); $form->accept($renderer); $smarty->assign('T_CHAT_CHANGE_REFRESHRATE_FORM', $renderer->toArray());*/ ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //$lessons = $this -> getLessonsCatalogue(); //$smarty->assign('T_CHAT_LESSONS', $lessons); $textfieldcontent = ""; if (isset($_POST['lessontitle'])) { $textfieldcontent = $_POST['lessontitle']; //$l = strip_tags($_POST['lessontitle']); //$l2 = substr($l, strpos($l, '→')+5); $log = $this->createLessonHistory($_POST['lessontitle'], $_POST['from']['Y'] . '-' . $_POST['from']['M'] . '-' . $_POST['from']['d'] . ' ' . "00:00:00", $_POST['until']['Y'] . '-' . $_POST['until']['M'] . '-' . $_POST['until']['d'] . ' ' . "23:59:59"); $smarty->assign('T_LOG', $log); $smarty->assign('T_CHAT_LESSON_TITLE', $l2); } $form = new HTML_QuickForm("create_log_form", "post", $this->moduleBaseUrl . "&createLog=1", "", null, true); $date_from = $form->addElement('date', 'from', 'From Date:', array('format' => 'dMY', 'minYear' => 2010, 'maxYear' => date('Y'))); $date_until = $form->addElement('date', 'until', 'Until Date:', array('format' => 'dMY', 'minYear' => 2010, 'maxYear' => date('Y'))); $form->addElement('text', 'lessontitle', "lessontitle", 'maxlength="100" size="100" class="autoCompleteTextBox" id="autocomplete" value="' . $textfieldcontent . '"'); $form->addRule('lessontitle', _THEFIELD . ' "Lesson Title" ' . _ISMANDATORY, 'required', null, 'client'); $week_ago = $this->subtractDaysFromToday(7); $form->setDefaults(array('until' => array('d' => date('d'), 'M' => date('m'), 'Y' => date('Y')), 'from' => $week_ago)); $form->addElement('submit', 'submit', "Create Log", 'class="flatButton"'); $renderer = new HTML_QuickForm_Renderer_ArraySmarty($smarty); $form->setJsWarnings(_BEFOREJAVASCRIPTERROR, _AFTERJAVASCRIPTERROR); $form->setRequiredNote("mesh"); $form->accept($renderer); $smarty->assign('T_CHAT_CREATE_LOG_FORM', $renderer->toArray()); //////// return $this->moduleBaseDir . "control_panel.tpl"; }
/** * Remplit le layer de customisation des searchforms. * * @param object $tpl instanceof Template * @access private * @return void */ private function _customDisplay($tpl) { require_once 'HTML/QuickForm.php'; require_once 'HTML/QuickForm/Renderer/ArraySmarty.php'; require_once 'HTML/QuickForm/advmultiselect.php'; $renderer = new HTML_QuickForm_Renderer_ArraySmarty($tpl); $form = new HTML_QuickForm('CustomSearch', 'post', $_SERVER['PHP_SELF']); $form->removeAttribute('name'); // XHTML compliance $defaultValues = array(); // Valeurs par defaut des champs du form $form->updateAttributes(array('onsubmit' => "return checkBeforeSubmit();")); $form->addElement('hidden', 'customSearchUpdated', '0'); $criteria = array(); foreach ($this->_elementsToDisplay as $elementName => $type) { if ($type == 'blank' || substr($type, 0, 4) == 'date') { continue; } $criteria[$elementName] = $this->_form->getElement($elementName)->getLabel(); } $labels = array(_('criteria') . ':', _('Available criteria'), _('Criteria to hide')); $elt = HTML_QuickForm::createElement('advmultiselect', 'customSearchHiddenCriteria', $labels, $criteria, array('style' => 'width:100%;')); // Necessaire pour externaliser la tonne de js, si include js trouve $js = file_exists('JS_AdvMultiSelect.php') ? '' : '{javascript}'; $jsValidation = '<script type="text/javascript"> //<![CDATA[ function checkBeforeSubmit() { if ($(\'__customSearchHiddenCriteria\').options.length == 0) { alert("' . _("You can't hide all criteria.") . '"); return false; } return true; } //]]> </script>'; $eltTemplate = $js . $jsValidation . ' <table{class}> <tr><th>{label_2}</th><th> </th><th>{label_3}</th></tr> <tr> <td valign="top">{unselected}</td> <td align="center">{add}{remove}</td> <td valign="top">{selected}</td> </tr> </table> '; $elt->setElementTemplate($eltTemplate); $form->addElement($elt); $form->addElement('submit', 'customSearchSubmit', A_VALIDATE, 'onclick="this.form.customSearchUpdated.value=1;"'); $form->addElement('button', 'customSearchCancel', A_CANCEL, 'onclick="fw.dom.toggleElement($(\'custom_search_layer\'));"'); $defaultValues['customSearchHiddenCriteria'] = $this->hiddenCriteriaByUser; $form->setDefaults($defaultValues); // PATCH car advmultiselect buggé!! $elt->_values = $defaultValues['customSearchHiddenCriteria']; // end PATCH $form->accept($renderer); // affecte au form le renderer personnalise $tpl->assign('customSearchForm', $renderer->toArray()); }
function db2app() { require_once 'HTML/QuickForm.php'; $form = new HTML_QuickForm('db2app'); $res = mysql_list_dbs(db()); if (!$res) { trigger_error(mysql_error(db()), E_USER_ERROR); } $options = array('' => 'Please Select Database ...'); while ($row = mysql_fetch_row($res)) { $options[$row[0]] = $row[0]; } $form->addElement('hidden', '-action', 'db2app'); $form->addElement('select', 'database_name', 'Select Database' . $this->infoLink('archive2app.database_name'), $options, array('onchange' => 'listeners.database_name.onchange(this)')); $form->addElement('header', 'db_info', 'Database connection details'); //$form->addElement('html', 'this is a test'); $form->addElement('text', 'mysql_user', 'MySQL Username ' . $this->infoLink('archive2app.mysql_user')); $form->addElement('password', 'mysql_password', 'MySQL Password'); //$form->addElement('radio','output_format','Output options','Download as tar.gz archive','download'); //$form->addElement('radio','output_format','','Install on webserver in apps directory','install'); $form->addElement('select', 'install_type', 'Installation type ' . $this->infoLink('archive2app.install_type'), array('' => 'Please select ...', 'download_tarball' => 'Download Tarball', 'ftp_install' => 'Install on server (using FTP)'), array('onchange' => "listeners.install_type.onchange(this);")); $form->addElement('header', 'ftp_info', 'FTP Connection Info'); $form->addElement('text', 'ftp_host', 'FTP Host'); $form->addElement('checkbox', 'ftp_ssl', 'Use SSL'); $form->setDefaults(array('ftp_host' => DB_HOST)); $form->addElement('text', 'ftp_path', 'FTP Path', array('size' => 50)); $form->setDefaults(array('ftp_path' => $_SERVER['DOCUMENT_ROOT'])); $form->addElement('text', 'ftp_username', 'FTP Username'); $form->addElement('password', 'ftp_password', 'FTP Password'); $form->addElement('submit', 'submit', 'Submit'); $form->addRule('database_name', 'Please select a database', 'required', null, 'client'); $form->addRule('mysql_user', 'Please enter a mysql username that the application can connect as.', 'required', null, 'client'); $form->addRule('install_type', 'Please select an installation type and then click submit.', 'required', null, 'client'); $form->setDefaults(array('mysql_user' => $_SERVER['PHP_AUTH_USER'], 'mysql_password' => $_SERVER['PHP_AUTH_PW'])); if ($form->validate()) { $tarpath = $form->process(array(&$this, 'db2app__process'), true); header('Content-type: application/x-gzip'); header('Content-Disposition: attachment; filename="' . basename($tarpath) . '.tar.gz"'); echo file_get_contents($tarpath); exit; } require_once 'HTML/QuickForm/Renderer/Array.php'; $renderer = new HTML_QuickForm_Renderer_Array(true, true, true); $form->accept($renderer); $context = $renderer->toArray(); //print_r($context); ob_start(); $form->display(); $out = ob_get_contents(); ob_end_clean(); include 'install' . DIRECTORY_SEPARATOR . 'db2app.inc.php'; }
$user->user['need_pwd_change'] = 0; $user->persist(); unset($_SESSION['s_index_comply']); if ($GLOBALS['configuration']['show_license_note'] && $user->user['viewed_license'] == 0) { eF_redirect("index.php?ctg=agreement"); } else { EfrontEvent::triggerEvent(array("type" => EfrontEvent::SYSTEM_VISITED, "users_LOGIN" => $user->user['login'], "users_name" => $user->user['name'], "users_surname" => $user->user['surname'])); loginRedirect($user->user['user_type']); } } } } $renderer = new HTML_QuickForm_Renderer_ArraySmarty($smarty); $changePasswordForm->setJsWarnings(_BEFOREJAVASCRIPTERROR, _AFTERJAVASCRIPTERROR); $changePasswordForm->setRequiredNote(_REQUIREDNOTE); $changePasswordForm->accept($renderer); $smarty->assign('T_CHANGE_PASSWORD_FORM', $changePasswordForm->toArray()); } catch (Exception $e) { eF_redirect("index.php?message=" . urlencode($e->getMessage() . " (" . $e->getCode() . ")") . "&message_type=failure"); } } } /* ---------------------------------------------------------Activation by email part--------------------------------------------------------- */ if (isset($_GET['account']) && isset($_GET['key']) && eF_checkParameter($_GET['account'], 'login') && eF_checkParameter($_GET['key'], 'timestamp')) { if ($configuration['activation'] == 0 && $configuration['mail_activation'] == 1 || $configuration['supervisor_mail_activation'] == 1) { $result = eF_getTableData("users", "timestamp, active", "login='******'account'] . "'"); if ($result[0]['active'] == 0 && $result[0]['timestamp'] == $_GET['key']) { try { $user = EfrontUserFactory::factory($_GET['account']); //new EfrontUser($_GET['login']); $user->activate();
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; }
} $backup_form = new HTML_QuickForm("backup_form", "post", basename($_SERVER['PHP_SELF']) . '?ctg=backup', "", null, true); $backup_form->registerRule('checkParameter', 'callback', 'eF_checkParameter'); //Register this rule for checking user input with our function, eF_checkParameter $backup_form->addElement('text', 'backupname', null, 'class = "inputText"'); $backup_form->addRule('backupname', _THEFIELD . ' ' . _FILENAME . ' ' . _ISMANDATORY, 'required', null, 'client'); $backup_form->setDefaults(array("backupname" => "backup_" . date('Y_m_d_h.i.s', time()))); if ($GLOBALS['configuration']['version_hosted']) { $backupTypes = array("0" => _DATABASEONLY); } else { $backupTypes = array("0" => _DATABASEONLY, "1" => _ALLDATABACKUP); if (strtoupper(substr(PHP_OS, 0, 3)) !== 'WIN') { $backupTypes[3] = _ALLDATASYSTEMBACKUP; } } $backup_form->addElement('select', 'backuptype', null, $backupTypes); $backup_form->addElement('submit', 'submit_backup', _TAKEBACKUP, 'class = "flatButton" onclick = "$(\'backup_image\').show();"'); if ($backup_form->isSubmitted() && $backup_form->validate()) { $values = $backup_form->exportValues(); try { $backupFile = EfrontSystem::backup($values['backupname'] . '.zip', $values['backuptype']); eF_redirect("" . basename($_SERVER['PHP_SELF']) . "?ctg=backup&message=" . urlencode(_SUCCESFULLYBACKEDUP) . "&message_type=success"); } catch (EfrontFileException $e) { $smarty->assign("T_EXCEPTION_TRACE", $e->getTraceAsString()); $message = $e->getMessage() . ' <a href = "javascript:void(0)" onclick = "eF_js_showDivPopup(event, \'' . _ERRORDETAILS . '\', 2, \'error_details\')">' . _MOREINFO . '</a>'; $message_type = failure; } } $renderer = new HTML_QuickForm_Renderer_ArraySmarty($smarty); $backup_form->accept($renderer); $smarty->assign('T_BACKUP_FORM', $renderer->toArray());
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"; } } }
public function getModule() { $smarty = $this->getSmartyVar(); $currentLesson = $this->getCurrentLesson(); $currentUser = $this->getCurrentUser(); try { $currentContent = new EfrontContentTree($_SESSION['s_lessons_ID']); //Initialize content } catch (Exception $e) { $smarty->assign("T_EXCEPTION_TRACE", $e->getTraceAsString()); $message = _ERRORLOADINGCONTENT . ": " . $_SESSION['s_lessons_ID'] . ": " . $e->getMessage() . ' (' . $e->getCode() . ') <a href = "javascript:void(0)" onclick = "eF_js_showDivPopup(event, \'' . _ERRORDETAILS . '\', 2, \'error_details\')">' . _MOREINFO . '</a>'; } //pr($currentUser);exit; $roles = EfrontUser::getRoles(); //pr($roles); if ($roles[$currentUser->lessons[$_SESSION['s_lessons_ID']]] == "professor") { if (isset($_GET['view_list']) && eF_checkParameter($_GET['view_list'], 'id')) { $list = $currentContent->seekNode($_GET['view_list']); $questions = $list->getQuestions(true); $crosslists = array(); $possibleCrosslistsIds = array(); foreach ($questions as $key => $value) { if ($value->question['type'] == 'empty_spaces') { $crosslists[] = $value; $possibleCrosslistsIds[] = $value->question['id']; } } $questions = $crosslists; //pr($questions); foreach ($questions as $qid => $question) { $questions[$qid]->question['text'] = str_replace('#', '_', strip_tags($question->question['text'])); //If we ommit this line, then the questions list is html formatted, images are displayed etc, which is *not* the intended behaviour //$questions[$qid]->question['answer'] = unserialize($question->question['answer']); } $res = eF_getTableData("module_crossword_words", "crosslists,options", "content_ID=" . $_GET['view_list']); $resCrosslists = unserialize($res[0]['crosslists']); $smarty->assign("T_CROSSWORD_LIST_WORDS", $resCrosslists); $post_target = $this->moduleBaseUrl . '&view_list=' . $_GET['view_list'] . "&tab=options"; //Create form elements $form = new HTML_QuickForm("list_options", "post", $post_target, "", null, true); $form->registerRule('checkParameter', 'callback', 'eF_checkParameter'); $form->addElement('advcheckbox', 'active', _CROSSWORD_ACTIVE, null, 'class = "inputCheckbox"', array(0, 1)); $form->addElement("text", "max_word", _LOW, 'size = "5"'); $form->addRule('max_word', _INVALIDFIELDDATA . ":" . _LOW, 'checkParameter', 'id'); $form->addElement('advcheckbox', 'reveal_answer', _CROSSWORD_SHOWANSWERFIRST, null, 'class = "inputCheckbox"', array(0, 1)); $form->addElement('advcheckbox', 'save_pdf', _CROSSWORD_SAVEPDF, null, 'class = "inputCheckbox"', array(0, 1)); $form->addElement('submit', 'submit_options', _SAVECHANGES, 'onclick ="return optionSubmit();" class = "flatButton"'); //The submit content button $options = unserialize($res[0]['options']); $form->setDefaults(array('active' => $options['active'], 'reveal_answer' => $options['reveal_answer'], 'save_pdf' => $options['save_pdf'], 'max_word' => $options['max_word'])); if ($form->isSubmitted() && $form->validate()) { //If the form is submitted and validated $values = $form->exportValues(); unset($values['submit_options']); $options = serialize($values); if (sizeof($res) != 0) { $ok = eF_updateTableData("module_crossword_words", array('options' => $options), "content_ID=" . $_GET['view_list']); } else { $fields = array('content_ID' => $_GET['view_list'], 'options' => $options); $ok = eF_insertTableData("module_crossword_words", $fields); } if ($ok !== false) { $message = _CROSSWORD_SUCCESSFULLY; $message_type = 'success'; } else { $message = _CROSSWORD_PROBLEMOCCURED; $message_type = 'failure'; } eF_redirect("" . $this->moduleBaseUrl . "&view_list=" . $_GET['view_list'] . "&tab=options&message=" . urlencode($message) . "&message_type=" . $message_type); } $renderer = new HTML_QuickForm_Renderer_ArraySmarty($smarty); //Create a smarty renderer $form->setJsWarnings(_BEFOREJAVASCRIPTERROR, _AFTERJAVASCRIPTERROR); //Set javascript error messages $form->setRequiredNote(_REQUIREDNOTE); $form->accept($renderer); //Assign this form to the renderer, so that corresponding template code is created $smarty->assign('T_CROSSWORD_OPTIONS', $renderer->toArray()); //Assign the form to the template if (isset($_GET['postAjaxRequest'])) { try { $result = eF_getTableData("module_crossword_words", "crosslists", "content_ID=" . $_GET['view_list']); //pr($result);exit; $crosslistsArray = unserialize($result[0]['crosslists']); if (isset($_GET['id']) && eF_checkParameter($_GET['id'], 'id')) { if (!in_array($_GET['id'], array_values($crosslistsArray))) { $crosslistsArray[] = $_GET['id']; $crosslists = serialize($crosslistsArray); if (sizeof($result) != 0) { $fields = array('crosslists' => $crosslists); eF_updateTableData("module_crossword_words", $fields, "content_ID=" . $_GET['view_list']); } else { $fields = array('content_ID' => $_GET['view_list'], 'crosslists' => $crosslists); eF_insertTableData("module_crossword_words", $fields); } } elseif (in_array($_GET['id'], array_values($crosslistsArray))) { unset($crosslistsArray[array_search($_GET['id'], $crosslistsArray)]); if (!empty($crosslistsArray)) { $crosslists = serialize($crosslistsArray); $fields = array('crosslists' => $crosslists); eF_updateTableData("module_crossword_words", $fields, "content_ID=" . $_GET['view_list']); } else { eF_deleteTableData("module_crossword_words", "content_ID=" . $_GET['view_list']); } } } else { if (isset($_GET['addAll'])) { $crosslists = serialize($possibleCrosslistsIds); if (sizeof($result) != 0) { $fields = array('crosslists' => $crosslists); eF_updateTableData("module_crossword_words", $fields, "content_ID=" . $_GET['view_list']); } else { $fields = array('content_ID' => $_GET['view_list'], 'crosslists' => $crosslists); eF_insertTableData("module_crossword_words", $fields); } } else { if (isset($_GET['removeAll'])) { $fields = array('crosslists' => ""); eF_updateTableData("module_crossword_words", $fields, "content_ID=" . $_GET['view_list']); } } } } catch (Exception $e) { header("HTTP/1.0 500 "); echo $e->getMessage() . ' (' . $e->getCode() . ')'; } exit; } $smarty->assign("T_CROSSWORD_CROSSLISTS", $crosslists); $smarty->assign("T_CROSSWORD_CROSSLISTS_SIZE", sizeof($crosslists)); } else { $listsArray = array(); $iterator = new EfrontContentFilterIterator(new EfrontNodeFilterIterator(new RecursiveIteratorIterator($currentContent->tree, RecursiveIteratorIterator::SELF_FIRST))); foreach ($iterator as $key => $value) { $questions = $value->getQuestions(true); $crosslists = array(); foreach ($questions as $key2 => $value2) { if ($value2->question['type'] == 'empty_spaces') { $crosslists[] = $value2; } } if (sizeof($crosslists) > 0) { $listsArray[$value['id']] = array('id' => $value['id'], 'name' => $value['name'], 'questions' => sizeof($crosslists)); } } if (!empty($listsArray)) { $str = implode(",", array_keys($listsArray)); $lists = eF_getTableDataFlat("module_crossword_words", "*", "content_ID IN (" . $str . ")"); $listsTemp = array_combine(array_values($lists['content_ID']), array_values($lists['options'])); $listsTemp2 = array_combine(array_values($lists['content_ID']), array_values($lists['crosslists'])); foreach ($listsArray as $key => $value) { $listsArray[$value['id']]['options'] = unserialize($listsTemp[$key]); $crosslistsTemp = unserialize($listsTemp2[$key]); $listsArray[$value['id']]['num_crosslists'] = empty($crosslistsTemp) ? 0 : sizeof($crosslistsTemp); } } $smarty->assign("T_CROSSWORD_WORDS", $listsArray); } } elseif ($roles[$currentUser->lessons[$_SESSION['s_lessons_ID']]] == "student") { if (isset($_GET['restart_list']) && eF_checkParameter($_GET['restart_list'], 'id')) { eF_deleteTableData("module_crossword_users", "users_LOGIN='******'s_login'] . "' AND content_ID=" . $_GET['restart_list']); } if (isset($_GET['restart_lists'])) { eF_deleteTableData("module_crossword_users", "users_LOGIN='******'s_login'] . "'"); } if ($_GET['answer'] == "true") { $resUserCard = eF_getTableData("module_crossword_users", "*", "crosslists_ID=" . $_GET['view_card'] . " and users_LOGIN='******'s_login'] . "'"); if (sizeof($resUserCard) == 0) { $fields = array('users_LOGIN' => $_SESSION['s_login'], 'content_ID' => $_GET['view_list'], 'crosslists_ID' => $_GET['view_card'], 'success' => '1'); eF_insertTableData("module_crossword_users", $fields); } else { $success = $resUserCard[0]['success'] + 1; eF_updateTableData("module_crossword_users", array('success' => $success), "crosslists_ID=" . $_GET['view_card'] . " and users_LOGIN='******'s_login'] . "'"); } } elseif ($_GET['answer'] == "false") { $resUserCard = eF_getTableData("module_crossword_users", "*", "crosslists_ID=" . $_GET['view_card'] . " and users_LOGIN='******'s_login'] . "'"); $currentListTemp = eF_getTableData("module_crossword_words", "options", "content_ID=" . $_GET['view_list']); $listTemp = unserialize($currentListTemp[0]['options']); if ($listTemp['wrong'] == 1 && sizeof($resUserCard) != 0 && $resUserCard[0]['success'] != 0) { $success = $resUserCard[0]['success'] - 1; eF_updateTableData("module_crossword_users", array('success' => $success), "crosslists_ID=" . $_GET['view_card'] . " and users_LOGIN='******'s_login'] . "'"); } } $listsArray = array(); $iterator = new EfrontContentFilterIterator(new EfrontNodeFilterIterator(new RecursiveIteratorIterator($currentContent->tree, RecursiveIteratorIterator::SELF_FIRST))); foreach ($iterator as $key => $value) { $listsArray[$value['id']] = array('id' => $value['id'], 'name' => $value['name']); } if (empty($listsArray)) { $smarty->assign("T_CROSSWORD_WORDSNAMES", $listsArray); return true; } $str = implode(",", array_keys($listsArray)); $lists = eF_getTableData("module_crossword_words", "*", "content_ID IN (" . $str . ")"); $mastery = eF_getTableDataFlat("module_crossword_users", "*", "content_ID IN (" . $str . ")"); $masteryArray = array_combine(array_values($mastery['crosslists_ID']), array_values($mastery['success'])); $questionsDiff = eF_getTableDataFlat("questions", "*", "content_ID IN (" . $str . ")"); $questionsDiffArray = array_combine(array_values($questionsDiff['id']), array_values($questionsDiff['difficulty'])); $validLists = array(); foreach ($lists as $key => $value) { $opt = unserialize($value['options']); $crosslists = unserialize($value['crosslists']); if ($opt['active'] == 1 && !empty($crosslists)) { $value['number_crosslists'] = empty($crosslists) ? 0 : sizeof($crosslists); $validLists[$value['content_ID']] = $value; $validLists[$value['content_ID']]['options'] = $opt; $finishedCrosslists = 0; foreach ($crosslists as $index => $item) { if ($masteryArray[$item] == $opt[$questionsDiffArray[$item]]) { $finishedCrosslists++; } } $conid = $validLists[$value['content_ID']]['content_ID']; $validLists[$value['content_ID']]['non_finished'] = $value['number_crosslists'] - $finishedCrosslists; $validLists[$value['content_ID']]['mastery'] = (double) $finishedCrosslists / sizeof($crosslists) * 100; $respoints = eF_getTableDataFlat("module_crossword_users", "*", "content_ID = '{$conid}' and users_LOGIN='******'s_login'] . "'"); $validLists[$value['content_ID']]['points'] = round($respoints['points'][0] / $respoints['totallength'][0] * 100); $validLists[$value['content_ID']]['crosstime'] = $respoints['wordtime'][0]; } } //print_r($validLists); $smarty->assign("T_CROSSWORD_WORDS", $validLists); $smarty->assign("T_CROSSWORD_WORDSNAMES", $listsArray); if (isset($_GET['view_list']) && !isset($_GET['pdf'])) { $resunit = eF_getTableData("content", "name", "id=" . $_GET['view_list']); $smarty->assign("T_CROSSWORD_UNITNAME", $resunit[0]['name']); $_SESSION['contentid'] = $_GET['view_list']; if (isset($_POST) && !empty($_POST['crosstime'])) { $userlist = eF_getTableData("module_crossword_users", "*", "users_LOGIN='******'s_login'] . "' and content_ID=" . $_GET['view_list'] . ""); if (count($userlist) == 0) { $fields = array('users_LOGIN' => $_SESSION['s_login'], 'content_ID' => $_GET['view_list'], 'points' => $_POST['points'], 'totallength' => $_SESSION['WORDLEN'], 'wordtime' => $_POST['crosstime']); eF_insertTableData("module_crossword_users", $fields); } else { $fields = array('points' => $_POST['points'], 'totallength' => $_SESSION['WORDLEN'], 'wordtime' => $_POST['crosstime']); eF_updateTableData("module_crossword_users", $fields, "content_ID=" . $_GET['view_list'] . " and users_LOGIN='******'s_login'] . "'"); } $message_type = 'success'; $message = _CROSSWORD_GAME_SUCCESSFULLY; eF_redirect($this->moduleBaseUrl . "&message=" . urlencode($message) . "&message_type=" . $message_type); } $contentid = $_GET['view_list']; $res = eF_getTableData("module_crossword_words", "crosslists,options", "content_ID=" . $_GET['view_list']); $reswords = unserialize($res[0]['crosslists']); $maxwords = unserialize($res[0]['options']); $maxwords1 = $maxwords['max_word']; $smarty->assign("T_CROSSWORD_REVEALANSWER", $maxwords['reveal_answer']); $smarty->assign("T_CROSSWORD_MAXWORD", $maxwords1 + 1); $_SESSION['CROSSWORD_MAXWORD'] = $maxwords1; require_once 'init.php'; $rowquesans = ""; foreach ($reswords as $rowques) { $rowquesans .= $rowques . ","; } $quesids = mb_substr($rowquesans, 0, -1); $quesans = eF_getTableData("questions", "text,answer", "id IN({$quesids}) order by rand() limit {$maxwords1}"); $value = array(); foreach ($quesans as $row) { $answer = unserialize($row['answer']); $answer1 = explode("|", $answer['0']); $value[] = array('ANSWER' => $answer1['0'], 'QUESTION' => $row['text']); } if (!empty($value)) { //pr($value);exit; $success = $pc->generateFromWords($value); if (!$success) { $message_type = 'failure'; $message = _CROSSWORD_UNABLEGENERATECROSSWORD; eF_redirect($this->moduleBaseUrl . "&message=" . urlencode($message) . "&message_type=" . $message_type); } else { $words = $pc->getWords(); $wordlen = ""; foreach ($words as $rowwords) { $wordlen = $wordlen + $rowwords['wordlength']; } $_SESSION['WORDLEN'] = $wordlen; $smarty->assign("T_CROSSWORD_LENGTH", $_SESSION['WORDLEN']); //vd($words); //because of #1599 foreach ($words as $key => $word) { $words[$key]['question'] = str_replace(array("\r\n", "\n"), '<br/>', $word['question']); } //vd($words); $smarty->assign("T_CROSSWORD_ANSWERS", $words); } } $post_target = $this->moduleBaseUrl . "&view_list=" . $_GET['view_list'] . ""; $form = new HTML_QuickForm("crossword_game", "post", $post_target, "", null, true); $form->addElement('submit', 'submit_crossword', 'SUBMIT', 'class = "flatButton"'); //The submit content button $renderer = new HTML_QuickForm_Renderer_ArraySmarty($smarty); //Create a smarty renderer $form->setJsWarnings(_BEFOREJAVASCRIPTERROR, _AFTERJAVASCRIPTERROR); //Set javascript error messages $form->setRequiredNote(_REQUIREDNOTE); $form->accept($renderer); //Assign this form to the renderer, so that corresponding template code is created $smarty->assign('T_CROSSWORD_SUBMIT', $renderer->toArray()); //Assign the form to the template $message = ""; //$message_type = 'success'; // eF_redirect("".$this -> moduleBaseUrl."&popup=1&finish=1&message=".$message."&message_type=".$message_type); } else { if (isset($_GET['view_list']) && isset($_GET['pdf']) && $_GET['pdf'] == 'cross') { $resunit = eF_getTableData("content", "name,lessons_ID", "id=" . $_GET['view_list']); $reslesson = eF_getTableData("lessons", "name", "id=" . $resunit[0]['lessons_ID']); $res = eF_getTableData("module_crossword_words", "crosslists,options", "content_ID=" . $_GET['view_list']); $reswords = unserialize($res[0]['crosslists']); $maxwords = unserialize($res[0]['options']); $maxwords1 = $maxwords['max_word']; $_SESSION['CROSSWORD_MAXWORD'] = $maxwords1; require_once 'init.php'; $rowquesans = ""; foreach ($reswords as $rowques) { $rowquesans .= $rowques . ","; } $quesids = mb_substr($rowquesans, 0, -1); $quesans = eF_getTableData("questions", "text,answer", "id IN({$quesids}) order by rand() limit {$maxwords1}"); $value = array(); foreach ($quesans as $row) { $answer = unserialize($row['answer']); $answer1 = explode("|", $answer['0']); $value[] = array('ANSWER' => $answer1['0'], 'QUESTION' => $row['text']); } $success = $pc->generateFromWords($value); if (!$success) { $message_type = 'failure'; $message = _CROSSWORD_UNABLEGENERATECROSSWORD; eF_redirect($this->moduleBaseUrl . "&message=" . urlencode($message) . "&message_type=" . $message_type); } else { $currentlesson = $reslesson[0]['name']; $words = $pc->getWords(); $answor = array(); $html1 = array(); $html2 = array(); $html1[] = $currentlesson; $html1[] .= $resunit[0]['name']; $html1[] .= _CROSSWORD_ACROSS; $html2[] = _CROSSWORD_DOWN; $k = 1; //pr($words); foreach ($words as $row) { if ($row['axis'] == 1) { $html1[] .= $k . '. ' . $row['question']; } else { $html2[] .= $k . '. ' . $row['question']; } $k++; } //pr($html1); //pr($html2); //exit; $answor[] = array_merge($html1, $html2); //pr($answor); exit; $dd = $pc->getHTML($answor); exit; } } } } return true; }
//pr($user_profile_dates); $smarty->assign("T_USER_PROFILE_DATES", $user_profile_dates); } } #cpp#endif $smarty->assign("T_DATES_SEARCH_CRITERIA", implode(",", $datesFields)); $renderer = new HTML_QuickForm_Renderer_ArraySmarty($smarty); $renderer->setRequiredTemplate('{$html}{if $required} <span class = "formRequired">*</span> {/if}'); // Management of the 'send email to all found' link icon on the top right of the table // During page load create the item $mass_operations = array(array('id' => 'groupUsersId', 'text' => _SETFOUNDEMPLOYEESINTOGROUP, 'image' => "16x16/users.png", 'href' => "javascript:void(0);", "onclick" => "eF_js_showDivPopup(event, '" . _SETFOUNDEMPLOYEESINTOGROUP . "', 0, 'insert_into_group')", 'target' => 'POPUP_FRAME'), array('id' => 'sendToAllId', 'text' => _SENDMESSAGETOALLFOUNDEMPLOYEES, 'image' => "16x16/mail.png", 'href' => "javascript:void(0);", "onclick" => "var recipient = '&recipient='+document.getElementById('usersFound').value;this.href='" . $currentUser->getType() . ".php?ctg=messages&add=1&popup=1'+recipient;eF_js_showDivPopup(event, '" . _SENDMESSAGE . "', 2)", 'target' => 'POPUP_FRAME')); $smarty->assign("T_SENDALLMAIL_LINK", $mass_operations); $form->setJsWarnings(_BEFOREJAVASCRIPTERROR, _AFTERJAVASCRIPTERROR); $form->setRequiredNote(_REQUIREDNOTE); $form->accept($renderer); $smarty->assign('T_REPORT_FORM', $renderer->toArray()); // Popup to set to custom group form $group_form = new HTML_QuickForm("insert_into_groups_form", "post", $_SESSION['s_type'] . ".php?ctg=search_users&search=1&branch_ID=" . $_GET['branch_ID'] . "&job_description_ID=" . $_GET['job_description_ID'], "", null, true); $groups = array("0" => _INSERTINTONEWGROUP); $groupsResult = EfrontGroup::getGroups(); foreach ($groupsResult as $group) { $groups[$group['id']] = $group['name']; } $group_form->addElement('select', 'existing_group', _INSERTINTOEXISTINGGROUP, $groups, 'id = "existing_group_id" class = "inputSelectMed" onchange="javascript:updateNewGroup(this, \'new_group_id\')"'); $group_form->addElement('text', 'new_group', _NEWGROUPNAME, 'class = "inputText" id="new_group_id" onChange="javascript:$(\'existing_group_id\').value = 0;"'); $group_form->setJsWarnings(_BEFOREJAVASCRIPTERROR, _AFTERJAVASCRIPTERROR); $group_form->setRequiredNote(_REQUIREDNOTE); $group_form->accept($renderer); $smarty->assign('T_INSERT_INTO_GROUP_POPUP_FORM', $renderer->toArray());
/** * Get the create directory form * * This function is responsible for creating the "create directory" * form, as well as the equivalent HTML code. * * @param HTML_QuickForm $form The form to populate * @return string The HTML code of the form * @since 3.5.0 * @access protected */ protected function getCreateDirectoryForm(&$form) { $form->registerRule('checkParameter', 'callback', 'eF_checkParameter'); //Register this rule for checking user input with our function, eF_checkParameter $form->addElement('text', 'create_directory', null, 'class = "inputText"'); $form->addElement('hidden', 'current_directory', null, 'id = "current_directory" class = "inputText"'); $form->addElement('submit', 'submit_create_directory', _CREATE, 'class = "flatButton"'); $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">' . _FOLDERNAME . ': </td> <td class = "elementCell">' . $formArray['create_directory']['html'] . '</td></tr> <tr><td></td> <td class = "elementCell"> ' . $formArray['submit_create_directory']['html'] . ' </td></tr> </table> </form>'; return $formString; }
public function getModule() { $smarty = $this->getSmartyVar(); global $load_editor; $load_editor = true; $current_user = $this->getCurrentUser(); $smarty->assign("T_MODULE_CURRENT_USER", $current_user->getType()); $form = new HTML_QuickForm("module_mail_form", "post", $this->moduleBaseUrl, "", "id = 'module_mail_form'"); $form->addElement('hidden', 'recipients', $_GET['rec']); $form->addElement('text', 'subject', _SUBJECT, 'class = "inputText" style = "width:400px"'); $form->addElement('textarea', 'body', _BODY, 'class = "simpleEditor" style = "width:100%;height:200px"'); $form->addElement('checkbox', 'email', _SENDASEMAILALSO, null, 'id = "send_as_email" class = "inputCheckBox"'); $form->addRule('subject', _THEFIELD . ' "' . _SUBJECT . '" ' . _ISMANDATORY, 'required', null, 'client'); $form->addRule('recipients', _THEFIELD . ' "' . _RECIPIENTS . '" ' . _ISMANDATORY, 'required', null, 'client'); $form->addElement('file', 'attachment[0]', _ATTACHMENT, null, 'class = "inputText"'); $form->addElement('submit', 'submit_mail', _SEND, 'class = "flatButton"'); if ($form->isSubmitted() && $form->validate()) { $values = $form->exportValues(); switch ($values['recipients']) { case "lesson_students": $lesson = new EfrontLesson($_SESSION['s_lessons_ID']); $lessonUsers = $lesson->getUsers("student"); foreach ($lessonUsers as $value) { $mail_recipients[] = $value['login']; } //pr($mail_recipients);return; break; case "lesson_professors": $lesson = new EfrontLesson($_SESSION['s_lessons_ID']); $lessonUsers = $lesson->getUsers("professor"); if (isset($_SESSION['s_courses_ID'])) { $course = new EfrontCourse($_SESSION['s_courses_ID']); $course_users = $course->getCourseUsers(); foreach ($lessonUsers as $key => $value) { if (!isset($course_users[$key])) { unset($lessonUsers[$key]); } } } foreach ($lessonUsers as $value) { $mail_recipients[] = $value['login']; } break; case "admin": $result = eF_getTableData("users", "*", "user_type='administrator' and user_types_ID=0 and archive = 0"); //not foreach ($result as $value) { $mail_recipients[] = $value['login']; } break; } //$list = implode(",",$mail_recipients); $pm = new eF_PersonalMessage($_SESSION['s_login'], $mail_recipients, $values['subject'], $values['body']); if ($_FILES['attachment']['name'][0] != "") { $maxFileSize = FileSystemTree::getUploadMaxSize(); if ($_FILES['attachment']['size'][0] == 0 || $_FILES['attachment']['size'][0] > $maxFileSize * 1024) { // G_MAXFILESIZE is deprecated $message = _EACHFILESIZEMUSTBESMALLERTHAN . " " . G_MAXFILESIZE . " Bytes"; $message_type = 'failure'; } //Upload user avatar file $pm->sender_attachment_timestamp = time(); $user_dir = G_UPLOADPATH . $_SESSION['s_login'] . '/message_attachments/Sent/' . $pm->sender_attachment_timestamp . '/'; mkdir($user_dir, 0755); $filesystem = new FileSystemTree($user_dir); $uploadedFile = $filesystem->uploadFile('attachment', $user_dir, 0); $pm->sender_attachment_fileId = $uploadedFile['id']; $pm->setAttachment($uploadedFile['path']); } if ($pm->send($values['email'], $values)) { $message = _MESSAGEWASSENT; $message_type = 'success'; } else { $message = $pm->errorMessage; $message_type = 'failure'; } } $renderer = new HTML_QuickForm_Renderer_ArraySmarty($smarty); //Create a smarty renderer $renderer->setRequiredTemplate('{$html}{if $required} <span class = "formRequired">*</span> {/if}'); $form->setJsWarnings(_BEFOREJAVASCRIPTERROR, _AFTERJAVASCRIPTERROR); //Set javascript error messages $form->setRequiredNote(_REQUIREDNOTE); $form->accept($renderer); //Assign this form to the renderer, so that corresponding template code is created $smarty->assign('T_MODULE_MAIL_FORM', $renderer->toArray()); $smarty->assign("T_MESSAGE_MAIL", $message); $smarty->assign("T_MESSAGE_MAIL_TYPE", $message_type); //pr($renderer -> toArray()); return true; }
public function getModule() { $smarty = $this->getSmartyVar(); // Always show the preview of the data if ($_POST['preview'] || $_POST['submit']) { if ($_POST['questions_format'] == "gift") { $questions = $this->scanGIFT($_POST['imported_data']); } else { $questions = $this->scanAIKEN(str_replace('\\"', '"', str_replace("\\'", "'", $_POST['imported_data']))); } if (sizeof($questions)) { $smarty->assign("T_PREVIEW_DIV", $this->createPreviewHTML($questions)); } } // Submit the data the data if ($_POST['submit']) { if ($_POST['select_unit'] == -1 || $_POST['select_unit'] == -2) { $content_ID = 0; } else { $content_ID = $_POST['select_unit']; } $currentLesson = $this->getCurrentLesson(); $lessons_ID = $currentLesson->lesson['id']; $count = 0; foreach ($questions as $key => $question) { if ($question['type'] != "same" && $question['type'] != "error" && $question['type'] != "no_answer_error") { $question['content_ID'] = $content_ID; $question['lessons_ID'] = $lessons_ID; $question['difficulty'] = "medium"; if (sizeof($question['options'])) { $question['options'] = serialize($question['options']); //$question['options'] = str_replace("'", "'", $question['options']); //$question['options'] = str_replace("\r", "", $question['options']); } if (sizeof($question['answer'])) { // Different accounting for answers of multiple many type if ($question['type'] == "multiple_many") { $answers = array(); foreach ($question['answer'] as $answer) { $answers[$answer] = "1"; } $question['answer'] = $answers; } $question['answer'] = serialize($question['answer']); //$question['answer'] = str_replace("'", "'", $question['answer']); //$question['answer'] = str_replace("\r", "", $question['answer']); } //$question['text'] = str_replace("'", "'", $question['text']); if (isset($question['explanation'])) { //$question['explanation'] = str_replace("'", "'", $question['explanation']); //$question['explanation'] = str_replace("\r", "", $question['explanation']); } if (Question::createQuestion($question)) { $count++; } } } if ($count) { $this->setMessageVar($count . " " . _GIFTAIKEN_QUESTIONSIMPORTEDSUCCESSFULLY, "success"); } else { $this->setMessageVar(_GIFTAIKEN_NOQUESTIONCOULDBEIMPORTED, "failure"); } } $pos = strpos($_SERVER['REQUEST_URI'], "&message"); if ($pos) { $postUrl = substr($_SERVER['REQUEST_URI'], 0, $pos); } else { $postUrl = $_SERVER['REQUEST_URI']; } $importForm = new HTML_QuickForm("import_users_form", "post", $postUrl, "", null, true); $importForm->registerRule('checkParameter', 'callback', 'eF_checkParameter'); //Register this rule for checking user input with our function, eF_checkParameter $importForm->addElement('radio', 'questions_format', _GIFTAIKEN_GIFT, null, 'gift', 'id="gift_selection"'); $importForm->addElement('radio', 'questions_format', _GIFTAIKEN_AIKEN, null, 'aiken', 'id="aiken_selection"'); $currentLesson = $this->getCurrentLesson(); $currentContent = new EfrontContentTree($currentLesson->lesson['id']); $smarty->assign("T_UNITS", $currentContent->toHTMLSelectOptions()); $importForm->addElement('textarea', 'imported_data', _GIFTAIKEN_QUESTIONDATATOIMPORT, 'class = "inputProjectTextarea" id="imported_data"'); $importForm->addElement('submit', 'preview', _PREVIEW, 'class=flatButton onclick="$(\'import_users_form\').action += \'&preview=1\'"'); $importForm->addElement('submit', 'submit', _SUBMIT, 'class=flatButton'); $renderer = new HTML_QuickForm_Renderer_ArraySmarty($smarty); $importForm->setJsWarnings(_BEFOREJAVASCRIPTERROR, _AFTERJAVASCRIPTERROR); $importForm->setRequiredNote(_REQUIREDNOTE); $importForm->accept($renderer); $smarty->assign('T_GIFTAIKENQUESTIONS_FORM', $renderer->toArray()); return true; }
public function getModule() { // Get smarty variable $smarty = $this->getSmartyVar(); if (isset($_GET['delete_faq']) && eF_checkParameter($_GET['delete_faq'], 'id')) { eF_deleteTableData("module_faq", "id=" . $_GET['delete_faq']); eF_redirect("" . $this->moduleBaseUrl . "&message=" . urlencode(_FAQ_SUCCESFULLYDELETEDFAQENTRY) . "&message_type=success"); } else { if (isset($_GET['add_faq']) || isset($_GET['edit_faq']) && eF_checkParameter($_GET['edit_faq'], 'id')) { $load_editor = true; //TODO $form = new HTML_QuickForm("faq_entry_form", "post", $_SERVER['REQUEST_URI'], "", null, true); $form->registerRule('checkParameter', 'callback', 'eF_checkParameter'); //Register this rule for checking user input with our function, eF_checkParameter $form->addElement('textarea', 'question', null, 'class = "simpleEditor" style = "width:100%;height:5em;"'); $form->addElement('textarea', 'answer', null, 'class = "simpleEditor" style = "width:100%;height:25em;"'); $currentLesson = $this->getCurrentLesson(); $units = eF_getTableDataFlat("content", "id, name", "lessons_ID = " . $currentLesson->lesson['id']); //$units['id'] = array_merge(array("0"), $units['id']); //$units['name'] = array_merge(array(_FAQ_GENERAL_LESSON), $units['name']); sizeof($units) > 0 ? $units = array(0 => _FAQ_GENERAL_LESSON) + array_combine($units['id'], $units['name']) : ($units = array("0" => _FAQ_GENERAL_LESSON)); $form->addElement('select', 'related_content', _CONTENT, $units, 'class = "inputSelectLong"'); $form->addElement('submit', 'submit_faq', _SUBMIT, 'class = "flatButton"'); if (isset($_GET['edit_faq'])) { $faq_entry = eF_getTableData("module_faq", "*", "id=" . $_GET['edit_faq']); $form->setDefaults(array('related_content' => $faq_entry[0]['unit_ID'], 'question' => $faq_entry[0]['question'], 'answer' => $faq_entry[0]['answer'])); } if ($form->isSubmitted() && $form->validate()) { $fields = array('lessons_ID' => $_SESSION['s_lessons_ID'], 'unit_ID' => $form->exportValue('related_content'), 'question' => $form->exportValue('question'), 'answer' => $form->exportValue('answer')); if (isset($_GET['edit_faq'])) { if (eF_updateTableData("module_faq", $fields, "id=" . $_GET['edit_faq'])) { eF_redirect("" . $this->moduleBaseUrl . "&message=" . urlencode(_FAQ_SUCCESFULLYUPDATEDFAQENTRY) . "&message_type=success"); } else { $this->setMessageVar(_FAQ_PROBLEMUPDATINGFAQENTRY, 'failure'); } } else { if (eF_insertTableData("module_faq", $fields)) { eF_redirect("" . $this->moduleBaseUrl . "&message=" . urlencode(_FAQ_SUCCESFULLYINSERTEDFAQENTRY) . "&message_type=success"); } else { $this->setMessageVar(_FAQ_PROBLEMINSERTINGFAQENTRY, 'failure'); } } } $renderer = new HTML_QuickForm_Renderer_ArraySmarty($smarty); $form->accept($renderer); $smarty->assign('T_FAQ_FORM', $renderer->toArray()); } else { $currentLesson = $this->getCurrentLesson(); $faq = eF_getTableDataFlat("module_faq", "*", "lessons_ID=" . $currentLesson->lesson['id']); $currentUser = $this->getCurrentUser(); $smarty->assign("T_FAQUSERLESSONROLE", $currentUser->getRole($currentLesson)); $smarty->assign("T_FAQ", $faq); $smarty->assign("T_QUESTIONS_FOUND", sizeof($faq)); } } return true; }
public function __construct() { parent::__construct('add_category'); $this->loadHttpVars(); if ($this->loginError) { return; } $category = new pdCategory(); if (isset($this->cat_id)) { if (!is_numeric($this->cat_id)) { $this->pageError = true; return; } $result = $category->dbLoad($this->db, $this->cat_id); if (!$result) { $this->pageError = true; return; } } if (isset($this->numNewFields)) { if (!is_numeric($this->numNewFields)) { $this->pageError = true; return; } } else { $this->numNewFields = 0; } if ($category->cat_id != '') { $label = 'Edit Category'; } else { $label = 'Add Category'; } $this->pageTitle = $label; $form = new HTML_QuickForm('catForm'); $form->addElement('header', null, $this->helpTooltip($label, 'addCategoryPageHelp', 'helpHeading')); $form->addElement('text', 'catname', 'Category Name:', array('size' => 50, 'maxlength' => 250)); $form->addRule('catname', 'category name cannot be empty', 'required', null, 'client'); // info list $label = 'Related Fields:'; $info_list = pdInfoList::create($this->db); foreach ($info_list as $info_id => $name) { $form->addElement('advcheckbox', 'info[' . $info_id . ']', $label, $name, null, array('', $name)); $label = ''; } for ($i = 0; $i < $this->numNewFields; $i++) { $form->addElement('text', 'new_fields[' . $i . ']', 'New field ' . ($i + 1) . ':', array('size' => 50, 'maxlength' => 250)); } $form->addElement('hidden', 'numNewFields', $this->numNewFields); $form->addGroup(array(HTML_QuickForm::createElement('reset', 'reset', 'Reset'), HTML_QuickForm::createElement('button', 'add_field', 'Add Related Field', array('onClick' => 'dataKeep(' . ($this->numNewFields + 1) . ');')), HTML_QuickForm::createElement('submit', 'submit', 'Submit New Category')), 'submit_group', null, ' '); if ($form->validate()) { $values = $form->exportValues(); $category->category = $values['catname']; if (isset($values['new_fields'])) { $values['info'] = array_merge($values['info'], $values['new_fields']); } foreach ($values['info'] as $infoname) { if ($infoname == '') { continue; } $obj = new stdClass(); $obj->name = $infoname; $category->info[] = $obj; } $category->dbSave($this->db); echo 'Category "', $category->category, '" succesfully added to the database.', '<p/>', '<a href="' . $_SERVER['PHP_SELF'] . '">', 'Add another new category</a>'; } else { foreach (array_keys(get_class_vars(get_class($this))) as $member) { $defaults[$member] = $this->{$member}; } $defaults['catname'] = $category->category; if (isset($category->info) && count($category->info) > 0) { foreach ($category->info as $info_id => $name) { $defaults['info[' . $info_id . ']'] = $name; } } $form->setDefaults($defaults); $renderer =& $form->defaultRenderer(); $form->accept($renderer); $this->form =& $form; $this->renderer =& $renderer; $this->javascript(); } }
//Check here, whether the system is already locked, and present unlock button if ($lockdown_form->isSubmitted() && $lockdown_form->validate()) { //If the form is submitted and validated $values = $lockdown_form->exportValues(); if ($GLOBALS['configuration']['lock_down'] && isset($values['submit_unlock'])) { EfrontSystem::unlockSystem(); } elseif (isset($values['submit_lockdown'])) { EfrontSystem::lockSystem($values['lock_message'], $values['logout_users']); } elseif (isset($values['submit_message'])) { EfrontConfiguration::setValue('lock_message', $values['lock_message']); } eF_redirect(basename($_SERVER['PHP_SELF']) . "?ctg=maintenance&tab=lock_down"); } $renderer = new HTML_QuickForm_Renderer_ArraySmarty($smarty); //Create a smarty renderer $lockdown_form->accept($renderer); //Assign this form to the renderer, so that corresponding template code is created $smarty->assign('T_LOCKDOWN_FORM', $renderer->toArray()); //Assign the form to the template if ($_GET['check_cleanup'] || isset($_GET['cleanup'])) { //User check $users = eF_getTableDataFlat("users", "login"); //$users_dir = eF_getDirContents(G_ROOTPATH.'upload/', '', false, false); $users_dir = scandir(G_ROOTPATH . 'upload/'); foreach ($users_dir as $key => $value) { if (!is_dir(G_ROOTPATH . 'upload/' . $value) || !is_dir(G_ROOTPATH . 'upload/' . $value . '/message_attachments') || in_array($value, array('.', '..', '.svn'))) { unset($users_dir[$key]); } } $orphan_user_folders = array_diff($users_dir, $users['login']); $orphan_users = array_diff($users['login'], $users_dir);
/** * Remplit le layer de customisation des grids. * * @param object $tpl instanceof Template * @access private * @return void */ private function _customDisplay($tpl) { require_once 'HTML/QuickForm.php'; require_once 'HTML/QuickForm/Renderer/ArraySmarty.php'; require_once 'HTML/QuickForm/advmultiselect.php'; $renderer = new HTML_QuickForm_Renderer_ArraySmarty($tpl); $form = new HTML_QuickForm('gridCustomDisplay', 'post', $_SERVER['PHP_SELF']); $form->removeAttribute('name'); // XHTML compliance $defaultValues = array(); // Valeurs par defaut des champs du form $form->updateAttributes(array('onsubmit' => "return checkBeforeSubmit();")); //$form->updateAttributes(array('onsubmit' => '$(\'customDisplayUpdated\').value=1;')); $form->addElement('hidden', 'customDisplayUpdated', '0'); // Les plus souvent utilises $nbItemsArray = array(30 => 30, 50 => 50, 100 => 100, 150 => 150, 200 => 200, 300 => 300, 500 => 500); if ($this->paged) { $defaultItemPerPage = $this->itemPerPage; if (!in_array($defaultItemPerPage, $nbItemsArray)) { $nbItemsArray[$defaultItemPerPage] = $defaultItemPerPage; sort($nbItemsArray); } $form->addElement('select', 'customDisplayItemPerPage', _('Items number per page'), $nbItemsArray); // ToDo: MODIFIER en fction des saisies!! $defaultValues['customDisplayItemPerPage'] = $defaultItemPerPage; } $cols = array(); foreach ($this->columns as $colIndex => $column) { // Groupement de colonnes: toDo? // $column->groupCaption . ' ' . $column->title; if (!$column->enabled || $column->groupCount) { // On n'affiche que les column actives et continue; } // Pour la gestion des sous-grids, on nettoie l'entete $cols[$colIndex] = stripos($column->title, '</td><td>') !== false ? substr(str_replace('</td><td>', ', ', $column->title), 2, -2) : $column->title; } $labels = array(_('Columns') . ':', _('Available columns'), _('Columns to hide')); $elt = HTML_QuickForm::createElement('advmultiselect', 'customDisplayHiddenColumns', $labels, $cols, array('style' => 'width:100%;')); // Necessaire pour externaliser la tonne de js, si include js trouve $js = file_exists('JS_AdvMultiSelect.php') ? '' : '{javascript}'; $jsValidation = '<script type="text/javascript"> //<![CDATA[ function checkBeforeSubmit() { if ($(\'__customDisplayHiddenColumns\').options.length == 0) { alert("' . _("You can't hide all columns.") . '"); return false; } return true; } //]]> </script>'; $eltTemplate = $js . $jsValidation . ' <table{class}> <tr><th>{label_2}</th><th> </th><th>{label_3}</th></tr> <tr> <td valign="top">{unselected}</td> <td align="center">{add}{remove}</td> <td valign="top">{selected}</td> </tr> </table> '; $elt->setElementTemplate($eltTemplate); $form->addElement($elt); $form->addElement('submit', 'customDisplaySubmit', A_VALIDATE, 'onclick="this.form.customDisplayUpdated.value=1;"'); /*$form->addElement('button', 'customDisplaySetDefault', _('Default values'), 'onclick="fw.dom.selectOptionByValue($(\'customDisplayColumns\'), ' . JsTools::JSArray($nbItemsArray) . ');this.form.submit();"'); $(\'customDisplayUpdated\').value=1*/ $form->addElement('button', 'customDisplayCancel', A_CANCEL, 'onclick="fw.dom.toggleElement($(\'custom_display_layer\'));"'); $defaultValues['customDisplayHiddenColumns'] = $this->hiddenColumnsByUser; $form->setDefaults($defaultValues); // PATCH car advmultiselect buggé!! $elt->_values = $defaultValues['customDisplayHiddenColumns']; // end PATCH $form->accept($renderer); // affecte au form le renderer personnalise $tpl->assign('form', $renderer->toArray()); }
// Rest of representatives foreach ($representatives as $rep_specificid) { ++$c; $rep_info = $representatives_info[$rep_specificid]; if ($rep_specificid == $fyr_who) $form->addElement('static', '', null, $rep_info['name'] . ' is you!', $rep_specificid); else $form->addElement('radio', 'who', null, " <b>" . $rep_info['name'] . '</b><br>' . $rep_info['party'], $rep_specificid); } $form->addElement('hidden', 'action', 'doforward'); $form->addElement('hidden', 'id', $id); $form->addElement('submit', 'next', 'Forward Message >>'); $fyr_form_renderer = new HTML_QuickForm_Renderer_mySociety(); $form->accept($fyr_form_renderer); $right_column .= $fyr_form_renderer->toHtml(); array_push($fyr_representatives, array($left_column, $right_column)); debug_timestamp(); } // Display page, using all the fyr_* variables set above. template_draw("reps-forward", array("representative" => $representative, "voting_area" => $voting_area, "constituent" => $constituent, "message" => $message, "forwardreps" => $fyr_representatives)); } }
$dir = new EfrontDirectory(G_MODULESPATH . $module_folder . '/'); $dir->delete(); } } else { $message = _NOMODULECLASSFOUND . ' "' . $className . '" : ' . G_MODULESPATH . $module_folder; $message_type = 'failure'; //$dir = new EfrontDirectory(G_MODULESPATH.$module_folder.'/'); //$dir -> delete(); //eF_deleteFolder(G_MODULESPATH.$module_folder.'/'); } } else { if (!is_dir(G_MODULESPATH . $module_folder)) { $message = _THISFOLDERDOESNOTEXIT . ': ' . G_MODULESPATH . $module_folder; $message_type = 'failure'; } else { $message = _DESCRIPTIONFILECOULDNOTBEFOUND; $message_type = 'failure'; $dir = new EfrontDirectory(G_MODULESPATH . $module_folder . '/'); $dir->delete(); //eF_deleteFolder(G_MODULESPATH.$module_folder.'/'); } } } else { $message = _COULDNOTOPENZIPFILE; $message_type = 'failure'; } } } $renderer = new HTML_QuickForm_Renderer_ArraySmarty($smarty); $upload_form->accept($renderer); $smarty->assign('T_UPLOAD_FILE_FORM', $renderer->toArray());
$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); } }
function ic2_display($path, $params) { global $_conf, $ini, $thumb, $dpr, $redirect, $id, $uri, $file, $thumbnailer; if (P2_OS_WINDOWS) { $path = str_replace('\\', '/', $path); } if (strncmp($path, '/', 1) == 0) { $s = empty($_SERVER['HTTPS']) ? '' : 's'; $to = 'http' . $s . '://' . $_SERVER['HTTP_HOST'] . $path; } else { $dir = dirname(P2Util::getMyUrl()); if (strncasecmp($path, './', 2) == 0) { $to = $dir . substr($path, 1); } elseif (strncasecmp($path, '../', 3) == 0) { $to = dirname($dir) . substr($path, 2); } else { $to = $dir . '/' . $path; } } $name = basename($path); $ext = strrchr($name, '.'); switch ($redirect) { case 1: header("Location: {$to}"); exit; case 2: switch ($ext) { case '.jpg': header("Content-Type: image/jpeg; name=\"{$name}\""); break; case '.png': header("Content-Type: image/png; name=\"{$name}\""); break; case '.gif': header("Content-Type: image/gif; name=\"{$name}\""); break; default: if (strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') !== false || strpos($_SERVER['HTTP_USER_AGENT'], 'Opera') !== false) { header("Content-Type: application/octetstream; name=\"{$name}\""); } else { header("Content-Type: application/octet-stream; name=\"{$name}\""); } } header("Content-Disposition: inline; filename=\"{$name}\""); header('Content-Length: ' . filesize($path)); readfile($path); exit; default: if (!class_exists('HTML_Template_Flexy', false)) { require 'HTML/Template/Flexy.php'; } if (!class_exists('HTML_QuickForm', false)) { require 'HTML/QuickForm.php'; } if (!class_exists('HTML_QuickForm_Renderer_ObjectFlexy', false)) { require 'HTML/QuickForm/Renderer/ObjectFlexy.php'; } if (isset($uri)) { $img_o = 'uri'; $img_p = $uri; } elseif (isset($id)) { $img_o = 'id'; $img_p = $id; } else { $img_o = 'file'; $img_p = $file; } $img_q = $img_o . '=' . rawurlencode($img_p); // QuickFormの初期化 $_size = explode('x', $thumbnailer->calc($params['width'], $params['height'])); $_constants = array('o' => sprintf('原寸 (%dx%d)', $params['width'], $params['height']), 's' => '作成', 't' => $thumb, 'd' => $dpr, 'u' => $img_p, 'v' => $img_o, 'x' => $_size[0], 'y' => $_size[1]); $_defaults = array('q' => $ini["Thumb{$thumb}"]['quality'], 'r' => '0'); $mobile = Net_UserAgent_Mobile::singleton(); $qa = 'size=3 maxlength=3'; if ($mobile->isDoCoMo()) { $qa .= ' istyle=4'; } elseif ($mobile->isEZweb()) { $qa .= ' format=*N'; } elseif ($mobile->isSoftBank()) { $qa .= ' mode=numeric'; } $_presets = array('' => 'サイズ・品質'); foreach ($ini['Dynamic']['presets'] as $_preset_name => $_preset_params) { $_presets[$_preset_name] = $_preset_name; } $qf = new HTML_QuickForm('imgmaker', 'get', 'ic2_mkthumb.php'); $qf->setConstants($_constants); $qf->setDefaults($_defaults); $qf->addElement('hidden', 't'); $qf->addElement('hidden', 'u'); $qf->addElement('hidden', 'v'); $qf->addElement('text', 'x', '高さ', $qa); $qf->addElement('text', 'y', '横幅', $qa); $qf->addElement('text', 'q', '品質', $qa); $qf->addElement('select', 'p', 'プリセット', $_presets); $qf->addElement('select', 'r', '回転', array('0' => 'なし', '90' => '右に90°', '270' => '左に90°', '180' => '180°')); $qf->addElement('checkbox', 'w', 'トリム'); $qf->addElement('checkbox', 'z', 'DL'); $qf->addElement('submit', 's'); $qf->addElement('submit', 'o'); // FlexyとQurickForm_Rendererの初期化 $_flexy_options = array('locale' => 'ja', 'charset' => 'cp932', 'compileDir' => $_conf['compile_dir'] . DIRECTORY_SEPARATOR . 'ic2', 'templateDir' => P2EX_LIB_DIR . '/ic2/templates', 'numberFormat' => ''); $flexy = new HTML_Template_Flexy($_flexy_options); $rdr = new HTML_QuickForm_Renderer_ObjectFlexy($flexy); $qf->accept($rdr); // 表示 $flexy->setData('p2vid', P2_VERSION_ID); $flexy->setData('title', 'IC2::Cached'); $flexy->setData('pc', !$_conf['ktai']); $flexy->setData('iphone', $_conf['iphone']); if (!$_conf['ktai']) { $flexy->setData('skin', $GLOBALS['skin_name']); //$flexy->setData('stylesheets', array('css')); //$flexy->setData('javascripts', array('js')); } else { $flexy->setData('k_color', array('c_bgcolor' => !empty($_conf['mobile.background_color']) ? $_conf['mobile.background_color'] : '#ffffff', 'c_text' => !empty($_conf['mobile.text_color']) ? $_conf['mobile.text_color'] : '#000000', 'c_link' => !empty($_conf['mobile.link_color']) ? $_conf['mobile.link_color'] : '#0000ff', 'c_vlink' => !empty($_conf['mobile.vlink_color']) ? $_conf['mobile.vlink_color'] : '#9900ff')); } $rank = isset($params['rank']) ? $params['rank'] : 0; if ($_conf['iphone']) { $img_dir = 'img/iphone/'; $img_ext = '.png'; } else { $img_dir = 'img/'; $img_ext = $_conf['ktai'] ? '.gif' : '.png'; } $stars = array(); $stars[-1] = $img_dir . ($rank == -1 ? 'sn1' : 'sn0') . $img_ext; //$stars[0] = $img_dir . (($rank == 0) ? 'sz1' : 'sz0') . $img_ext; $stars[0] = $img_dir . ($_conf['iphone'] ? 'sz0' : 'sz1') . $img_ext; for ($i = 1; $i <= 5; $i++) { $stars[$i] = $img_dir . ($rank >= $i ? 's1' : 's0') . $img_ext; } $k_at_a = str_replace('&', '&', $_conf['k_at_a']); $setrank_url = "ic2.php?{$img_q}&t={$thumb}&r=0{$k_at_a}"; $flexy->setData('stars', $stars); $flexy->setData('params', $params); if ($thumb == 2 && $rank >= 0) { if ($ini['General']['inline'] == 1) { $t = 2; $link = null; } else { $t = 1; $link = $path; } $r = $ini['General']['redirect'] == 1 ? 1 : 2; $preview = "{$_SERVER['SCRIPT_NAME']}?o=1&r={$r}&t={$t}&{$img_q}{$k_at_a}"; $flexy->setData('preview', $preview); $flexy->setData('link', $link); $flexy->setData('info', null); } else { $flexy->setData('preview', null); $flexy->setData('link', $path); $flexy->setData('info', null); } if (!$_conf['ktai'] || $_conf['iphone']) { $flexy->setData('backto', null); } elseif (isset($_REQUEST['from'])) { $flexy->setData('backto', $_REQUEST['from']); $setrank_url .= '&from=' . rawurlencode($_REQUEST['from']); } elseif (isset($_SERVER['HTTP_REFERER'])) { $flexy->setData('backto', $_SERVER['HTTP_REFERER']); } else { $flexy->setData('backto', null); } $flexy->setData('stars', $stars); $flexy->setData('sertank', $setrank_url . '&rank='); if ($_conf['iphone']) { $_conf['extra_headers_ht'] .= <<<EOP <link rel="stylesheet" type="text/css" href="css/ic2_iphone.css?{$_conf['p2_version_id']}"> EOP; $_conf['extra_headers_xht'] .= <<<EOP <link rel="stylesheet" type="text/css" href="css/ic2_iphone.css?{$_conf['p2_version_id']}" /> EOP; } $flexy->setData('edit', extension_loaded('gd') && $rank >= 0); $flexy->setData('form', $rdr->toObject()); $flexy->setData('doctype', $_conf['doctype']); $flexy->setData('extra_headers', $_conf['extra_headers_ht']); $flexy->setData('extra_headers_x', $_conf['extra_headers_xht']); $flexy->compile('preview.tpl.html'); P2Util::header_nocache(); $flexy->output(); } exit; }
public function getModule() { // Get smarty variable $smarty = $this->getSmartyVar(); //This could become a module function... global $load_editor; $load_editor = true; //$smarty -> assign("T_HEADER_EDITOR", $load_editor); $form = new HTML_QuickForm("billboard_entry_form", "post", $_SERVER['REQUEST_URI'], "", null, true); $form->registerRule('checkParameter', 'callback', 'eF_checkParameter'); //Register this rule for checking user input with our function, eF_checkParameter $form->addElement('textarea', 'data', _BILLBOARDCONTENT, 'class = "inputContentTextarea mceEditor" style = "width:100%;height:300px;"'); //The unit content itself $form->addElement('submit', 'submit_billboard', _SUBMIT, 'class = "flatButton"'); $currentLesson = $this->getCurrentLesson(); $billboard = eF_getTableData("module_billboard", "*", "lessons_ID=" . $currentLesson->lesson['id']); $form->setDefaults(array('data' => $billboard[0]['data'])); if ($form->isSubmitted() && $form->validate()) { $fields = array('lessons_ID' => $currentLesson->lesson['id'], 'data' => $form->exportValue('data')); $currentUser = $this->getCurrentUser(); // if ($billboard[0]['data'] != "") { if (!empty($billboard)) { if (eF_updateTableData("module_billboard", $fields, "lessons_ID=" . $currentLesson->lesson['id'])) { eF_redirect("professor.php?ctg=control_panel&message=" . urlencode(_BILLBOARD_SUCCESFULLYUPDATEDBILLBOARDENTRY) . "&message_type=success"); } else { $this->setMessageVar(_BILLBOARD_PROBLEMUPDATINGBILLBOARDENTRY, 'failure'); } } else { if (eF_insertTableData("module_billboard", $fields)) { eF_redirect("professor.php?ctg=control_panel&message=" . urlencode(_BILLBOARD_SUCCESFULLYUPDATEDBILLBOARDENTRY) . "&message_type=success"); //eF_redirect("".$this -> moduleBaseUrl."&message="._BILLBOARD_SUCCESFULLYINSERTEDBILLBOARDENTRY."&message_type=success"); } else { $this->setMessageVar(_BILLBOARD_PROBLEMINSERTINGBILLBOARDENTRY, 'failure'); } } } $renderer = new HTML_QuickForm_Renderer_ArraySmarty($smarty); $form->accept($renderer); $smarty->assign('T_BILLBOARD_FORM', $renderer->toArray()); $smarty->assign("T_BILLBOARD", $billboard[0]['data']); return true; }
$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)); $renderer = new UthandoForm(__SITE_PATH . '/templates/' . $template); $renderer->setFormTemplate('form'); $renderer->setHeaderTemplate('header'); $renderer->setElementTemplate('element'); $form->accept($renderer); // output the form $this->content .= $renderer->toHtml(); } if (isset($params)) { $params['CONTENT'] = $this->makeMessageBar($menuBar, 24); $this->content .= $this->message($params); } } else { header("Location:" . $this->get('config.server.web_url')); exit; }
public function editUser() { $this->db_authors = pdAuthorList::create($this->db, null, null, true); $user =& $_SESSION['user']; $user->collaboratorsDbLoad($this->db); $form = new HTML_QuickForm('userForm', 'post', '', '', array('onsubmit' => 'return check_authors("userForm");')); $form->addElement('static', 'login_label', 'Login:'******'hidden', 'status', 'edit'); $form->addElement('hidden', 'login', $user->login); $form->addElement('text', 'name', 'Name:', array('size' => 50, 'maxlength' => 100)); $form->addElement('text', 'email', 'E-mail:', array('size' => 50, 'maxlength' => 100)); $form->addElement('textarea', 'authors', 'Authors:', array('cols' => 60, 'rows' => 5, 'class' => 'wickEnabled:MYCUSTOMFLOATER', 'wrap' => 'virtual')); $form->addElement('static', null, null, '<span class="small">' . 'There are ' . count($this->db_authors) . ' authors in the database. Type a partial name to ' . 'see a list of matching authors. Separate names ' . 'using commas.</span>'); $form->addElement('advcheckbox', 'option_internal_info', 'Options:', 'show internal info', null, array('No', 'Yes')); $form->addElement('advcheckbox', 'option_user_info', 'Options:', 'show user info', null, array('No', 'Yes')); $auth_list = pdAuthorList::create($this->db); $form->addElement('submit', 'Submit', 'Save'); if ($form->validate()) { $values = $form->exportValues(); assert('$values["login"] == $user->login'); $user->name = $values['name']; $user->email = $values['email']; $user->options = 0; if ($values['option_internal_info'] == 'Yes') { $user->options |= pdUser::OPTION_SHOW_INTERNAL_INFO; } if ($values['option_user_info'] == 'Yes') { $user->options |= pdUser::OPTION_SHOW_USER_INFO; } unset($user->collaborators); // need to retrieve author_ids for the selected authors $selAuthors = explode(', ', preg_replace('/\\s\\s+/', ' ', $values['authors'])); $author_ids = array(); foreach ($selAuthors as $author) { if (empty($author)) { continue; } $result = array_search($author, $this->db_authors); if ($result !== false) { $user->collaborators[$result] = $this->db_authors[$result]; } } $user->dbSave($this->db); echo 'Change to user information submitted.<p/>'; echo 'Click <a href="edit_user.php?status=edit">here</a> to edit your preferences again.'; } else { echo '<h2>Login Information</h2>'; $defaults = array('name' => $user->name, 'email' => $user->email); $defaults['option_internal_info'] = $user->showInternalInfo() ? 'Yes' : 'No'; $defaults['option_user_info'] = $user->showUserInfo() ? 'Yes' : 'No'; if (count($user->collaborators) > 0) { $author_names = pdAuthorList::createFromAuthorIds($this->db, array_keys($user->collaborators), true); $defaults['authors'] = implode(', ', array_values($author_names)); } $form->setDefaults($defaults); $renderer =& $form->defaultRenderer(); $form->accept($renderer); $this->form =& $form; $this->renderer =& $renderer; $this->javascript(); } }