function getData(&$arResult) { global $APPLICATION, $USER; //$arResult = $this->__prepareDataForTpl(); $arResult["WEB_FORM_ID"] = $this->WEB_FORM_ID; $arResult["WEB_FORM_NAME"] = $this->WEB_FORM_NAME; if ($this->RESULT_ID > 0) { $arResult["RESULT_ID"] = $this->RESULT_ID; } $arResult["F_RIGHT"] = $this->F_RIGHT; if (strlen($_REQUEST["web_form_submit"]) > 0 || strlen($_REQUEST["web_form_apply"]) > 0) { $this->arrVALUES = $_REQUEST; if ($this->RESULT_ID) { $this->__form_validate_errors = CForm::Check($this->WEB_FORM_ID, $this->arrVALUES, $this->RESULT_ID); } else { $this->__form_validate_errors = CForm::Check($this->WEB_FORM_ID, $this->arrVALUES); } if (!$this->isFormErrors()) { if (check_bitrix_sessid()) { $return = false; if ($this->RESULT_ID) { CFormResult::Update($this->RESULT_ID, $this->arrVALUES, $this->arParams["EDIT_ADDITIONAL"]); $this->strFormNote = GetMessage("FORM_DATA_SAVED"); if (strlen($_REQUEST["web_form_submit"]) > 0 && !(defined("ADMIN_SECTION") && ADMIN_SECTION === true)) { if ($this->arParams["SEF_MODE"] == "Y") { LocalRedirect($this->arParams["LIST_URL"] . "?strFormNote=" . urlencode($this->strFormNote)); } else { LocalRedirect($this->arParams["LIST_URL"] . (strpos($this->arParams["LIST_URL"], "?") === false ? "?" : "&") . "WEB_FORM_ID=" . $this->WEB_FORM_ID . "&strFormNote=" . urlencode($this->strFormNote)); } die; } if (strlen($_REQUEST["web_form_apply"]) > 0 && !(defined("ADMIN_SECTION") && ADMIN_SECTION === true) && $this->arParams["SEF_MODE"] == "Y") { // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! LocalRedirect($this->arParams["EDIT_URL"] . (strpos($this->arParams["EDIT_URL"], "?") === false ? "?" : "&") . "strFormNote=" . urlencode($this->strFormNote)); die; } if (defined("ADMIN_SECTION") && ADMIN_SECTION === true) { if (strlen($_REQUEST["web_form_submit"]) > 0) { LocalRedirect(BX_ROOT . "/admin/form_result_list.php?lang=" . LANG . "&WEB_FORM_ID=" . $this->WEB_FORM_ID . "&strFormNote=" . urlencode($this->strFormNote)); } elseif (strlen($_REQUEST["web_form_apply"]) > 0) { LocalRedirect(BX_ROOT . "/admin/form_result_edit.php?lang=" . LANG . "&WEB_FORM_ID=" . $this->WEB_FORM_ID . "&RESULT_ID=" . $this->RESULT_ID . "&strFormNote=" . urlencode($this->strFormNote)); } die; } } else { if ($this->RESULT_ID = CFormResult::Add($this->WEB_FORM_ID, $this->arrVALUES)) { $this->strFormNote = GetMessage("FORM_DATA_SAVED1") . $this->RESULT_ID . GetMessage("FORM_DATA_SAVED2"); CFormResult::SetEvent($this->RESULT_ID); CFormResult::Mail($this->RESULT_ID); if ($this->F_RIGHT >= 15) { if (strlen($_REQUEST["web_form_submit"]) > 0 && strlen($this->arParams["LIST_URL"]) > 0) { if ($this->arParams["SEF_MODE"] == "Y") { LocalRedirect($this->arParams["LIST_URL"] . "?strFormNote=" . urlencode($this->strFormNote)); } else { LocalRedirect($this->arParams["LIST_URL"] . (strpos($this->arParams["LIST_URL"], "?") === false ? "?" : "&") . "WEB_FORM_ID=" . $this->WEB_FORM_ID . "&RESULT_ID=" . $this->RESULT_ID . "&strFormNote=" . urlencode($this->strFormNote)); } die; } elseif (strlen($_REQUEST["web_form_apply"]) > 0 && strlen($this->arParams["EDIT_URL"]) > 0) { if ($this->arParams["SEF_MODE"] == "Y") { LocalRedirect(str_replace("#RESULT_ID#", $this->RESULT_ID . $this->arParams["EDIT_URL"]) . "?strFormNote=" . urlencode($this->strFormNote)); } else { LocalRedirect($this->arParams["EDIT_URL"] . (strpos($this->arParams["EDIT_URL"], "?") === false ? "?" : "&") . "RESULT_ID=" . $this->RESULT_ID . "&strFormNote=" . urlencode($this->strFormNote)); } die; } $arResult["return"] = true; } else { LocalRedirect($APPLICATION->GetCurPage() . "?WEB_FORM_ID=" . $this->WEB_FORM_ID . "&strFormNote=" . urlencode($this->strFormNote)); die; } } else { $this->__form_validate_errors = $GLOBALS["strError"]; } } } } } return $arResult; }
} } else { $strError .= $error; } } else { $arrVALUES = CFormResult::GetDataByIDForHTML($RESULT_ID, $EDIT_ADDITIONAL); } } } // ============================ oldies finish ======================== $WEB_FORM_ID = intval($WEB_FORM_ID); $arForm = CForm::GetByID_admin($WEB_FORM_ID); // result changes saving if ($old_module_version != 'Y' && $_SERVER['REQUEST_METHOD'] == "POST" && intval($WEB_FORM_ID) > 0 && (strlen($save) > 0 || strlen($apply) > 0) && check_bitrix_sessid()) { $arrVALUES = $_REQUEST; $error = CForm::Check($WEB_FORM_ID, $arrVALUES, $RESULT_ID); if (strlen($error) <= 0) { $bUpdate = true; if (!$RESULT_ID) { $default_status = CFormStatus::GetDefault($WEB_FORM_ID); $status_tmp = $arrVALUES['status_' . $arForm['SID']]; $arrVALUES['status_' . $arForm['SID']] = $default_status; $RESULT_ID = CFormResult::Add($WEB_FORM_ID, $arrVALUES, 'Y', intval($arrVALUES['USER_ID']) > 0 ? intval($arrVALUES['USER_ID']) : false); $arrVALUES['status_' . $arForm['SID']] = $status_tmp == $default_status ? 'NOT_REF' : $status_tmp; $bUpdate = $RESULT_ID > 0 && $EDIT_ADDITIONAL == 'Y'; // little hack to prevent doubling of status notification message } // second update needed to set additional fields if ($bUpdate && strlen($strError) <= 0) { CFormResult::Update($RESULT_ID, $arrVALUES, $EDIT_ADDITIONAL); }
} } // if there's no error if (strlen($arResult["ERROR"]) <= 0) { // ************************************************************* // // get/post processing // // ************************************************************* // if (strlen($_REQUEST["web_form_submit"])>0 || strlen($_REQUEST["web_form_apply"])>0) { $arResult["arrVALUES"] = $_REQUEST; // check errors $arResult["FORM_ERRORS"] = CForm::Check($arParams["WEB_FORM_ID"], $arResult["arrVALUES"], $arParams["RESULT_ID"], "Y", $arParams['USE_EXTENDED_ERRORS']); if ( $arParams['USE_EXTENDED_ERRORS'] == 'Y' && (!is_array($arResult["FORM_ERRORS"]) || count($arResult["FORM_ERRORS"]) <= 0) || $arParams['USE_EXTENDED_ERRORS'] != 'Y' && strlen($arResult["FORM_ERRORS"]) <= 0 ) { // check session id if (check_freetrix_sessid()) { $return = false; if (CFormResult::Update($arParams["RESULT_ID"], $arResult["arrVALUES"], $arParams["EDIT_ADDITIONAL"])) { $arResult["FORM_RESULT"] = 'editok';
/** * Валидируем POST данные * @param array $values * @return bool */ protected function checkErrors(array $values) { $this->errors = \CForm::Check($this->formId, $values, false, 'Y', 'Y'); return !is_array($this->errors) || count($this->errors) <= 0; }