• Модуль: iblock
  • Путь к файлу: ~/bitrix/modules/iblock/classes/general/iblockproperty.php
  • Класс: CAllIBlockProperty
  • Вызов: CAllIBlockProperty::CheckFields
public function CheckFields(&$arFields, $ID=false, $bFormValidate=false)
{
	global $APPLICATION;
	$this->LAST_ERROR = "";
	if ($ID===false || array_key_exists("NAME", $arFields))
	{
		if ($arFields["NAME"] == '')
			$this->LAST_ERROR .= GetMessage("IBLOCK_PROPERTY_BAD_NAME")."
"; } if(array_key_exists("CODE", $arFields) && mb_strlen($arFields["CODE"])) { if(mb_strpos("0123456789", mb_substr($arFields["CODE"], 0, 1)) !== false) $this->LAST_ERROR .= GetMessage("IBLOCK_PROPERTY_CODE_FIRST_LETTER").": ".htmlspecialcharsbx($arFields["CODE"])."
"; if(preg_match("/[^A-Za-z0-9_]/", $arFields["CODE"])) $this->LAST_ERROR .= GetMessage("IBLOCK_PROPERTY_WRONG_CODE").": ".htmlspecialcharsbx($arFields["CODE"])."
"; } if(!$bFormValidate) { if($ID===false && !is_set($arFields, "IBLOCK_ID")) $this->LAST_ERROR .= GetMessage("IBLOCK_BAD_BLOCK_ID")."
"; if(is_set($arFields, "IBLOCK_ID")) { $arFields["IBLOCK_ID"] = (int)$arFields["IBLOCK_ID"]; $r = CIBlock::GetList(array(), array("ID"=>$arFields["IBLOCK_ID"], "CHECK_PERMISSIONS" => "N")); if(!$r->Fetch()) $this->LAST_ERROR .= GetMessage("IBLOCK_BAD_BLOCK_ID")."
"; } } if(isset($arFields["USER_TYPE"])) { $arUserType = CIBlockProperty::GetUserType($arFields["USER_TYPE"]); if(isset($arUserType["CheckFields"])) { $value=array("VALUE"=>$arFields["DEFAULT_VALUE"]); $arError = call_user_func_array($arUserType["CheckFields"],array($arFields,$value)); if(is_array($arError) && count($arError)>0) $this->LAST_ERROR .= implode("
", $arError)."
"; } } if(!$bFormValidate) { $APPLICATION->ResetException(); if($ID===false) { $db_events = GetModuleEvents("iblock", "OnBeforeIBlockPropertyAdd", true); } else { $arFields["ID"] = $ID; $db_events = GetModuleEvents("iblock", "OnBeforeIBlockPropertyUpdate", true); } foreach($db_events as $arEvent) { $bEventRes = ExecuteModuleEventEx($arEvent, array(&$arFields)); if($bEventRes===false) { if($err = $APPLICATION->GetException()) { $this->LAST_ERROR .= $err->GetString()."
"; } else { $APPLICATION->ThrowException("Unknown error"); $this->LAST_ERROR .= "Unknown error.
"; } break; } } } if($this->LAST_ERROR <> '') return false; return true; }