Title
CModule::IncludeModule("iblock");
if(intval($_REQUEST["IBLOCK_ID_FIELDS"])>0){
$bError = false;
$IBLOCK_ID = intval($_REQUEST["IBLOCK_ID_FIELDS"]);
$ib = new CIBlock;
$arFields = CIBlock::GetArrayByID($IBLOCK_ID);
$arFields["GROUP_ID"] = CIBlock::GetGroupPermissions($IBLOCK_ID);
$arFields["NAME"] = $arFields["NAME"]."_new";
unset($arFields["ID"]);
if($_REQUEST["IBLOCK_TYPE_ID"]!="empty")
$arFields["IBLOCK_TYPE_ID"]=$_REQUEST["IBLOCK_TYPE_ID"];
$ID = $ib->Add($arFields);
if(intval($ID)"asc", "name"=>"asc"), Array("ACTIVE"=>"Y", "IBLOCK_ID"=>$iblock_prop));
while ($prop_fields = $properties->GetNext()){
if($prop_fields["PROPERTY_TYPE"] == "L"){
$property_enums = CIBlockPropertyEnum::GetList(Array("DEF"=>"DESC", "SORT"=>"ASC"),
Array("IBLOCK_ID"=>$iblock_prop, "CODE"=>$prop_fields["CODE"]));
while($enum_fields = $property_enums->GetNext()){
$prop_fields["VALUES"][] = Array(
"VALUE" => $enum_fields["VALUE"],
"DEF" => $enum_fields["DEF"],
"SORT" => $enum_fields["SORT"]
);
}
}
$prop_fields["IBLOCK_ID"]=$iblock_prop_new;
unset($prop_fields["ID"]);
foreach($prop_fields as $k=>$v){
if(!is_array($v))$prop_fields[$k]=trim($v);
if($k{0}=='~') unset($prop_fields[$k]);
}
$PropID = $ibp->Add($prop_fields);
if(intval($PropID)<=0)
$bError = true;
}
if(!$bError && $IBLOCK_ID>0)
LocalRedirect($APPLICATION->GetCurPageParam("success=Y",array("success","IBLOCK_ID_FIELDS")));
else
LocalRedirect($APPLICATION->GetCurPageParam("error=Y",array("success","IBLOCK_ID_FIELDS")));
}
$str .='';
echo $str;