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; }
// check errors $arResult["FORM_ERRORS"] = CForm::Check($arParams["WEB_FORM_ID"], $arResult["arrVALUES"], false, "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 user session if (check_bitrix_sessid()) { $return = false; // add result if($RESULT_ID = CFormResult::Add($arParams["WEB_FORM_ID"], $arResult["arrVALUES"])) { //$arResult["FORM_NOTE"] = GetMessage("FORM_DATA_SAVED1").$RESULT_ID.GetMessage("FORM_DATA_SAVED2"); $arResult["FORM_RESULT"] = 'addok'; // send email notifications CFormCRM::onResultAdded($arParams["WEB_FORM_ID"], $RESULT_ID); CFormResult::SetEvent($RESULT_ID); CFormResult::Mail($RESULT_ID); // choose type of user redirect and do it if ($arResult["F_RIGHT"] >= 15) { if (strlen($_REQUEST["web_form_submit"])>0 && strlen($arParams["LIST_URL"]) > 0) {
} } // ============================ 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 (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); } }
function Add($WEB_FORM_ID, $arrVALUES = false, $CHECK_RIGHTS = "Y", $USER_ID = false) { return CFormResult::Add($WEB_FORM_ID, $arrVALUES, $CHECK_RIGHTS, $USER_ID); }
/** * Добавляет результат */ protected function addResult() { $resultId = \CFormResult::Add($this->formId, $this->requestData); return $resultId; }
<? require($_SERVER["DOCUMENT_ROOT"]."/bitrix/header.php"); $APPLICATION->SetTitle("Партнерам"); if (isset($_POST["send"])) { CModule::IncludeModule('form'); $arFields = array( "form_text_1" => $_POST["name"], "form_text_24" => $_POST["company"], "form_text_25" => $_POST["city"], "form_text_2" => $_POST["phone"], "form_email_3" => $_POST["email"], "form_textarea_4" => $_POST["message"], ); if ($RESULT_ID = CFormResult::Add(1, $arFields)) { $successMessage = "Ваше сообщение принято. Спасибо за Ваш отклик."; } else { global $strError; echo $strError; } } ?> <?if ($successMessage) : ?> <div class="success_message_partner" style="display: none;"><?php echo $successMessage; ?> </div> <?endif;?> <?$APPLICATION->IncludeComponent(