protected function preserveFilters() { if (isset($this->filters) && isset($this->form)) { foreach ($this->filters as $key => $value) { $this->form->preserved_filters[filter_var($key, FILTER_SANITIZE_STRING)] = filter_var($value, FILTER_SANITIZE_STRING); } } if (isset($this->form)) { $this->form->preserved_filters['filter_pagination_page'] = filter_var($this->request->getRequestParam('filter_pagination_page'), FILTER_SANITIZE_NUMBER_INT); } }
public function mapFormFromRequest($raw_values = array()) { if (!$this->form->initialised) { $this->form->initialise(); } foreach ($this->request->getRawRequest() as $key => $value) { if ($key == 'id') { $this->form->record_id = substr($value, 0, 3) == 'new' ? $value : intval($value); } if ($this->form->fieldExists($key, true)) { $field = $this->form->getField($key, true); if (array_search($key, $raw_values) !== false) { $field->setValueRaw($this->request->getRequestParam($key, null, null)); } else { $field->setValue($this->request->getRequestParam($key)); } if (array_key_exists('confirm_' . $key, $_REQUEST)) { $field->setConfirmValue($this->request->getRequestParam('confirm_' . $key)); } } } //If any values were not sent back, mark them as not published foreach ($this->form->field_sets as &$field_set) { foreach ($field_set->fields as &$field) { switch ($field->type) { case 'button': case 'submit': case 'reset': case 'container': continue; default: if (!$field instanceof FieldLinkButton) { if (!array_key_exists($field->name, $_REQUEST) && !array_key_exists($field->name, $_FILES)) { $field->published = false; } } break; } } } return $this->form; }
public function validate(Request $request, &$message = null, $suppress_errors = false) { if (strlen($this->url) > 0 && $request->getRequestParam($this->name)) { //Button clicked, but javascript disabled if (!headers_sent()) { //Clear the buffers $loopbreaker = 0; while (ob_get_length() !== false) { $loopbreaker++; @ob_end_clean(); if ($loopbreaker > 15) { break; } } //Do the redirect header('Location: ' . $this->url, true, 301); exit; } } return true; }
/** * Move file from staging area to final destination * @param string $message * @return boolean */ public function formSubmitted(Request $request, &$message) { $success = true; clearstatcache(); $value = $this->getValue(); if (isset($value) && strlen($value) > 0) { $tmp_file = $this->staging_folder . '/tmp_' . $this->parent_field_set->parent_form->submission_id . '_' . $value; if (file_exists($tmp_file) && file_exists($this->upload_folder . '/' . $value)) { $success = false; $message = $this->language->form['err_fld_file_exists']; } else { if (file_exists($tmp_file)) { $success = rename($tmp_file, $this->upload_folder . '/' . $value); if (!$success) { $message = $this->language->form['err_fld_file_copy_from_staging_failed']; } } } } //If original file has been deleted, remove it from the file system $orig_file_names = explode(",", $request->getRequestParam('orig_' . $this->name)); foreach ($orig_file_names as $orig_file_name) { if (strlen($orig_file_name) > 0 && $this->value != $orig_file_name && strpos($orig_file_name, '..') === false) { $full_file_name = $this->upload_folder . '/' . filter_var($orig_file_name, FILTER_SANITIZE_STRING); if (file_exists($full_file_name)) { unlink($full_file_name); } } } $this->clearDownOldTempFiles(); return $success; }