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; }
$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 (strlen($strError) <= 0) { if (strlen($apply) > 0) { LocalRedirect("/bitrix/admin/form_result_edit.php?lang=" . LANGUAGE_ID . "&WEB_FORM_ID=" . $WEB_FORM_ID . "&RESULT_ID=" . $RESULT_ID); } else { LocalRedirect("/bitrix/admin/form_result_list.php?lang=" . LANGUAGE_ID . "&WEB_FORM_ID=" . $WEB_FORM_ID); } } } else { $strError .= $error; } } if ($EDIT_RESULT_TEMPLATE == "") { $EDIT_RESULT_TEMPLATE = $arForm["EDIT_RESULT_TEMPLATE"]; }
// 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'; if (strlen($_REQUEST["web_form_submit"])>0 && !(defined("ADMIN_SECTION") && ADMIN_SECTION===true)) { if ($arParams["SEF_MODE"] == "Y") { //LocalRedirect($arParams["LIST_URL"]."?strFormNote=".urlencode($arResult["FORM_NOTE"])); LocalRedirect( str_replace( array('#WEB_FORM_ID#', '#RESULT_ID#'), array($arParams['WEB_FORM_ID'], $arParams["RESULT_ID"]), $arParams["LIST_URL"] )."?formresult=".urlencode($arResult["FORM_RESULT"]) );
function Update($RESULT_ID, $arrVALUES = false, $UPDATE_ADDITIONAL = "N", $CHECK_RIGHTS = "Y") { return CFormResult::Update($RESULT_ID, $arrVALUES, $UPDATE_ADDITIONAL, $CHECK_RIGHTS); }