function validate() { $result = parent::validate(); if ($result) { $this->update_model(); } return $result; }
protected function validate() { FormValidator::validate($this->login, self::LOGIN, ValidationRules::NAME); FormValidator::validate($this->firstname, self::FIRSTNAME, ValidationRules::NAME); FormValidator::validate($this->lastname, self::LASTNAME, ValidationRules::NAME); FormValidator::validate($this->email, self::EMAIL, ValidationRules::EMAIL); FormValidator::validate($this->password, self::PASSWORD, ValidationRules::PASS); FormValidator::validateDate($this->year, $this->month, $this->day); FormValidator::validate($this->gender, self::GENDER, ValidationRules::NAME); FormValidator::validate($this->rules, self::RULES, ValidationRules::TICK); }
public function testInteger() { $profile = array('constraints' => array('field1' => array('required' => 1, 'integer' => 1), 'field2' => array('integer' => 1), 'field3' => array('integer' => 1), 'field4' => array('integer' => 1), 'field5' => array('integer' => 1))); $data = array('field1' => '5', 'field2' => 10, 'field3' => 'asdf', 'field4' => '5.1', 'field5' => 5.1); $validator = new FormValidator(); $errors = $validator->validate($data, $profile); $this->assertEquals($errors, array('field3 is invalid.', 'field4 is invalid.', 'field5 is invalid.')); $this->assertEquals($validator->valid, array('field1', 'field2')); $this->assertEquals($validator->invalid, array('field3', 'field4', 'field5')); $this->assertEquals($validator->missing, array()); }
public function validate() { $result = (bool) parent::validate(); if ($result == false) { return false; } $file = $this->get_file(); if (empty($file)) { return false; } return true; }
/** * Display the search form for the forum and display the search results * @return void display an HTML search results * @author Patrick Cool <*****@*****.**>, Ghent University, Belgium * @version march 2008, dokeos 1.8.5 */ function forum_search() { // Initialize the object. $form = new FormValidator('forumsearch', 'post', 'forumsearch.php?' . api_get_cidreq()); // Setting the form elements. $form->addElement('header', '', get_lang('ForumSearch')); $form->addElement('text', 'search_term', get_lang('SearchTerm'), array('autofocus')); $form->applyFilter('search_term', 'html_filter'); $form->addElement('static', 'search_information', '', get_lang('ForumSearchInformation')); $form->addButtonSearch(get_lang('Search')); // Setting the rules. $form->addRule('search_term', get_lang('ThisFieldIsRequired'), 'required'); $form->addRule('search_term', get_lang('TooShort'), 'minlength', 3); // Validation or display. if ($form->validate()) { $values = $form->exportValues(); $form->setDefaults($values); $form->display(); // Display the search results. display_forum_search_results(stripslashes($values['search_term'])); } else { $form->display(); } }
/** * displayDeleteSubmit * * @return void */ function displayDeleteSubmit() { $aid = $_GET['delete']; $cat = $_GET['cat']; $validator = new FormValidator(); if ($this->fcmsUser->access >= 2) { $this->displayHeader(); echo ' <p class="error-alert">' . T_('You do not have permission to perform this task.') . '</p>'; $this->fcmsBook->displayAddressList($cat); $this->displayFooter(); return; } $errors = $validator->validate($_GET, $this->fcmsBook->getProfile('delete')); if ($errors !== true) { $this->displayHeader(); displayErrors($errors); $this->fcmsBook->displayAddressList($cat); $this->displayFooter(); return; } $sql = "SELECT a.`user`, u.`phpass`\n FROM `fcms_address` AS a, `fcms_users` AS u\n WHERE a.`id` = ?\n AND a.`user` = u.`id`"; $r = $this->fcmsDatabase->getRow($sql, $aid); if ($r === false) { $this->displayHeader(); $this->fcmsError->displayError(); $this->displayFooter(); return; } $user = $r['user']; $pass = $r['phpass']; if ($r['phpass'] !== 'NONMEMBER' && $r['phpass'] !== 'PRIVATE') { $this->displayHeader(); echo ' <p class="error-alert">' . T_('You cannot delete the address of a member.') . '</p>'; $this->fcmsBook->displayAddressList($cat); $this->displayFooter(); return; } $sql = "DELETE FROM `fcms_users` \n WHERE `id` = ?"; if (!$this->fcmsDatabase->delete($sql, $user)) { $this->displayHeader(); $this->fcmsDatabase->displayError(); $this->displayFooter(); return; } $sql = "DELETE FROM fcms_address \n WHERE id = ?"; if (!$this->fcmsDatabase->delete($sql, $aid)) { $this->displayHeader(); $this->fcmsError->displayError(); $this->displayFooter(); return; } $this->displayAddressList(); displayOkMessage(T_('Address Deleted Successfully.')); $this->displayFooter(); }
$skillIssueDate = api_get_local_time($skillIssue->getAcquiredSkillAt()); $skillIssueInfo = ['id' => $skillIssue->getId(), 'datetime' => api_format_date($skillIssueDate, DATE_TIME_FORMAT_SHORT), 'argumentation' => $skillIssue->getArgumentation(), 'source_name' => $skillIssue->getSourceName(), 'user_id' => $skillIssue->getUser()->getId(), 'user_complete_name' => $skillIssue->getUser()->getCompleteName(), 'skill_badge_image' => $skillIssue->getSkill()->getWebIconPath(), 'skill_name' => $skillIssue->getSkill()->getName(), 'skill_short_code' => $skillIssue->getSkill()->getShortCode(), 'skill_description' => $skillIssue->getSkill()->getDescription(), 'skill_criteria' => $skillIssue->getSkill()->getCriteria(), 'badge_asserion' => [$skillIssue->getAssertionUrl()], 'comments' => [], 'feedback_average' => $skillIssue->getAverage()]; $skillIssueComments = $skillIssue->getComments(true); foreach ($skillIssueComments as $comment) { $commentDate = api_get_local_time($comment->getFeedbackDateTime()); $skillIssueInfo['comments'][] = ['text' => $comment->getFeedbackText(), 'value' => $comment->getFeedbackValue(), 'giver_complete_name' => $comment->getFeedbackGiver()->getCompleteName(), 'datetime' => api_format_date($commentDate, DATE_TIME_FORMAT_SHORT)]; } $form = new FormValidator('comment'); $form->addTextarea('comment', get_lang('NewComment'), ['rows' => 4]); $form->applyFilter('comment', 'trim'); $form->addRule('comment', get_lang('ThisFieldIsRequired'), 'required'); $form->addSelect('value', [get_lang('Value'), get_lang('RateTheSkillInPractice')], ['-', 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]); $form->addHidden('user', $skillIssue->getUser()->getId()); $form->addHidden('issue', $skillIssue->getId()); $form->addButtonSend(get_lang('Send')); if ($form->validate() && $allowComment) { $values = $form->exportValues(); $skillUserComment = new Chamilo\CoreBundle\Entity\SkillRelUserComment(); $skillUserComment->setFeedbackDateTime(new DateTime())->setFeedbackGiver($currentUser)->setFeedbackText($values['comment'])->setFeedbackValue($values['value'] ? $values['value'] : null)->setSkillRelUser($skillIssue); $entityManager->persist($skillUserComment); $entityManager->flush(); header("Location: " . $skillIssue->getIssueUrl()); exit; } if ($allowExport) { $backpack = 'https://backpack.openbadges.org/'; $configBackpack = api_get_setting('openbadges_backpack'); if (strcmp($backpack, $configBackpack) !== 0) { $backpack = $configBackpack; } $htmlHeadXtra[] = '<script src="' . $backpack . 'issuer.js"></script>';
if (!api_site_use_cookie_warning_cookie_exist()) { if (Template::isToolBarDisplayedForUser()) { $tpl->assign('toolBarDisplayed', true); } else { $tpl->assign('toolBarDisplayed', false); } $tpl->assign('displayCookieUsageWarning', true); } } } $tpl->assign('web_admin_ajax_url', $admin_ajax_url); $tpl->assign('blocks', $blocks); if (api_is_platform_admin()) { $extraContentForm = new FormValidator('block_extra_data', 'post', '#', null, array('id' => 'block-extra-data', 'class' => ''), FormValidator::LAYOUT_BOX_NO_LABEL); $extraContentFormRenderer = $extraContentForm->getDefaultRenderer(); if ($extraContentForm->validate()) { $extraData = $extraContentForm->getSubmitValues(); $extraData = array_map(['Security', 'remove_XSS'], $extraData); if (!empty($extraData['block'])) { if (!is_dir($adminExtraContentDir)) { mkdir($adminExtraContentDir, api_get_permissions_for_new_directories(), true); } if (!is_writable($adminExtraContentDir)) { die; } $fullFilePath = $adminExtraContentDir . $extraData['block']; $fullFilePath .= "_extra.html"; file_put_contents($fullFilePath, $extraData['extra_content']); Header::location(api_get_self()); } }
continue; } $skillList[$skill['id']] = $skill['name']; } foreach ($allGradebooks as $gradebook) { $gradebookList[$gradebook['id']] = $gradebook['name']; } /* Form */ $editForm = new FormValidator('skill_edit'); $editForm->addHeader(get_lang('SkillEdit')); $editForm->addText('name', get_lang('Name'), true, ['id' => 'name']); $editForm->addText('short_code', get_lang('ShortCode'), false, ['id' => 'short_code']); $editForm->addSelect('parent_id', get_lang('Parent'), $skillList, ['id' => 'parent_id']); $editForm->addSelect('gradebook_id', [get_lang('Gradebook'), get_lang('WithCertificate')], $gradebookList, ['id' => 'gradebook_id', 'multiple' => 'multiple', 'size' => 10]); $editForm->addTextarea('description', get_lang('Description'), ['id' => 'description', 'rows' => 7]); $editForm->addButtonSave(get_lang('Save')); $editForm->addHidden('id', null); $editForm->setDefaults($skillDefaultInfo); if ($editForm->validate()) { $updated = $objSkill->edit($editForm->getSubmitValues()); if ($updated) { Session::write('message', Display::return_message(get_lang('TheSkillHasBeenUpdated'), 'success')); } else { Session::write('message', Display::return_message(get_lang('CannotUpdateSkill'), 'error')); } Header::location(api_get_path(WEB_CODE_PATH) . 'admin/skill_list.php'); } /* view */ $tpl = new Template(get_lang('SkillEdit')); $tpl->assign('content', $editForm->returnForm()); $tpl->display_one_col_template();
function add_category_form($in_action, $type = 'simple') { $in_action = Security::remove_XSS($in_action); // Initiate the object $form = new FormValidator('note', 'post', api_get_self() . '?' . api_get_cidreq() . '&action=' . $in_action . "&type=" . $type); // Setting the form elements $form->addElement('header', get_lang('AddACategory')); $form->addElement('text', 'category_name', get_lang('CategoryName'), array('class' => 'span6')); $form->add_html_editor('category_description', get_lang('CategoryDescription'), false, false, array('ToolbarSet' => 'test_category', 'Width' => '90%', 'Height' => '200')); $form->addElement('select', 'parent_id', get_lang('Parent'), array(), array('id' => 'parent_id')); $form->addElement('style_submit_button', 'SubmitNote', get_lang('AddTestCategory'), 'class="add"'); // Setting the rules $form->addRule('category_name', get_lang('ThisFieldIsRequired'), 'required'); // The validation or display if ($form->validate()) { $check = Security::check_token('post'); if ($check) { $values = $form->getSubmitValues(); $parent_id = isset($values['parent_id']) && isset($values['parent_id'][0]) ? $values['parent_id'][0] : null; $objcat = new Testcategory(0, $values['category_name'], $values['category_description'], $parent_id, $type, api_get_course_int_id()); if ($objcat->addCategoryInBDD()) { Display::display_confirmation_message(get_lang('AddCategoryDone')); } else { Display::display_confirmation_message(get_lang('AddCategoryNameAlreadyExists')); } } Security::clear_token(); display_add_category($type); display_categories($type); } else { display_goback($type); $token = Security::get_token(); $form->addElement('hidden', 'sec_token'); $form->setConstants(array('sec_token' => $token)); $form->display(); } }
header('Location: usergroups.php'); exit; } } // Filters $filters = array(array('type' => 'text', 'name' => 'code', 'label' => get_lang('CourseCode')), array('type' => 'text', 'name' => 'title', 'label' => get_lang('Title'))); $searchForm = new FormValidator('search', 'get', api_get_self() . '?id=' . $id); $searchForm->addHeader(get_lang('AdvancedSearch')); $renderer =& $searchForm->defaultRenderer(); $searchForm->addElement('hidden', 'id', $id); foreach ($filters as $param) { $searchForm->addElement($param['type'], $param['name'], $param['label']); } $searchForm->addButtonSearch(); $filterData = array(); if ($searchForm->validate()) { $filterData = $searchForm->getSubmitValues(); } $conditions = array(); if (!empty($filters) && !empty($filterData)) { foreach ($filters as $filter) { if (isset($filter['name']) && isset($filterData[$filter['name']])) { $value = $filterData[$filter['name']]; if (!empty($value)) { $conditions[$filter['name']] = $value; } } } } $data = $usergroup->get($id); $course_list_in = $usergroup->get_courses_by_usergroup($id, true);
function hyvaksy_tarjous($valittu_tarjous_tunnus, $syotetyt_lisatiedot) { global $kukarow, $yhtiorow; $kukarow['kesken'] = $valittu_tarjous_tunnus; $validations = array('syotetyt_lisatiedot' => 'kirjain_numero'); $validator = new FormValidator($validations); if ($validator->validate(array('syotetyt_lisatiedot' => $syotetyt_lisatiedot))) { //asetetaan myyntitilaus Myyntitilaus kesken Tulostusjonossa $query = "UPDATE lasku\n SET sisviesti1='{$syotetyt_lisatiedot}'\n WHERE yhtio='{$kukarow['yhtio']}'\n AND tunnus='{$valittu_tarjous_tunnus}'"; pupe_query($query); // Kopsataan valitut rivit uudelle myyntitilaukselle require "tilauksesta_myyntitilaus.inc"; $tilauksesta_myyntitilaus = tilauksesta_myyntitilaus($valittu_tarjous_tunnus, '', '', ''); if ($tilauksesta_myyntitilaus != '') { echo "{$tilauksesta_myyntitilaus}<br><br>"; $query = "UPDATE lasku SET alatila='B' where yhtio='{$kukarow['yhtio']}' and tunnus='{$valittu_tarjous_tunnus}'"; pupe_query($query); } $aika = date("d.m.y @ G:i:s", time()); echo "<font class='message'>{$otsikko} {$kukarow['kesken']} " . t("valmis") . "!</font><br><br>"; $tee = ''; $tilausnumero = ''; $laskurow = ''; $kukarow['kesken'] = ''; return true; } return false; }
/** * Add (or edit) a template. This function displays the form and also takes * care of uploading the image and storing the information in the database * * @author Patrick Cool <*****@*****.**>, Ghent University, Belgium * @version August 2008 * @since Dokeos 1.8.6 */ function add_edit_template() { // Initialize the object. $id = isset($_GET['id']) ? '&id=' . Security::remove_XSS($_GET['id']) : ''; $form = new FormValidator('template', 'post', 'settings.php?category=Templates&action=' . Security::remove_XSS($_GET['action']) . $id); // Setting the form elements: the header. if ($_GET['action'] == 'add') { $title = get_lang('AddTemplate'); } else { $title = get_lang('EditTemplate'); } $form->addElement('header', '', $title); // Setting the form elements: the title of the template. $form->addText('title', get_lang('Title'), false); // Setting the form elements: the content of the template (wysiwyg editor). $form->addHtmlEditor('template_text', get_lang('Text'), false, false, array('ToolbarSet' => 'AdminTemplates', 'Width' => '100%', 'Height' => '400')); // Setting the form elements: the form to upload an image to be used with the template. $form->addElement('file', 'template_image', get_lang('Image'), ''); // Setting the form elements: a little bit information about the template image. $form->addElement('static', 'file_comment', '', get_lang('TemplateImageComment100x70')); // Getting all the information of the template when editing a template. if ($_GET['action'] == 'edit') { // Database table definition. $table_system_template = Database::get_main_table('system_template'); $sql = "SELECT * FROM {$table_system_template} WHERE id = " . intval($_GET['id']) . ""; $result = Database::query($sql); $row = Database::fetch_array($result); $defaults['template_id'] = intval($_GET['id']); $defaults['template_text'] = $row['content']; // Forcing get_lang(). $defaults['title'] = get_lang($row['title']); // Adding an extra field: a hidden field with the id of the template we are editing. $form->addElement('hidden', 'template_id'); // Adding an extra field: a preview of the image that is currently used. if (!empty($row['image'])) { $form->addElement('static', 'template_image_preview', '', '<img src="' . api_get_path(WEB_APP_PATH) . 'home/default_platform_document/template_thumb/' . $row['image'] . '" alt="' . get_lang('TemplatePreview') . '"/>'); } else { $form->addElement('static', 'template_image_preview', '', '<img src="' . api_get_path(WEB_APP_PATH) . 'home/default_platform_document/template_thumb/noimage.gif" alt="' . get_lang('NoTemplatePreview') . '"/>'); } // Setting the information of the template that we are editing. $form->setDefaults($defaults); } // Setting the form elements: the submit button. $form->addButtonSave(get_lang('Ok'), 'submit'); // Setting the rules: the required fields. $form->addRule('template_image', get_lang('ThisFieldIsRequired'), 'required'); $form->addRule('title', get_lang('ThisFieldIsRequired'), 'required'); $form->addRule('template_text', get_lang('ThisFieldIsRequired'), 'required'); // if the form validates (complies to all rules) we save the information, else we display the form again (with error message if needed) if ($form->validate()) { $check = Security::check_token('post'); if ($check) { // Exporting the values. $values = $form->exportValues(); // Upload the file. if (!empty($_FILES['template_image']['name'])) { $upload_ok = process_uploaded_file($_FILES['template_image']); if ($upload_ok) { // Try to add an extension to the file if it hasn't one. $new_file_name = add_ext_on_mime(stripslashes($_FILES['template_image']['name']), $_FILES['template_image']['type']); // The upload directory. $upload_dir = api_get_path(SYS_APP_PATH) . 'home/default_platform_document/template_thumb/'; // Create the directory if it does not exist. if (!is_dir($upload_dir)) { mkdir($upload_dir, api_get_permissions_for_new_directories()); } // Resize the preview image to max default and upload. $temp = new Image($_FILES['template_image']['tmp_name']); $picture_info = $temp->get_image_info(); $max_width_for_picture = 100; if ($picture_info['width'] > $max_width_for_picture) { $temp->resize($max_width_for_picture); } $temp->send_image($upload_dir . $new_file_name); } } // Store the information in the database (as insert or as update). $table_system_template = Database::get_main_table('system_template'); if ($_GET['action'] == 'add') { $content_template = Security::remove_XSS($values['template_text'], COURSEMANAGERLOWSECURITY); $params = ['title' => $values['title'], 'content' => $content_template, 'image' => $new_file_name]; Database::insert($table_system_template, $params); // Display a feedback message. Display::display_confirmation_message(get_lang('TemplateAdded')); echo '<a href="settings.php?category=Templates&action=add">' . Display::return_icon('new_template.png', get_lang('AddTemplate'), '', ICON_SIZE_MEDIUM) . '</a>'; } else { $content_template = '<head>{CSS}<style type="text/css">.text{font-weight: normal;}</style></head><body>' . Database::escape_string($values['template_text']) . '</body>'; $sql = "UPDATE {$table_system_template} set title = '" . Database::escape_string($values['title']) . "', content = '" . $content_template . "'"; if (!empty($new_file_name)) { $sql .= ", image = '" . Database::escape_string($new_file_name) . "'"; } $sql .= " WHERE id = " . intval($_GET['id']) . ""; Database::query($sql); // Display a feedback message. Display::display_confirmation_message(get_lang('TemplateEdited')); } } Security::clear_token(); display_templates(); } else { $token = Security::get_token(); $form->addElement('hidden', 'sec_token'); $form->setConstants(array('sec_token' => $token)); // Display the form. $form->display(); } }
protected function validate() { // temporarily ValidationRules::NONE validation rule is applied FormValidator::validate($this->comment, self::COMMENT, ValidationRules::NONE); }
/** * @param string $action */ public function getSearchPages($action) { echo '<div class="actions">' . get_lang('SearchPages') . '</div>'; if (isset($_GET['mode_table'])) { if (!isset($_GET['SearchPages_table_page_nr'])) { $_GET['search_term'] = isset($_POST['search_term']) ? $_POST['search_term'] : ''; $_GET['search_content'] = isset($_POST['search_content']) ? $_POST['search_content'] : ''; $_GET['all_vers'] = isset($_POST['all_vers']) ? $_POST['all_vers'] : ''; } self::display_wiki_search_results($_GET['search_term'], $_GET['search_content'], $_GET['all_vers']); } else { // initiate the object $form = new FormValidator('wiki_search', 'post', api_get_self() . '?cidReq=' . api_get_course_id() . '&action=' . api_htmlentities($action) . '&session_id=' . api_get_session_id() . '&group_id=' . api_get_group_id() . '&mode_table=yes1'); // Setting the form elements $form->addText('search_term', get_lang('SearchTerm'), true, array('autofocus' => 'autofocus')); $form->addElement('checkbox', 'search_content', null, get_lang('AlsoSearchContent')); $form->addElement('checkbox', 'all_vers', null, get_lang('IncludeAllVersions')); $form->addButtonSearch(get_lang('Search'), 'SubmitWikiSearch'); // setting the rules $form->addRule('search_term', get_lang('TooShort'), 'minlength', 3); //TODO: before fixing the pagination rules worked, not now if ($form->validate()) { $form->display(); $values = $form->exportValues(); self::display_wiki_search_results($values['search_term'], $values['search_content'], $values['all_vers']); } else { $form->display(); } } }
if (empty($request['ppl']) or empty($request['kkl']) or empty($request['vvl'])) { $request['loppu_pvm'] = date('d.m.Y', strtotime('now')); $pvm_array = explode('.', $request['loppu_pvm']); $request['ppl'] = $pvm_array[0]; $request['kkl'] = $pvm_array[1]; $request['vvl'] = $pvm_array[2]; } if ($request['tee'] == 'nayta_tilaus') { require 'naytatilaus.inc'; } else { echo_kayttoliittyma($request); if ($request['tee'] == 'hae_tilaukset') { $validations = array('sarjanro' => 'mitavaan', 'asiakas' => 'mitavaan', 'toimittaja' => 'mitavaan', 'tuote' => 'mitavaan', 'alku_pvm' => 'paiva', 'loppu_pvm' => 'paiva'); $required = array('alku_pvm', 'loppu_pvm'); $validator = new FormValidator($validations, $required); if ($validator->validate($request)) { $tilaukset = hae_tilaukset($request); //esitellään tilaus tyypit tässä jotta validaatio luokka ei yritä valitoida niitä. $request['tyypit'] = array('L' => t("Myyntitilaus"), 'O' => t("Ostotilaus"), 'A' => t("Työmääräys")); echo_tilaukset_raportti($tilaukset, $request); } else { echo $validator->getScript(); } } } function hae_tilaukset($request) { global $kukarow, $yhtiorow; $sarjanumero_where = ""; if (!empty($request['sarjanumero'])) { $sarjanumero_where = " AND sarjanumeroseuranta.sarjanumero LIKE '%{$request['sarjanumero']}%'";
function validate() { return parent::validate(); }
/** * Iterates over each control in the form and uses FormValidator to validate * it. If all the controls in the form are valid, the form is valid. * * @return boolean */ public final function isValid() { $isValid = TRUE; $validator = new FormValidator(); foreach ($this->_controls as $control) { if ($control->isRequired()) { if (!$validator->validate($control)) { $control->setIsMissing(); $isValid = FALSE; } } } return $isValid; }
// setting breadcrumbs $interbreadcrumb[] = array('url' => 'index.php', 'name' => get_lang('PlatformAdmin')); $tpl = new Template(get_lang('ResourcesSequencing')); $sessionListFromDatabase = SessionManager::get_sessions_list(); $sessionList = []; if (!empty($sessionListFromDatabase)) { foreach ($sessionListFromDatabase as $sessionItem) { $sessionList[$sessionItem['id']] = $sessionItem['name'] . ' (' . $sessionItem['id'] . ')'; } } $formSequence = new FormValidator('sequence_form', 'post', api_get_self(), null, null, 'inline'); $formSequence->addText('name', get_lang('Sequence'), true, ['cols-size' => [3, 8, 1]]); $formSequence->addButtonCreate(get_lang('AddSequence'), 'submit_sequence', false, ['cols-size' => [3, 8, 1]]); $em = Database::getManager(); // Add sequence if ($formSequence->validate()) { $values = $formSequence->exportValues(); $sequence = new Sequence(); $sequence->setName($values['name']); $em->persist($sequence); $em->flush(); header('Location: ' . api_get_self()); exit; } $selectSequence = new FormValidator(''); $selectSequence->addHidden('sequence_type', 'session'); $em = Database::getManager(); $sequenceList = $em->getRepository('ChamiloCoreBundle:Sequence')->findAll(); $selectSequence->addSelect('sequence', get_lang('Sequence'), $sequenceList, ['id' => 'sequence_id', 'cols-size' => [3, 7, 2]]); $form = new FormValidator(''); $form->addHtml("<div class='col-md-6'>");
/** * Main plugin call. * * @param string $id A form ID. * * @return string (X)HTML. * * @global array The configuration of the plugins. * @global array The localization of the plugins. * @global string The script name. * @global string The (X)HTML fragment containing error messages. * @global array The paths of system files and folders. */ public static function main($id) { global $plugin_cf, $plugin_tx, $sn, $e, $pth; $pcf = $plugin_cf['advancedform']; $ptx = $plugin_tx['advancedform']; $fn = $pth['folder']['plugins'] . $pcf['captcha_plugin'] . '/captcha.php'; if (file_exists($fn)) { include_once $fn; } else { e('cntopen', 'file', $fn); } $hooks = Data::folder() . $id . '.inc' . ($pcf['php_extension'] ? '.php' : ''); if (file_exists($hooks)) { include $hooks; } $form = Data::fetchForm($id); if (!isset($form)) { $e .= '<li>' . sprintf($ptx['error_form_missing'], $id) . '</li>' . PHP_EOL; return ''; } if (isset($_POST['advfrm']) && $_POST['advfrm'] == $id) { $validator = new FormValidator($form); if (($res = $validator->validate()) === true) { if ($form->isStored()) { self::appendCsv($id); } if (!self::mail($form, false)) { return self::formView($form); } if (function_exists('advfrm_custom_thanks_page')) { self::fields($fields); $thanks = advfrm_custom_thanks_page($id, $fields); } if (empty($thanks)) { $thanks = $form->getThanksPage(); } if (!empty($thanks)) { if (!self::mail($form, true)) { return self::formView($form); } header('Location: ' . $sn . '?' . $thanks); // FIXME: exit()? } else { $view = MailView::make($form, false, true); return $view->render(); } } else { return $res . self::formView($form); } } return self::formView($form); }
/** * Gets attendance base in the table: * TABLE_STATISTIC_TRACK_E_COURSE_ACCESS * @param bool $showForm * @throws ViewException */ public function getAttendanceBaseInLogin($showForm = false, $exportToPdf = true) { $table = null; $formToDisplay = null; $startDate = null; $endDate = null; $sessionId = api_get_session_id(); if ($showForm) { $form = new FormValidator('search', 'post', api_get_self() . '?' . api_get_cidreq() . '&action=calendar_logins'); $form->addDateRangePicker('range', get_lang('DateRange')); $form->addButton('submit', get_lang('Submit')); if ($form->validate()) { $values = $form->getSubmitValues(); $startDate = api_get_utc_datetime($values['range_start']); $endDate = api_get_utc_datetime($values['range_end']); } $formToDisplay = $form->returnForm(); } else { if (!empty($sessionId)) { $sessionInfo = api_get_session_info($sessionId); $startDate = $sessionInfo['access_start_date']; $endDate = $sessionInfo['access_end_date']; } } $attendance = new Attendance(); if ($exportToPdf) { $result = $attendance->exportAttendanceLogin($startDate, $endDate); if (empty($result)) { api_not_allowed(true, get_lang('NoDataAvailable')); } } $table = $attendance->getAttendanceLoginTable($startDate, $endDate); $data = array('form' => $formToDisplay, 'table' => $table); $this->view->set_data($data); $this->view->set_layout('layout'); $this->view->set_template('calendar_logins'); $this->view->render(); }
} $parent_select->addOption($label, $folder); if ($selected != '') { $parent_select->setSelected($folder); } } } } if ($is_certificate_mode) { $form->addElement('style_submit_button', 'submit', get_lang('CreateCertificate'), 'class="save"'); } else { $form->addElement('style_submit_button', 'submit', get_lang('CreateDoc'), 'class="save"'); } $form->setDefaults($defaults); // If form validates -> save the new document if ($form->validate()) { $values = $form->exportValues(); $readonly = isset($values['readonly']) ? 1 : 0; $values['title'] = trim($values['title']); if (!empty($values['curdirpath'])) { $dir = $values['curdirpath']; } if ($dir[strlen($dir) - 1] != '/') { $dir .= '/'; } //Setting the filename $filename = $values['title']; $filename = addslashes(trim($filename)); $filename = Security::remove_XSS($filename); $filename = api_replace_dangerous_char($filename); $filename = FileManager::disable_dangerous_file($filename);
<?php require_once $_SERVER['DOCUMENT_ROOT'] . '/aprimindTask/config/config.php'; /* Making data validation. */ $formValidation = new FormValidator($_REQUEST); $validationResault = $formValidation->validate(); /* If data are not valid display warnings */ if (isset($validationResault[0][0]) == 'FALSE') { $warnings = $validationResault[1]; /* If AJAX return warnings array. */ if (isset($_SERVER['HTTP_X_REQUESTED_WITH']) && !empty($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest') { echo 'window.location = "http://savchenkoportfolio/aprimindtask/view/warnings_form.php"'; return $warnings; } include_once $_SERVER['DOCUMENT_ROOT'] . '/aprimindTask/view/warnings_form.php'; /* If data are valid insert them into DB. */ } else { $insertData = new CreateData(); $insertData->insert($validationResault); /* If AJAX return relocation. */ if (isset($_SERVER['HTTP_X_REQUESTED_WITH']) && !empty($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest') { echo "window.location = 'http://savchenkoportfolio/aprimindtask/controllers/showController.php'"; return; } $showData = new ReadData(); $data = $showData->read(); include_once $_SERVER['DOCUMENT_ROOT'] . '/aprimindTask/view/resaults.php'; }
/** * Add (or edit) a template. This function displays the form and also takes care of uploading the image and storing the information in the database * * @author Patrick Cool <*****@*****.**>, Ghent University, Belgium * @version August 2008 * @since Dokeos 1.8.6 */ function add_edit_template() { // initiate the object $form = new FormValidator('template', 'post', 'settings.php?category=Templates&action=' . $_GET['action'] . '&id=' . $_GET['id']); // settting the form elements: the header if ($_GET['action'] == 'add') { $title = get_lang('AddTemplate'); } else { $title = get_lang('EditTemplate'); } $form->addElement('header', '', $title); // settting the form elements: the title of the template $form->add_textfield('title', get_lang('Title'), false); // settting the form elements: the content of the template (wysiwyg editor) $form->addElement('html_editor', 'template_text', get_lang('Text')); // settting the form elements: the form to upload an image to be used with the template $form->addElement('file', 'template_image', get_lang('Image'), ''); // settting the form elements: a little bit information about the template image $form->addElement('static', 'file_comment', '', get_lang('TemplateImageComment100x70')); // getting all the information of the template when editing a template if ($_GET['action'] == 'edit') { // Database table definition $table_system_template = Database::get_main_table('system_template'); $sql = "SELECT * FROM {$table_system_template} WHERE id = '" . Database::escape_string($_GET['id']) . "'"; $result = api_sql_query($sql, __FILE__, __LINE__); $row = Database::fetch_array($result); $defaults['template_id'] = $_GET['id']; $defaults['template_text'] = $row['content']; $defaults['title'] = $row['title']; // adding an extra field: a hidden field with the id of the template we are editing $form->addElement('hidden', 'template_id'); // adding an extrra field: a preview of the image that is currently used if (!empty($row['image'])) { $form->addElement('static', 'template_image_preview', '', '<img src="' . api_get_path(WEB_PATH) . 'home/default_platform_document/' . $row['image'] . '" alt="' . get_lang('TemplatePreview') . '"/>'); } else { $form->addElement('static', 'template_image_preview', '', '<img src="' . api_get_path(WEB_PATH) . 'home/default_platform_document/noimage.gif" alt="' . get_lang('NoTemplatePreview') . '"/>'); } // setting the information of the template that we are editing $form->setDefaults($defaults); } // settting the form elements: the submit button $form->addElement('style_submit_button', 'submit', get_lang('Ok'), 'class="save"'); // setting the rules: the required fields $form->addRule('title', '<div class="required">' . get_lang('ThisFieldIsRequired'), 'required'); $form->addRule('template_text', '<div class="required">' . get_lang('ThisFieldIsRequired'), 'required'); // if the form validates (complies to all rules) we save the information, else we display the form again (with error message if needed) if ($form->validate()) { // exporting the values $values = $form->exportValues(); // upload the file if (!empty($_FILES['template_image']['name'])) { include_once api_get_path(LIBRARY_PATH) . 'fileUpload.lib.php'; $upload_ok = process_uploaded_file($_FILES['template_image']); if ($upload_ok) { // Try to add an extension to the file if it hasn't one $new_file_name = add_ext_on_mime(stripslashes($_FILES['template_image']['name']), $_FILES['template_image']['type']); // upload dir $upload_dir = api_get_path(SYS_PATH) . 'home/default_platform_document/'; // create dir if not exists if (!is_dir($upload_dir)) { $perm = api_get_setting('permissions_for_new_directories'); $perm = octdec(!empty($perm) ? $perm : '0770'); $res = @mkdir($upload_dir, $perm); } // resize image to max default and upload require_once api_get_path(LIBRARY_PATH) . 'image.lib.php'; $temp = new image($_FILES['template_image']['tmp_name']); $picture_infos = @getimagesize($_FILES['template_image']['tmp_name']); $max_width_for_picture = 100; if ($picture_infos[0] > $max_width_for_picture) { $thumbwidth = $max_width_for_picture; if (empty($thumbwidth) or $thumbwidth == 0) { $thumbwidth = $max_width_for_picture; } $new_height = round($thumbwidth / $picture_infos[0] * $picture_infos[1]); $temp->resize($thumbwidth, $new_height, 0); } $type = $picture_infos[2]; switch (!empty($type)) { case 2: $temp->send_image('JPG', $upload_dir . $new_file_name); break; case 3: $temp->send_image('PNG', $upload_dir . $new_file_name); break; case 1: $temp->send_image('GIF', $upload_dir . $new_file_name); break; } } } // store the information in the database (as insert or as update) $table_system_template = Database::get_main_table('system_template'); if ($_GET['action'] == 'add') { $sql = "INSERT INTO {$table_system_template} (title, content, image) VALUES ('" . Database::escape_string($values['title']) . "','" . Database::escape_string($values['template_text']) . "','" . Database::escape_string($new_file_name) . "')"; $result = api_sql_query($sql, __FILE__, __LINE__); // display a feedback message Display::display_confirmation_message('TemplateAdded'); echo '<a href="settings.php?category=Templates&action=add">' . Display::return_icon('add_template.gif', get_lang('AddTemplate')) . get_lang('AddTemplate') . '</a>'; } else { $sql = "UPDATE {$table_system_template} set title = '" . Database::escape_string($values['title']) . "',\n\t\t\t\t\t\t\t\t\t\t\t \t\t content = '" . Database::escape_string($values['template_text']) . "'"; if (!empty($new_file_name)) { $sql .= ", image = '" . Database::escape_string($new_file_name) . "'"; } $sql .= " WHERE id='" . Database::escape_string($_GET['id']) . "'"; $result = api_sql_query($sql, __FILE__, __LINE__); // display a feedback message Display::display_confirmation_message('TemplateEdited'); } display_templates(); } else { // display the form $form->display(); } }
/** * form to add a category * @todo move to TestCategory.class.php * @param string $action */ function add_category_form($action) { $action = Security::remove_XSS($action); // initiate the object $form = new FormValidator('note', 'post', api_get_self() . '?action=' . $action); // Setting the form elements $form->addElement('header', get_lang('AddACategory')); $form->addElement('text', 'category_name', get_lang('CategoryName'), array('size' => '95')); $form->addHtmlEditor('category_description', get_lang('CategoryDescription'), false, false, array('ToolbarSet' => 'test_category', 'Height' => '200')); $form->addButtonCreate(get_lang('AddTestCategory'), 'SubmitNote'); // setting the rules $form->addRule('category_name', get_lang('ThisFieldIsRequired'), 'required'); // The validation or display if ($form->validate()) { $check = Security::check_token('post'); if ($check) { $values = $form->exportValues(); $v_name = Security::remove_XSS($values['category_name'], COURSEMANAGER); $v_description = Security::remove_XSS($values['category_description'], COURSEMANAGER); $objcat = new TestCategory(0, $v_name, $v_description); if ($objcat->addCategoryInBDD()) { Display::display_confirmation_message(get_lang('AddCategoryDone')); } else { Display::display_confirmation_message(get_lang('AddCategoryNameAlreadyExists')); } } Security::clear_token(); } else { display_goback(); $token = Security::get_token(); $form->addElement('hidden', 'sec_token'); $form->setConstants(array('sec_token' => $token)); $form->display(); } }
public static function displayTrackingAccessOverView($courseId, $sessionId, $studentId) { $courseId = intval($courseId); $sessionId = intval($sessionId); $studentId = intval($studentId); $em = Database::getManager(); $sessionRepo = $em->getRepository('ChamiloCoreBundle:Session'); $courseList = []; $sessionList = []; $studentList = []; if (!empty($courseId)) { $course = $em->find('ChamiloCoreBundle:Course', $courseId); $courseList[$course->getId()] = $course->getTitle(); } if (!empty($sessionId)) { $session = $em->find('ChamiloCoreBundle:Session', $sessionId); $sessionList[$session->getId()] = $session->getName(); } if (!empty($studentId)) { $student = $em->find('ChamiloUserBundle:User', $studentId); $studentList[$student->getId()] = $student->getCompleteName(); } $form = new FormValidator('access_overview', 'GET'); $form->addElement('select_ajax', 'course_id', get_lang('SearchCourse'), $courseList, ['url' => api_get_path(WEB_AJAX_PATH) . 'course.ajax.php?' . http_build_query(['a' => 'search_course_by_session_all', 'session_id' => $sessionId])]); $form->addElement('select_ajax', 'session_id', get_lang('SearchSession'), $sessionList, ['url_function' => "\n function () {\n var params = \$.param({\n a: 'search_session_by_course',\n course_id: \$('#course_id').val() || 0\n });\n\n return '" . api_get_path(WEB_AJAX_PATH) . "session.ajax.php?' + params;\n }\n "]); $form->addSelect('profile', get_lang('Profile'), ['' => get_lang('Select'), STUDENT => get_lang('Student'), COURSEMANAGER => get_lang('CourseManager'), DRH => get_lang('Drh')], ['id' => 'profile']); $form->addElement('select_ajax', 'student_id', get_lang('SearchUsers'), $studentList, ['placeholder' => get_lang('All'), 'url_function' => "\n function () {\n var params = \$.param({\n a: 'search_user_by_course',\n session_id: \$('#session_id').val(),\n course_id: \$('#course_id').val()\n });\n\n return '" . api_get_path(WEB_AJAX_PATH) . "course.ajax.php?' + params;\n }\n "]); $form->addDateRangePicker('date', get_lang('DateRange'), true, ['id' => 'date_range', 'format' => 'YYYY-MM-DD', 'timePicker' => 'false', 'validate_format' => 'Y-m-d']); $form->addHidden('display', 'accessoverview'); $form->addRule('course_id', get_lang('Required'), 'required'); $form->addRule('profile', get_lang('Required'), 'required'); $form->addButton('submit', get_lang('Generate'), 'gear', 'primary'); $table = null; if ($form->validate()) { $table = new SortableTable('tracking_access_overview', ['MySpace', 'getNumberOfRrackingAccessOverview'], ['MySpace', 'getUserDataAccessTrackingOverview'], 0); $table->additional_parameters = $form->exportValues(); $table->set_header(0, get_lang('LoginDate'), true); $table->set_header(1, get_lang('Username'), true); if (api_is_western_name_order()) { $table->set_header(2, get_lang('FirstName'), true); $table->set_header(3, get_lang('LastName'), true); } else { $table->set_header(2, get_lang('LastName'), true); $table->set_header(3, get_lang('FirstName'), true); } $table->set_header(4, get_lang('Clicks'), false); $table->set_header(5, get_lang('IP'), false); $table->set_header(6, get_lang('TimeLoggedIn'), false); } $template = new Template(null, false, false, false, false, false, false); $template->assign('form', $form->returnForm()); $template->assign('table', $table ? $table->return_table() : null); echo $template->fetch($template->get_template('my_space/accessoverview.tpl')); }
$skillList = [0 => get_lang('None')]; $gradebookList = []; foreach ($allSkills as $skill) { $skillList[$skill['id']] = $skill['name']; } foreach ($allGradebooks as $gradebook) { $gradebookList[$gradebook['id']] = $gradebook['name']; } /* Form */ $createForm = new FormValidator('skill_create'); $createForm->addHeader(get_lang('CreateSkill')); $createForm->addText('name', get_lang('Name'), true, ['id' => 'name']); $createForm->addText('short_code', get_lang('ShortCode'), false, ['id' => 'short_code']); $createForm->addSelect('parent_id', get_lang('Parent'), $skillList, ['id' => 'parent_id']); $createForm->addSelect('gradebook_id', [get_lang('Gradebook'), get_lang('WithCertificate')], $gradebookList, ['id' => 'gradebook_id', 'multiple' => 'multiple', 'size' => 10]); $createForm->addTextarea('description', get_lang('Description'), ['id' => 'description', 'rows' => 7]); $createForm->addButtonSave(get_lang('Save')); $createForm->addHidden('id', null); $createForm->setDefaults($formDefaultValues); if ($createForm->validate()) { $created = $objSkill->add($createForm->getSubmitValues()); if ($created) { Display::return_message(get_lang('TheSkillHasBeenCreated'), 'success'); } else { Display::return_message(get_lang('CannotCreateSkill'), 'error'); } header('Location: ' . api_get_path(WEB_CODE_PATH) . 'admin/skill_list.php'); exit; } //$tpl = new Template(get_lang('CreateSkill')); echo $createForm->returnForm();
/** * addSpouse * * Adds a spouse to a given user. Will also add optional children to the user and spouse. * * @param array $user * @param array $spouse * @param array $children * * @return boolean */ function addSpouse(array $user, array $spouse, array $children = array()) { $params = array('userId' => isset($user['id']) ? $user['id'] : null, 'spouseId' => isset($spouse['id']) ? $user['id'] : null, 'userSex' => isset($user['sex']) ? $spouse['sex'] : null, 'spouseSex' => isset($spouse['sex']) ? $spouse['sex'] : null); foreach ($children as $id) { $params['childId'][] = $id; } $validator = new FormValidator(); $errors = $validator->validate($params, $this->getProfile('add_spouse')); if ($errors !== true) { foreach ($errors as $msg) { $this->fcmsError->add(array('type' => 'operation', 'message' => $msg, 'error' => $params, 'file' => __FILE__, 'line' => __LINE__)); } return false; } // Get sex for user and spouse if (!isset($user['sex']) || is_null($user['sex']) || !isset($spouse['sex']) || is_null($spouse['sex'])) { $sql = "SELECT `sex`\n FROM `fcms_users`\n WHERE `id` = ?\n UNION\n SELECT `sex`\n FROM `fcms_users`\n WHERE `id` = ?"; $userSpouseInfo = $this->fcmsDatabase->getRows($sql, array($user['id'], $spouse['id'])); if ($userSpouseInfo === false) { return false; } $userInfo = $userSpouseInfo[0]; $spouseInfo = isset($userSpouseInfo[1]) ? $userSpouseInfo[1] : null; $user['sex'] = $userInfo['sex']; $spouse['sex'] = $spouseInfo['sex']; } $relationship = $spouse['sex'] == 'M' ? 'HUSB' : 'WIFE'; // Figure out the spouse relationship // Same sex if ($user['sex'] == $spouse['sex']) { $spouseRelationship = $relationship; } else { $spouseRelationship = $relationship == 'WIFE' ? 'HUSB' : 'WIFE'; } // Insert relationships for both users $sql = "INSERT INTO `fcms_relationship` (\n `user`, `relationship`, `rel_user`\n ) \n VALUES \n (?, ?, ?),\n (?, ?, ?)"; $params = array($user['id'], $relationship, $spouse['id'], $spouse['id'], $spouseRelationship, $user['id']); if (!$this->fcmsDatabase->insert($sql, $params)) { return false; } // Handle any children if (!empty($children)) { if (!$this->addChildren($children, $user, $spouse)) { return false; } } return true; }
function manage_form($default, $select_from_user_list = null, $sent_to = null) { $group_id = isset($_REQUEST['group_id']) ? intval($_REQUEST['group_id']) : null; $message_id = isset($_GET['message_id']) ? intval($_GET['message_id']) : null; $param_f = isset($_GET['f']) && $_GET['f'] == 'social' ? 'social' : null; $form = new FormValidator('compose_message', null, api_get_self() . '?f=' . $param_f, null, array('enctype' => 'multipart/form-data')); if (empty($group_id)) { if (isset($select_from_user_list)) { $form->addText('id_text_name', get_lang('SendMessageTo'), true, array('id' => 'id_text_name', 'onkeyup' => 'send_request_and_search()', 'autocomplete' => 'off')); $form->addRule('id_text_name', get_lang('ThisFieldIsRequired'), 'required'); $form->addElement('html', '<div id="id_div_search" style="padding:0px" class="message-select-box" > </div>'); $form->addElement('hidden', 'user_list', 0, array('id' => 'user_list')); } else { if (!empty($sent_to)) { $form->addLabel(get_lang('SendMessageTo'), $sent_to); } if (empty($default['users'])) { //fb select $form->addElement('select_ajax', 'users', get_lang('SendMessageTo'), array(), ['multiple' => 'multiple', 'url' => api_get_path(WEB_AJAX_PATH) . 'message.ajax.php?a=find_users']); } else { $form->addElement('hidden', 'hidden_user', $default['users'][0], array('id' => 'hidden_user')); } } } else { $userGroup = new UserGroup(); $group_info = $userGroup->get($group_id); $form->addElement('label', get_lang('ToGroup'), api_xml_http_response_encode($group_info['name'])); $form->addElement('hidden', 'group_id', $group_id); $form->addElement('hidden', 'parent_id', $message_id); } $form->addText('title', get_lang('Subject'), true); $form->addHtmlEditor('content', get_lang('Message'), false, false, array('ToolbarSet' => 'Messages', 'Width' => '100%', 'Height' => '250')); if (isset($_GET['re_id'])) { $message_reply_info = MessageManager::get_message_by_id($_GET['re_id']); $default['title'] = get_lang('MailSubjectReplyShort') . " " . $message_reply_info['title']; $form->addElement('hidden', 're_id', intval($_GET['re_id'])); $form->addElement('hidden', 'save_form', 'save_form'); //adding reply mail $user_reply_info = api_get_user_info($message_reply_info['user_sender_id']); $default['content'] = '<p><br/></p>' . sprintf(get_lang('XWroteY'), $user_reply_info['complete_name'], Security::filter_terms($message_reply_info['content'])); } if (empty($group_id)) { $form->addElement('label', '', '<div id="filepaths" class="form-group"> <div id="filepath_1"> <label>' . get_lang('FilesAttachment') . '</label> <input type="file" name="attach_1"/> <label>' . get_lang('Description') . '</label> <input id="file-descrtiption" type="text" name="legend[]" class="form-control"/> </div> </div>'); $form->addElement('label', '', '<span id="link-more-attach"><a href="javascript://" onclick="return add_image_form()">' . get_lang('AddOneMoreFile') . '</a></span> (' . sprintf(get_lang('MaximunFileSizeX'), format_file_size(api_get_setting('message.message_max_upload_filesize'))) . ')'); } $form->addButtonSend(get_lang('SendMessage'), 'compose'); $form->setRequiredNote('<span class="form_required">*</span> <small>' . get_lang('ThisFieldIsRequired') . '</small>'); if (!empty($group_id) && !empty($message_id)) { $message_info = MessageManager::get_message_by_id($message_id); $default['title'] = get_lang('MailSubjectReplyShort') . " " . $message_info['title']; } $form->setDefaults($default); $html = ''; if ($form->validate()) { $check = Security::check_token('post'); if ($check) { $user_list = $default['users']; $file_comments = $_POST['legend']; $title = $default['title']; $content = $default['content']; $group_id = isset($default['group_id']) ? $default['group_id'] : null; $parent_id = isset($default['parent_id']) ? $default['parent_id'] : null; if (is_array($user_list) && count($user_list) > 0) { //all is well, send the message foreach ($user_list as $user) { $res = MessageManager::send_message($user, $title, $content, $_FILES, $file_comments, $group_id, $parent_id); if ($res) { $html .= MessageManager::display_success_message($user); } } } else { Display::display_error_message('ErrorSendingMessage'); } } Security::clear_token(); } else { $token = Security::get_token(); $form->addElement('hidden', 'sec_token'); $form->setConstants(array('sec_token' => $token)); $html .= $form->returnForm(); } return $html; }
$form->addElement('button', 'submit', get_lang('Confirm'), array('class' => 'btn btn-primary')); $formHtml = $form->return_form(); if ($form->validate()) { $result = $form->getSubmitValues(); if (isset($result['left']) && $result['left']) { $_SESSION['before_login_accepted'] = 1; header('Location: ' . $urlOption1); exit; } } $form2 = new FormValidator('form'); if (!empty($option2) && !empty($urlOption2)) { $renderer =& $form2->defaultRenderer(); $renderer->setHeaderTemplate(''); $renderer->setFormTemplate('<form{attributes}><table border="0" cellpadding="5" cellspacing="0" width="100%">{content}</table></form>'); $renderer->setCustomElementTemplate('<tr><td>{element}</td></tr>'); $form2->addElement('html', $option2); $form2->addElement('checkbox', 'right', null, get_lang('Yes')); $form2->addElement('button', 'submit', get_lang('Send')); $formHtml2 = $form2->return_form(); if ($form2->validate()) { $result = $form2->getSubmitValues(); if (isset($result['right']) && $result['right']) { header('Location: ' . $urlOption2); exit; } } } $_template['form_option1'] = $formHtml; $_template['form_option2'] = $formHtml2; }