foreach ($this->_formPages as $formPages) { $pageContent = json_decode($formPages->page_content); $submissionDetail = ""; $submissionEdit = ""; foreach ($pageContent as $fields) { $key = "sd_" . $fields->id; if (isset($fields->type) && $fields->type != 'static-content' && $fields->type != 'google-maps') { if (isset($submission->{$key})) { $submissionDetail .= '<dt>' . $fields->label . ':</dt><dd id="' . $key . '">'; $submissionEdit .= '<div class="control-group "> <label class="control-label">' . $fields->label . ':</label> <div class="controls">'; $contentField = ""; $contentFieldEdit = ""; $contentFieldDetail = ""; $contentField = JSNUniformHelper::getDataField($fields->type, $submission, $key, $this->_item->form_id, false); $contentFieldEdit = $contentField; if ($fields->type == "email") { $contentFieldDetail = !empty($contentField) ? '<a href="mailto:' . htmlentities($contentField, ENT_QUOTES, "UTF-8") . '">' . htmlentities($contentField, ENT_QUOTES, "UTF-8") . '</a>' : "N/A"; } else { $contentFieldDetail = $contentField; } $submissionDetail .= htmlentities($contentFieldDetail, ENT_QUOTES, "UTF-8") ? str_replace("\n", "<br/>", trim(htmlentities($contentFieldDetail, ENT_QUOTES, "UTF-8"))) : "N/A"; if (isset($fields->type) && ($fields->type == "checkboxes" || $fields->type == "list" || $fields->type == "paragraph-text")) { if ($fields->type == "checkboxes" || $fields->type == "list") { $contentFieldEdit = str_replace("<br/>", "\n", $contentFieldEdit); $contentFieldEdit = str_replace("\n\n", "\n", $contentFieldEdit); $contentFieldEdit = htmlentities($contentFieldEdit, ENT_QUOTES | ENT_IGNORE, "UTF-8"); } $submissionEdit .= "<textarea name=\"submission[{$key}]\" class=\"jsn-input-xxlarge-fluid\" dataValue='" . $fields->id . "' typeValue='" . $fields->type . "' rows=\"5\" >{$contentFieldEdit}</textarea>"; } else {
/** * Save form submission * * @param Array $post Post form * * @return Messages */ public function save($post) { $return = new stdClass(); $submissionsData = array(); $validationForm = array(); $requiredField = array(); $fieldData = array(); $postFormId = isset($post['form_id']) ? $post['form_id'] : ""; $this->_db->setQuery($this->_db->getQuery(true)->select('*')->from('#__jsn_uniform_forms')->where("form_id = " . (int) $postFormId)); $dataForms = $this->_db->loadObject(); $emptyField = ''; $dataContentEmail = ''; $fileAttach = ""; $recepientEmail = ""; $nameFileByIndentifier = ''; $dataArray = $this->_validData($post); if (!empty($dataForms->form_captcha)) { if ($dataForms->form_captcha == 1) { $captchaParams = JPluginHelper::getPlugin('captcha', 'recaptcha'); $params = json_decode($captchaParams->params); if (version_compare($params->version, '2.0', '>=')) { JPluginHelper::importPlugin('captcha'); $dispatcher = JEventDispatcher::getInstance(); $checkAnswer = $dispatcher->trigger('onCheckAnswer'); if (is_array($checkAnswer)) { if ($checkAnswer[0] == false) { $return->error['captcha'] = JText::_('JSN_UNIFORM_ERROR_CAPTCHA'); return $return; } } elseif ($checkAnswer == false) { $return->error['captcha'] = JText::_('JSN_UNIFORM_ERROR_CAPTCHA'); return $return; } } else { require_once JSN_UNIFORM_LIB_CAPTCHA; $recaptchaChallenge = isset($_POST["recaptcha_challenge_field"]) ? $_POST["recaptcha_challenge_field"] : ""; $recaptchaResponse = isset($_POST["recaptcha_response_field"]) ? $_POST["recaptcha_response_field"] : ""; $resp = recaptcha_check_answer(JSN_UNIFORM_CAPTCHA_PRIVATEKEY, $_SERVER["REMOTE_ADDR"], $recaptchaChallenge, $recaptchaResponse); if (!$resp->is_valid) { $return->error['captcha'] = JText::_('JSN_UNIFORM_ERROR_CAPTCHA'); return $return; } } } else { if ($dataForms->form_captcha == 2) { if (!empty($_POST['form_name']) && !empty($_POST['captcha'])) { $sCaptcha = $_SESSION['securimage_code_value'][$_POST['form_name']] ? $_SESSION['securimage_code_value'][$_POST['form_name']] : ""; if (strtolower($sCaptcha) != strtolower($_POST['captcha'])) { $return->error['captcha_2'] = JText::_('JSN_UNIFORM_ERROR_CAPTCHA'); return $return; } } else { $return->error['captcha_2'] = JText::_('JSN_UNIFORM_ERROR_CAPTCHA'); return $return; } } } } $dataFormId = isset($dataForms->form_id) ? $dataForms->form_id : 0; $this->_db->setQuery($this->_db->getQuery(true)->select('count(*)')->from('#__jsn_uniform_form_pages')->where("form_id = " . (int) $postFormId)); $countPages = $this->_db->loadResult(); if ((int) $countPages > 1) { $fieldOrderId = array('field_id'); $this->_db->setQuery($this->_db->getQuery(true)->select('*')->from('#__jsn_uniform_form_pages')->where("form_id = " . (int) $postFormId)->order("page_id ASC")); $columsPageData = $this->_db->loadObjectList(); foreach ($columsPageData as $columData) { $pageContents = json_decode($columData->page_content); foreach ($pageContents as $pageContent) { $fieldOrderId[] = $pageContent->id; } } $fieldOrderId = array_unique($fieldOrderId); $fieldOrderId = implode(',', $fieldOrderId); $this->_db->setQuery($this->_db->getQuery(true)->select('*')->from('#__jsn_uniform_fields')->where("form_id = " . (int) $postFormId)->order("FIELD(" . $fieldOrderId . ")")); $columsSubmission = $this->_db->loadObjectList(); } else { $this->_db->setQuery($this->_db->getQuery(true)->select('*')->from('#__jsn_uniform_fields')->where("form_id = " . (int) $postFormId)->order("field_ordering ASC")); $columsSubmission = $this->_db->loadObjectList(); } $fieldClear = array(); if (isset($dataForms->form_type) && $dataForms->form_type == 1) { $this->_db->setQuery($this->_db->getQuery(true)->select('*')->from('#__jsn_uniform_form_pages')->where("form_id = " . (int) $dataForms->form_id)); $dataPages = $this->_db->loadObjectList(); foreach ($dataPages as $index => $page) { if ($index > 0) { $contentPage = isset($page->page_content) ? json_decode($page->page_content) : ""; foreach ($contentPage as $item) { $fieldClear[] = $item->id; } } } } $this->_getActionForm($dataForms->form_post_action, $dataForms->form_post_action_data, $return); $fieldEmail = array(); foreach ($columsSubmission as $colum) { if (!in_array($colum->field_id, $fieldClear)) { $fieldName = ""; $fieldName = $colum->field_id; $fieldSettings = isset($colum->field_settings) ? json_decode($colum->field_settings) : ""; $value = ""; $fieldEmail[$colum->field_id] = $colum->field_identifier; if ($colum->field_type != 'static-content' && $colum->field_type != 'google-maps') { if (in_array($colum->field_type, array("single-line-text", "website", "paragraph-text", "country"))) { $postFieldName = isset($post[$fieldName]) ? $post[$fieldName] : ''; $postName = get_magic_quotes_gpc() == true || get_magic_quotes_runtime() == true ? stripslashes($postFieldName) : $postFieldName; $value = $postName ? $postName : ""; } elseif ($colum->field_type == "choices" || $colum->field_type == "dropdown") { $value = $this->_fieldOthers($post, $fieldSettings, $fieldName); } elseif (in_array($colum->field_type, array("address", "checkboxes", "name", "list", "likert", 'recepient-email'))) { $value = $this->_fieldJson($post, $colum->field_type, $fieldName, true); if ($colum->field_type == 'recepient-email') { $recepientEmail = $value; } } elseif ($colum->field_type == "file-upload") { $value = $this->_fieldUpload($fieldSettings, $fieldName, $colum->field_title, $validationForm, $post); } elseif ($colum->field_type == "email") { $value = $this->_fieldEmail($post, $fieldName, $colum->field_title, $validationForm); } elseif ($colum->field_type == "number") { $value = $this->_fieldNumber($post, $fieldName, $colum->field_title, $validationForm); } else { if ($colum->field_type == "date") { $value = $this->_fieldDate($post, $fieldName, $colum->field_title, $validationForm); } else { if ($colum->field_type == "phone") { $value = $this->_fieldPhone($post, $fieldName, $colum->field_title, $validationForm); } else { if ($colum->field_type == "currency") { $value = $this->_fieldCurrency($post, $fieldName, $colum->field_title, $validationForm); } else { if ($colum->field_type == "password") { $value = $this->_fieldPassword($post, $fieldName, $colum->field_title, $fieldSettings, $validationForm); } elseif ($colum->field_type == "identification-code") { $value = !empty($post['identification-code'][$fieldName]) ? $post['identification-code'][$fieldName] : ''; } } } } } if (in_array($colum->field_id, $dataArray)) { $submissionsData[] = array('form_id' => $dataFormId, 'field_id' => $colum->field_id, 'submission_data_value' => $value, 'field_type' => $colum->field_type); } $keyField = $colum->field_id; $submissions = new stdClass(); $submissions->{$keyField} = $value; if (in_array($colum->field_id, $dataArray)) { $fieldData[] = array('form_id' => $dataFormId, 'field_id' => $colum->field_id, 'submission_data_value' => $value, 'field_type' => $colum->field_type, 'field_title' => $colum->field_title); } if (isset($colum->field_type)) { $nameFileByIndentifier[$colum->field_identifier] = $colum->field_title; $contentField = JSNUniformHelper::getDataField($colum->field_type, $submissions, $colum->field_id, $postFormId, false, false, 'email'); if ($colum->field_type == "file-upload") { $fileAttach[$colum->field_identifier] = JSNUniformHelper::getDataField($colum->field_type, $submissions, $colum->field_id, $postFormId, false, false, 'fileAttach'); } if ($colum->field_type == 'recepient-email') { if ($fieldSettings->options->showInNotificationEmail == 'Yes') { if (in_array($colum->field_id, $dataArray)) { $dataContentEmail[$colum->field_identifier] = $contentField ? str_replace("\n", "<br/>", trim($contentField)) : "<span>N/A</span>"; } } } if ($colum->field_type == 'identification-code') { if ($fieldSettings->options->showInNotificationEmail == 'Yes') { if (in_array($colum->field_id, $dataArray)) { $dataContentEmail[$colum->field_identifier] = $contentField ? str_replace("\n", "<br/>", trim($contentField)) : "<span>N/A</span>"; } } } else { if (in_array($colum->field_id, $dataArray)) { if ($post['use_payment_gateway'] == 1) { $dispatcher = JEventDispatcher::getInstance(); JPluginHelper::importPlugin('uniform', (string) $dataForms->form_payment_type); if ($colum->field_type == 'choices' || $colum->field_type == 'list' || $colum->field_type == 'dropdown' || $colum->field_type == 'checkboxes' || $colum->field_type == 'currency') { $fieldValue = $contentField; if ($colum->field_type == 'list' || $colum->field_type == 'checkboxes') { $fieldValue = json_decode($value); $contentEmail = '<ul style="padding:0 0px 0px 10px;margin:0;">'; foreach ($fieldValue as $itemValue) { $tmpMoney = explode('|', $itemValue); if (count($tmpMoney) > 1) { $moneyValue = trim($tmpMoney[1]); $moneyValue = $dispatcher->trigger('displayCurrency', $moneyValue); $qty = trim(end($tmpMoney)); $tmpMoney = trim($tmpMoney[0]) . ' (' . strip_tags($moneyValue[0]) . ' x ' . $qty . ')'; $contentEmail .= '<li style="padding:0;">' . $tmpMoney . '</li>'; } else { $contentEmail .= '<li style="padding:0;">' . $itemValue . '</li>'; } } $contentEmail .= '</ul>'; if (!empty($contentEmail)) { $dataContentEmail[$colum->field_identifier] = $contentEmail ? str_replace("\n", "<br/>", trim($contentEmail)) : "<span>N/A</span>"; } } else { $tmpMoney = explode('|', $fieldValue); $moneyValue = trim($tmpMoney[1]); if (count($tmpMoney) > 1) { $moneyValue = $dispatcher->trigger('displayCurrency', $moneyValue); $qty = trim(end($tmpMoney)); $dataContentEmail[$colum->field_identifier] = trim($tmpMoney[0]) . ' (' . strip_tags($moneyValue[0]) . ' x ' . $qty . ')' ? str_replace("\n", "<br/>", trim($tmpMoney[0]) . ' (' . strip_tags($moneyValue[0]) . ' x ' . $qty . ')') : "<span>N/A</span>"; } else { $dataContentEmail[$colum->field_identifier] = $fieldValue ? str_replace("\n", "<br/>", trim($fieldValue)) : "<span>N/A</span>"; } } if ($colum->field_type == 'currency') { if (!empty($fieldValue)) { $fieldValue = str_replace(',', '.', $fieldValue); $currecyValue = $dispatcher->trigger('displayCurrency', $fieldValue); $currecyValue = strip_tags($currecyValue[0]); $dataContentEmail[$colum->field_identifier] = $currecyValue ? str_replace("\n", "<br/>", trim($currecyValue)) : "<span>N/A</span>"; } } } else { $dataContentEmail[$colum->field_identifier] = $contentField ? str_replace("\n", "<br/>", trim($contentField)) : "<span>N/A</span>"; } } else { $dataContentEmail[$colum->field_identifier] = $contentField ? str_replace("\n", "<br/>", trim($contentField)) : "<span>N/A</span>"; } } } $requiredField[$colum->field_identifier] = $fieldSettings->options->required; } // if (!empty($fieldSettings->options->noDuplicates) && (int) $fieldSettings->options->noDuplicates == 1) { $this->_checkDuplicates($post, $fieldName, $colum->field_title, $validationForm); } if (isset($fieldSettings->options->limitation) && (int) $fieldSettings->options->limitation == 1 && !empty($post[$fieldName])) { if ($fieldSettings->options->limitMin <= $fieldSettings->options->limitMax && $fieldSettings->options->limitMax > 0) { $this->_checkLimitChar($post, $fieldSettings, $fieldName, $colum->field_title, $validationForm); } } if (isset($fieldSettings->options->requiredConfirm) && (int) $fieldSettings->options->requiredConfirm == 1) { $postData = isset($post[$fieldName]) ? $post[$fieldName] : ''; $postDataConfirm = isset($post[$fieldName . "_confirm"]) ? $post[$fieldName . "_confirm"] : ''; if (isset($fieldSettings->options->required) && (int) $fieldSettings->options->required == 1 && $postData != $postDataConfirm) { $validationForm[$fieldName] = JText::sprintf('JSN_UNIFORM_CONFIRM_FIELD_CONFIRM', $colum->field_title); } else { if (!empty($postData) && !empty($postDataConfirm) && $postData != $postDataConfirm) { $validationForm[$fieldName] = JText::sprintf('JSN_UNIFORM_CONFIRM_FIELD_CONFIRM', $colum->field_title); } } } if (isset($fieldSettings->options->required) && (int) $fieldSettings->options->required == 1 && (int) $fieldSettings->options->hideField != 1) { switch ($colum->field_type) { case "name": $postFieldName = isset($post['name'][$fieldName]) ? $post['name'][$fieldName] : ''; if ($postFieldName['first'] == "" && $postFieldName['last'] == "" && $postFieldName['suffix'] == "") { $validationForm['name'][$fieldName] = JText::_('JSN_UNIFORM_CONFIRM_FIELD_CANNOT_EMPTY'); } break; case "address": $postAddress = $post['address'][$fieldName]; if ($postAddress['street'] == "" && $postAddress['line2'] == "" && $postAddress['city'] == "" && $postAddress['code'] == "" && $postAddress['state'] == "") { $validationForm['address'][$fieldName] = JText::_('JSN_UNIFORM_CONFIRM_FIELD_CANNOT_EMPTY'); } break; case "email": $postFieldEmail = isset($post[$fieldName]) ? $post[$fieldName] : ''; $postEmail = get_magic_quotes_gpc() == true || get_magic_quotes_runtime() == true ? stripslashes($postFieldEmail) : $postFieldEmail; $regex = '/^[_a-zA-Z0-9-]+(\\.[_a-zA-Z0-9-]+)*@[a-zA-Z0-9-]+(\\.[a-zA-Z0-9-]+)*(\\.[a-zA-Z]{2,6})$/'; if (!preg_match($regex, $postEmail)) { $validationForm[$fieldName] = JText::_('JSN_UNIFORM_CONFIRM_FIELD_INVALID'); } break; case "number": if ($post['number'][$fieldName] == "") { $validationForm[$fieldName] = JText::_('JSN_UNIFORM_CONFIRM_FIELD_CANNOT_EMPTY'); } else { $postNumber = $post['number'][$fieldName]['value']; $postNumberDecimal = $post['number'][$fieldName]['decimal']; $regex = '/^[0-9]+$/'; $checkNumber = false; if ($postNumber != "") { if (preg_match($regex, $postNumber)) { $checkNumber = true; } } if ($postNumberDecimal != "") { if (preg_match($regex, $postNumberDecimal)) { $checkNumber = true; } } if (!$checkNumber) { $validationForm[$fieldName] = JText::_('JSN_UNIFORM_CONFIRM_FIELD_CANNOT_EMPTY'); } } break; case "website": $postWebsite = isset($post[$fieldName]) ? $post[$fieldName] : ''; $regex = "/^((http|https|ftp):\\/\\/|www([0-9]{0,9})?\\.)?([a-zA-Z0-9][a-zA-Z0-9_-]*(?:\\.[a-zA-Z0-9][a-zA-Z0-9_-]*)+):?(\\d+)?\\/?/i"; if (!preg_match($regex, $postWebsite)) { $validationForm[$fieldName] = JText::_('JSN_UNIFORM_CONFIRM_FIELD_INVALID'); } break; case "file-upload": if (empty($_FILES[$fieldName]['name'])) { $validationForm[$fieldName] = JText::_('JSN_UNIFORM_CONFIRM_FIELD_CANNOT_EMPTY'); } break; case "date": if (isset($fieldSettings->options->enableRageSelection) && $fieldSettings->options->enableRageSelection == "1") { if ($post['date'][$fieldName]['date'] == "" || $post['date'][$fieldName]['daterange'] == "") { $validationForm['date'][$fieldName] = JText::_('JSN_UNIFORM_CONFIRM_FIELD_CANNOT_EMPTY'); } } else { if ($post['date'][$fieldName]['date'] == "") { $validationForm['date'][$fieldName] = JText::_('JSN_UNIFORM_CONFIRM_FIELD_CANNOT_EMPTY'); } } break; case "currency": if ($post['currency'][$fieldName]['value'] == "") { $validationForm['currency'][$fieldName] = JText::_('JSN_UNIFORM_CONFIRM_FIELD_CANNOT_EMPTY'); } break; case "phone": if (isset($fieldSettings->options->format) && $fieldSettings->options->format == "3-field") { if ($post['phone'][$fieldName]['one'] == "" || $post['phone'][$fieldName]['two'] == "" || $post['phone'][$fieldName]['three'] == "") { $validationForm['phone'][$fieldName] = JText::_('JSN_UNIFORM_CONFIRM_FIELD_CANNOT_EMPTY'); } } else { if ($post['phone'][$fieldName]['default'] == "") { $validationForm['phone'][$fieldName] = JText::_('JSN_UNIFORM_CONFIRM_FIELD_CANNOT_EMPTY'); } } break; case "password": if (count($post['password'][$fieldName]) > 1) { if ($post['password'][$fieldName][0] == "" || $post['password'][$fieldName][1] == "") { $validationForm['password'][$fieldName] = JText::_('JSN_UNIFORM_CONFIRM_FIELD_CANNOT_EMPTY'); } else { if ($post['password'][$fieldName][0] != "" && $post['password'][$fieldName][1] != "" && $post['password'][$fieldName][0] != $post['password'][$fieldName][1]) { $validationForm['password'][$fieldName] = JText::_('JSN_UNIFORM_CONFIRM_FIELD_PASSWORD_CONFIRM'); } } } else { if ($post['password'][$fieldName][0] == "") { $validationForm['password'][$fieldName] = JText::_('JSN_UNIFORM_CONFIRM_FIELD_CANNOT_EMPTY'); } } break; default: if (isset($post[$fieldName]) && $post[$fieldName] == "") { $validationForm[$fieldName] = JText::_('JSN_UNIFORM_CONFIRM_FIELD_CANNOT_EMPTY'); } break; } } } else { if (isset($colum->field_type) && $colum->field_type != 'file-upload' && $colum->field_type != 'google-maps') { $nameFileByIndentifier[$colum->field_identifier] = $colum->field_title; if ($colum->field_type == 'static-content') { if ($fieldSettings->options->showInNotificationEmail != 'No') { if (in_array($colum->field_id, $dataArray)) { $dataContentEmail[$colum->field_identifier] = $fieldSettings->options->value; } } } else { if (in_array($colum->field_id, $dataArray)) { $dataContentEmail[$colum->field_identifier] = $fieldSettings->options->value; } } } } } } if (!$validationForm) { $this->_save($dataForms, $return, $post, $submissionsData, $dataContentEmail, $nameFileByIndentifier, $requiredField, $fileAttach, $recepientEmail); if ((string) $dataForms->form_payment_type != '') { $dispatcher = JEventDispatcher::getInstance(); JPluginHelper::importPlugin('uniform', (string) $dataForms->form_payment_type); $dispatcher->trigger('processToPostPaymentGateway', array($post, $fieldData)); } return $return; } else { $return->error = $validationForm; return $return; } }
$dataItem = array(); for ($i = 0; $i < count($fieldIdentifier); $i++) { if (in_array($fieldIdentifier[$i], $arrayField)) { $dataItem[] = JText::_($fieldTitle[$i]); } } $dataItem[] = JText::_("JGRID_HEADING_ID"); $data[] = $dataItem; if (is_array($arrayField)) { if ($this->_dataExport) { foreach ($this->_dataExport as $i => $item) { $dataItem = array(); foreach ($arrayField as $j => $field) { $contentField = ""; if (isset($fieldType[$field])) { $contentField = JSNUniformHelper::getDataField($fieldType[$field], $item, $field, $formId, false, false, 'export'); $contentField = $contentField ? $contentField : ""; if ($field == 'submission_created_by' && !$item->{$field}) { $contentField = isset($listUser[$item->{$field}]) ? $listUser[$item->{$field}] : "Guest"; } $dataItem[] = $contentField; } } $dataItem[] = $item->submission_id; $data[] = $dataItem; } } } if (isset($_GET['e']) && $_GET['e'] == "excel") { include_once JSN_UNIFORM_LIB_PHPEXCEL; // generate file (constructor parameters are optional)
/** * Save form submission * * @param Array $post Post form * * @return Messages */ public function save($post) { $return = new stdClass(); $submissionsData = array(); $validationForm = array(); $requiredField = array(); $postFormId = isset($post['form_id']) ? $post['form_id'] : ""; $this->_db->setQuery($this->_db->getQuery(true)->select('*')->from('#__jsn_uniform_forms')->where("form_id = " . (int) $postFormId)); $dataForms = $this->_db->loadObject(); $dataContentEmail = ''; $fileAttach = ""; $nameFileByIndentifier = ''; if (!empty($dataForms->form_captcha)) { if ($dataForms->form_captcha == 1) { require_once JSN_UNIFORM_LIB_CAPTCHA; $recaptchaChallenge = isset($_POST["recaptcha_challenge_field"]) ? $_POST["recaptcha_challenge_field"] : ""; $recaptchaResponse = isset($_POST["recaptcha_response_field"]) ? $_POST["recaptcha_response_field"] : ""; $resp = recaptcha_check_answer(JSN_UNIFORM_CAPTCHA_PRIVATEKEY, $_SERVER["REMOTE_ADDR"], $recaptchaChallenge, $recaptchaResponse); if (!$resp->is_valid) { $return->error['captcha'] = JText::_('JSN_UNIFORM_ERROR_CAPTCHA'); return $return; } } else { if ($dataForms->form_captcha == 2) { if (!empty($_POST['form_name']) && !empty($_POST['captcha'])) { $sCaptcha = $_SESSION['securimage_code_value'][$_POST['form_name']] ? $_SESSION['securimage_code_value'][$_POST['form_name']] : ""; if (strtolower($sCaptcha) != strtolower($_POST['captcha'])) { $return->error['captcha_2'] = JText::_('JSN_UNIFORM_ERROR_CAPTCHA'); return $return; } } else { $return->error['captcha_2'] = JText::_('JSN_UNIFORM_ERROR_CAPTCHA'); return $return; } } } } $dataFormId = isset($dataForms->form_id) ? $dataForms->form_id : 0; $this->_db->setQuery($this->_db->getQuery(true)->select('*')->from('#__jsn_uniform_fields')->where("form_id = " . (int) $postFormId)->order("field_ordering ASC")); $columsSubmission = $this->_db->loadObjectList(); $fieldClear = array(); if (isset($dataForms->form_type) && $dataForms->form_type == 1) { $this->_db->setQuery($this->_db->getQuery(true)->select('*')->from('#__jsn_uniform_form_pages')->where("form_id = " . (int) $dataForms->form_id)); $dataPages = $this->_db->loadObjectList(); foreach ($dataPages as $index => $page) { if ($index > 0) { $contentPage = isset($page->page_content) ? json_decode($page->page_content) : ""; foreach ($contentPage as $item) { $fieldClear[] = $item->id; } } } } $this->_getActionForm($dataForms->form_post_action, $dataForms->form_post_action_data, $return); $fieldEmail = array(); foreach ($columsSubmission as $colum) { if (!in_array($colum->field_id, $fieldClear)) { $fieldName = ""; $fieldName = $colum->field_id; $fieldSettings = isset($colum->field_settings) ? json_decode($colum->field_settings) : ""; $value = ""; $fieldEmail[$colum->field_id] = $colum->field_identifier; if ($colum->field_type != 'static-content' && $colum->field_type != 'google-maps') { if (in_array($colum->field_type, array("single-line-text", "website", "paragraph-text", "country"))) { $postFieldName = isset($post[$fieldName]) ? $post[$fieldName] : ''; $postName = get_magic_quotes_gpc() == true || get_magic_quotes_runtime() == true ? stripslashes($postFieldName) : $postFieldName; $value = $postName ? $postName : ""; } elseif ($colum->field_type == "choices" || $colum->field_type == "dropdown") { $value = $this->_fieldOthers($post, $fieldSettings, $fieldName); } elseif (in_array($colum->field_type, array("address", "checkboxes", "name", "list", "likert"))) { $value = $this->_fieldJson($post, $colum->field_type, $fieldName, true); } elseif ($colum->field_type == "file-upload") { $value = $this->_fieldUpload($fieldSettings, $fieldName, $colum->field_title, $validationForm, $post); } elseif ($colum->field_type == "email") { $value = $this->_fieldEmail($post, $fieldName, $colum->field_title, $validationForm); } elseif ($colum->field_type == "number") { $value = $this->_fieldNumber($post, $fieldName, $colum->field_title, $validationForm); } else { if ($colum->field_type == "date") { $value = $this->_fieldDate($post, $fieldName, $colum->field_title, $validationForm); } else { if ($colum->field_type == "phone") { $value = $this->_fieldPhone($post, $fieldName, $colum->field_title, $validationForm); } else { if ($colum->field_type == "currency") { $value = $this->_fieldCurrency($post, $fieldName, $colum->field_title, $validationForm); } else { if ($colum->field_type == "password") { $value = $this->_fieldPassword($post, $fieldName, $colum->field_title, $fieldSettings, $validationForm); } } } } } $submissionsData[] = array('form_id' => $dataFormId, 'field_id' => $colum->field_id, 'submission_data_value' => $value, 'field_type' => $colum->field_type); $keyField = $colum->field_id; $submissions = new stdClass(); $submissions->{$keyField} = $value; if (isset($colum->field_type)) { $nameFileByIndentifier[$colum->field_identifier] = $colum->field_title; $contentField = JSNUniformHelper::getDataField($colum->field_type, $submissions, $colum->field_id, $postFormId, false, false, 'email'); if ($colum->field_type == "file-upload") { $fileAttach[$colum->field_identifier] = JSNUniformHelper::getDataField($colum->field_type, $submissions, $colum->field_id, $postFormId, false, false, 'fileAttach'); } $dataContentEmail[$colum->field_identifier] = $contentField ? str_replace("\n", "<br/>", trim($contentField)) : "<span>N/A</span>"; $requiredField[$colum->field_identifier] = $fieldSettings->options->required; } // if (!empty($fieldSettings->options->noDuplicates) && (int) $fieldSettings->options->noDuplicates == 1) { $this->_checkDuplicates($post, $fieldName, $colum->field_title, $validationForm); } if (isset($fieldSettings->options->limitation) && (int) $fieldSettings->options->limitation == 1 && !empty($post[$fieldName])) { if ($fieldSettings->options->limitMin <= $fieldSettings->options->limitMax && $fieldSettings->options->limitMax > 0) { $this->_checkLimitChar($post, $fieldSettings, $fieldName, $colum->field_title, $validationForm); } } if (isset($fieldSettings->options->requiredConfirm) && (int) $fieldSettings->options->requiredConfirm == 1) { $postData = isset($post[$fieldName]) ? $post[$fieldName] : ''; $postDataConfirm = isset($post[$fieldName . "_confirm"]) ? $post[$fieldName . "_confirm"] : ''; if (isset($fieldSettings->options->required) && (int) $fieldSettings->options->required == 1 && $postData != $postDataConfirm) { $validationForm[$fieldName] = JText::sprintf('JSN_UNIFORM_CONFIRM_FIELD_CONFIRM', $colum->field_title); } else { if (!empty($postData) && !empty($postDataConfirm) && $postData != $postDataConfirm) { $validationForm[$fieldName] = JText::sprintf('JSN_UNIFORM_CONFIRM_FIELD_CONFIRM', $colum->field_title); } } } if (isset($fieldSettings->options->required) && (int) $fieldSettings->options->required == 1 && (int) $fieldSettings->options->hideField != 1) { switch ($colum->field_type) { case "name": $postFieldName = isset($post['name'][$fieldName]) ? $post['name'][$fieldName] : ''; if ($postFieldName['first'] == "" && $postFieldName['last'] == "" && $postFieldName['suffix'] == "") { $validationForm['name'][$fieldName] = JText::_('JSN_UNIFORM_CONFIRM_FIELD_CANNOT_EMPTY'); } break; case "address": $postAddress = $post['address'][$fieldName]; if ($postAddress['street'] == "" && $postAddress['line2'] == "" && $postAddress['city'] == "" && $postAddress['code'] == "" && $postAddress['state'] == "") { $validationForm['address'][$fieldName] = JText::_('JSN_UNIFORM_CONFIRM_FIELD_CANNOT_EMPTY'); } break; case "email": $postFieldEmail = isset($post[$fieldName]) ? $post[$fieldName] : ''; $postEmail = get_magic_quotes_gpc() == true || get_magic_quotes_runtime() == true ? stripslashes($postFieldEmail) : $postFieldEmail; $regex = '/^[_a-zA-Z0-9-]+(\\.[_a-zA-Z0-9-]+)*@[a-zA-Z0-9-]+(\\.[a-zA-Z0-9-]+)*(\\.[a-zA-Z]{2,6})$/'; if (!preg_match($regex, $postEmail)) { $validationForm[$fieldName] = JText::_('JSN_UNIFORM_CONFIRM_FIELD_INVALID'); } break; case "number": if ($post['number'][$fieldName] == "") { $validationForm[$fieldName] = JText::_('JSN_UNIFORM_CONFIRM_FIELD_CANNOT_EMPTY'); } else { $postNumber = $post['number'][$fieldName]['value']; $postNumberDecimal = $post['number'][$fieldName]['decimal']; $regex = '/^[0-9]+$/'; $checkNumber = false; if ($postNumber != "") { if (preg_match($regex, $postNumber)) { $checkNumber = true; } } if ($postNumberDecimal != "") { if (preg_match($regex, $postNumberDecimal)) { $checkNumber = true; } } if (!$checkNumber) { $validationForm[$fieldName] = JText::_('JSN_UNIFORM_CONFIRM_FIELD_CANNOT_EMPTY'); } } break; case "website": $postWebsite = isset($post[$fieldName]) ? $post[$fieldName] : ''; $regex = "/^((http|https|ftp):\\/\\/|www([0-9]{0,9})?\\.)?([a-zA-Z0-9][a-zA-Z0-9_-]*(?:\\.[a-zA-Z0-9][a-zA-Z0-9_-]*)+):?(\\d+)?\\/?/i"; if (!preg_match($regex, $postWebsite)) { $validationForm[$fieldName] = JText::_('JSN_UNIFORM_CONFIRM_FIELD_INVALID'); } break; case "file-upload": if (empty($_FILES[$fieldName]['name'])) { $validationForm[$fieldName] = JText::_('JSN_UNIFORM_CONFIRM_FIELD_CANNOT_EMPTY'); } break; case "date": if (isset($fieldSettings->options->enableRageSelection) && $fieldSettings->options->enableRageSelection == "1") { if ($post['date'][$fieldName]['date'] == "" || $post['date'][$fieldName]['daterange'] == "") { $validationForm['date'][$fieldName] = JText::_('JSN_UNIFORM_CONFIRM_FIELD_CANNOT_EMPTY'); } } else { if ($post['date'][$fieldName]['date'] == "") { $validationForm['date'][$fieldName] = JText::_('JSN_UNIFORM_CONFIRM_FIELD_CANNOT_EMPTY'); } } break; case "currency": if ($post['currency'][$fieldName]['value'] == "") { $validationForm['currency'][$fieldName] = JText::_('JSN_UNIFORM_CONFIRM_FIELD_CANNOT_EMPTY'); } break; case "phone": if (isset($fieldSettings->options->format) && $fieldSettings->options->format == "3-field") { if ($post['phone'][$fieldName]['one'] == "" || $post['phone'][$fieldName]['two'] == "" || $post['phone'][$fieldName]['three'] == "") { $validationForm['phone'][$fieldName] = JText::_('JSN_UNIFORM_CONFIRM_FIELD_CANNOT_EMPTY'); } } else { if ($post['phone'][$fieldName]['default'] == "") { $validationForm['phone'][$fieldName] = JText::_('JSN_UNIFORM_CONFIRM_FIELD_CANNOT_EMPTY'); } } break; case "password": if (count($post['password'][$fieldName]) > 1) { if ($post['password'][$fieldName][0] == "" || $post['password'][$fieldName][1] == "") { $validationForm['password'][$fieldName] = JText::_('JSN_UNIFORM_CONFIRM_FIELD_CANNOT_EMPTY'); } else { if ($post['password'][$fieldName][0] != "" && $post['password'][$fieldName][1] != "" && $post['password'][$fieldName][0] != $post['password'][$fieldName][1]) { $validationForm['password'][$fieldName] = JText::_('JSN_UNIFORM_CONFIRM_FIELD_PASSWORD_CONFIRM'); } } } else { if ($post['password'][$fieldName][0] == "") { $validationForm['password'][$fieldName] = JText::_('JSN_UNIFORM_CONFIRM_FIELD_CANNOT_EMPTY'); } } break; default: if (isset($post[$fieldName]) && $post[$fieldName] == "") { $validationForm[$fieldName] = JText::_('JSN_UNIFORM_CONFIRM_FIELD_CANNOT_EMPTY'); } break; } } } else { if (isset($colum->field_type) && $colum->field_type != 'file-upload' && $colum->field_type != 'google-maps') { $nameFileByIndentifier[$colum->field_identifier] = $colum->field_title; $dataContentEmail[$colum->field_identifier] = $fieldSettings->options->value; } } } } if (!$validationForm) { $this->_save($dataForms, $return, $post, $submissionsData, $dataContentEmail, $nameFileByIndentifier, $requiredField, $fileAttach); return $return; } else { $return->error = $validationForm; return $return; } }
?> <tr class="row<?php echo $i % 2; ?> "> <td class="jsn-column-select"> <?php echo JHtml::_('grid.id', $i, $item->submission_id); ?> </td> <?php if (is_array($arrayField)) { foreach ($arrayField as $j => $field) { $contentField = ""; if (isset($fieldType[$field])) { $contentField = JSNUniformHelper::getDataField($fieldType[$field], $item, $field, $formId, true, true, 'list'); $contentField = $contentField ? str_replace("\n", "<br/>", trim($contentField)) : "<span>N/A</span>"; if ($j < 3) { $contentField = '<td><a href="' . JRoute::_('index.php?option=com_uniform&view=submission&submission_id=' . (int) $item->submission_id) . '">' . $contentField . '</a> </td>'; } elseif ($field == 'submission_created_by' && !$item->{$field}) { $contentField = isset($item->{$field}) ? JSNUniformHelper::getUserNameById($item->{$field}) : "Guest"; $contentField = "<td>{$contentField}</td>"; } else { $contentField = "<td>{$contentField}</td>"; } echo $contentField; } } } ?> <td class="jsn-column-id">