// регистрируем обработчик
AddEventHandler("iblock", "OnAfterIBlockElementAdd", Array("MyClass2", "OnAfterIBlockElementAddHandler"));
class MyClass2
{
// создаем обработчик события "OnAfterIBlockElementAdd"
function OnAfterIBlockElementAddHandler(&$arFields)
{
if (intval($arFields["IBLOCK_ID"]) == 38)
{
$db_props = CIBlockElement::GetProperty(38, $arFields["ID"], "sort", "asc", array());
$PROPS = array();
while($ar_props = $db_props->Fetch())
{
$PROPS[$ar_props['CODE']] = $ar_props['VALUE'];
}
$user = $PROPS["name"];
$text = $PROPS["text"];
$arSend = array(
'COMPANY' => $arFields['NAME'],
'USER' => $user,
'TEXT' => $text);
CEvent::Send('letterdir', SITE_ID, $arSend, 'N');
}
}
} |