AddEventHandler("main", "OnBeforeEventAdd", array("MainHandlers", "OnBeforeEventAddHandler"));
class MainHandlers
{
function OnBeforeEventAddHandler($event, $lid, $arFields)
{
if ($event == "INFOLETTERS")
{
$file = $arFields["PROPERTY_VALUES"]["43"]["n0"]["VALUE"];
require_once($_SERVER["DOCUMENT_ROOT"] . "/bitrix/php_interface/include/classes/mail_attach.php");
SendAttache($event, $lid, $arFields, $file);
$event = 'null'; $lid = 'null';
}
}
}
AddEventHandler('iblock', 'OnAfterIBlockElementAdd', Array('MyClass', 'OnAfterIBlockElementAddHandler'));
class MyClass
{
function OnAfterIBlockElementAddHandler(&$arFields)
{
if($arFields['IBLOCK_ID']==10)
{
$arEventFields = array(
"ID" => $arFields["ID"],
"MESSAGE" => $arFields["NAME"],
"EMAIL_TO" => implode(",", $EMAIL_TO),
"ADMIN_EMAIL" => implode(",", $ADMIN_EMAIL),
"ADD_EMAIL" => implode(",", $ADD_EMAIL),
"STAT_EMAIL" => implode(",", $VIEW_EMAIL),
"EDIT_EMAIL" => implode(",", $EDIT_EMAIL),
"OWNER_EMAIL" => implode(",", $OWNER_EMAIL),
"BCC" => implode(",", $BCC),
"ACTIVE" => $arFields["ACTIVE"],
"name" => $arFields["PROPERTY_VALUES"]["25"]["n0"],
"number" => $arFields["PROPERTY_VALUES"]["24"]["n0"],
"file" => $arFields["PROPERTY_VALUES']["43"]["n0"]["VALUE"],
"data" => $arFields["PROPERTY_VALUES"]["23"]["n0"]["VALUE"],
"anons" => $arFields["PREVIEW_TEXT"],
"detail" => $arFields["DETAIL_TEXT"],
"CREATED_BY" => $CREATED_BY,
"DATE_MODIFY" => $arFields["DATE_MODIFY"],
"MODIFIED_BY" => $MODIFIED_BY
);
CEvent::Send("INFOLETTERS", "ru", $arEventFields);
AddMessage2Log("OK");
}
}
} |