AddEventHandler("iblock", "OnBeforeIBlockElementAdd", array("СatalogAdd", "OnBeforeIBlockElementAdd"));
class СatalogAdd
{
function OnBeforeIBlockElementAdd (&$arFields)
{
if ($arFields['PROPERTY_VALUES'][94] > 0)
{
$author_id = $arFields['PROPERTY_VALUES'][94];
$arSelect = Array("ID", "IBLOCK_ID");
$arFilter = Array("IBLOCK_ID"=>25, "ACTIVE"=>"Y", "PROPERTY_129"=>$author_id);
$res = CIBlockElement::GetList(Array(), $arFilter, false, false, $arSelect);
$res_arr = $res->Fetch();
$arFields['PROPERTY_VALUES'][146] = $res_arr["ID"];
}
}
} |