コード例 #1
0
ファイル: form_edit.php プロジェクト: Satariall/izurit
 }
 // access rights
 $arFields["arGROUP"] = array();
 foreach ($arGroups as $arrG) {
     $arFields["arGROUP"][$arrG["ID"]] = $_REQUEST["PERMISSION_" . $arrG["ID"]];
 }
 $res = intval(CForm::Set($arFields, $ID));
 if ($res > 0) {
     if ($bEditTemplate && $USE_DEFAULT_TEMPLATE == "N") {
         // structure
         $FORM_STRUCTURE = $_REQUEST["FORM_STRUCTURE"];
         $arrFS = CheckSerializedData($FORM_STRUCTURE) ? unserialize($FORM_STRUCTURE) : array();
         if (CFormOutput::CheckTemplate($FORM_TEMPLATE, $arrFS)) {
             $GLOBALS['CACHE_MANAGER']->ClearByTag('form_' . $res);
             foreach ($arrFS as $arQuestion) {
                 $arQuestionFields = array("FORM_ID" => $res, "TITLE" => $arQuestion["CAPTION_UNFORM"], "TITLE_TYPE" => $arQuestion["isHTMLCaption"] == "N" ? "text" : "html", "SID" => $arQuestion["FIELD_SID"], "REQUIRED" => $arQuestion["isRequired"] == "N" ? "N" : "Y", "IN_RESULTS_TABLE" => $arQuestion["inResultsTable"] == "Y" ? "Y" : "N", "IN_EXCEL_TABLE" => $arQuestion["inExcelTable"] == "Y" ? "Y" : "N", "ACTIVE" => CForm::isFieldInTemplate($arQuestion["FIELD_SID"], $FORM_TEMPLATE) ? "Y" : "N", 'FILTER_TITLE' => $arQuestion['FILTER_TITLE']);
                 $FIELD_ID = $arQuestion["isNew"] == "Y" ? false : $arQuestion["ID"];
                 $QID = CFormField::Set($arQuestionFields, $FIELD_ID, 'Y', 'N');
                 if ($QID) {
                     foreach ($arQuestion["structure"] as $arAnswer) {
                         if (strlen($arAnswer["MESSAGE"]) <= 0) {
                             if ($arAnswer['ANS_NEW'] != 'Y' && in_array($arAnswer['FIELD_TYPE'], array('dropdown', 'multiselect', 'checkbox', 'radio'))) {
                                 CFormAnswer::Delete($arAnswer['ID'], $QID);
                             }
                             continue;
                         }
                         if (isset($arAnswer['DEFAULT'])) {
                             if ($arAnswer["FIELD_TYPE"] == "dropdown" || $arAnswer['FIELD_TYPE'] == "multiselect") {
                                 if ($arAnswer["DEFAULT"] == "Y") {
                                     $arAnswer["FIELD_PARAM"] = "SELECTED";
                                 } else {
コード例 #2
0
 public static function CheckTemplate($FORM_TEMPLATE, &$arrFS)
 {
     if (count($arrFS) > 0) {
         $arFldSIDs = array();
         $arInactiveFldSIDs = array();
         $str = "";
         foreach ($arrFS as $key => $arField) {
             $cur_str = "";
             if (strlen(trim($arField["FIELD_SID"])) <= 0) {
                 $cur_str .= GetMessage("FORM_ERROR_FORGOT_SID") . "<br>";
             } elseif (preg_match("/[^A-Za-z_01-9]/", $arField["FIELD_SID"])) {
                 $cur_str .= GetMessage("FORM_ERROR_INCORRECT_SID") . "<br>";
             } elseif (in_array($arField['FIELD_SID'], $arFldSIDs)) {
                 $key = array_search($arField['FIELD_SID'], $arInactiveFldSIDs);
                 if ($key) {
                     unset($arrFS[$key]);
                     unset($arInactiveFldSIDs[$key]);
                     unset($arFldSIDs[$key]);
                 } else {
                     $s = str_replace("#TYPE#", GetMessage("FORM_TYPE_FIELD"), GetMessage("FORM_ERROR_WRONG_SID"));
                     $s = str_replace("#ID#", $zr["ID"], $s);
                     $cur_str .= $s . "<br>";
                 }
             } else {
                 $arFldSIDs[$key] = $arField["FIELD_SID"];
                 if (!CForm::isFieldInTemplate($arField["FIELD_SID"], $FORM_TEMPLATE)) {
                     $arInactiveFldSIDs[$key] = $arField["FIELD_SID"];
                 }
             }
             if (!empty($cur_str)) {
                 $str .= $cur_str;
             }
         }
         if (!empty($str)) {
             $_GLOBALS["strError"] .= $str;
             return false;
         } else {
             return true;
         }
     }
     return true;
 }
コード例 #3
0
ファイル: form_edit.php プロジェクト: ASDAFF/entask.ru
			$arrFS = CheckSerializedData($FORM_STRUCTURE) ? unserialize($FORM_STRUCTURE) : array();

			if (CFormOutput::CheckTemplate($FORM_TEMPLATE, $arrFS))
			{
				$GLOBALS['CACHE_MANAGER']->ClearByTag('form_'.$res);
				foreach ($arrFS as $arQuestion)
				{
					$arQuestionFields = array(
						"FORM_ID" 	 => $res,
						"TITLE" 	 => $arQuestion["CAPTION_UNFORM"],
						"TITLE_TYPE" => $arQuestion["isHTMLCaption"] == "N" ? "text" : "html",
						"SID" 		 => $arQuestion["FIELD_SID"],
						"REQUIRED" 	 => $arQuestion["isRequired"] == "N" ? "N" : "Y",
						"IN_RESULTS_TABLE" => $arQuestion["inResultsTable"] == "Y" ? "Y" : "N",
						"IN_EXCEL_TABLE" => $arQuestion["inExcelTable"] == "Y" ? "Y" : "N",
						"ACTIVE"	 => CForm::isFieldInTemplate($arQuestion["FIELD_SID"], $FORM_TEMPLATE) ? "Y" : "N",
						'FILTER_TITLE' => $arQuestion['FILTER_TITLE'],
					);

					$FIELD_ID = $arQuestion["isNew"] == "Y" ? false : $arQuestion["ID"];

					$QID = CFormField::Set($arQuestionFields, $FIELD_ID, 'Y', 'N');

					if ($QID)
					{
						foreach ($arQuestion["structure"] as $arAnswer)
						{
							if (strlen($arAnswer["MESSAGE"]) <= 0)
							{
								if (
									$arAnswer['ANS_NEW'] != 'Y'