AddEventHandler("main", "OnBeforeEventAdd", array("MailEventHandler", "onBeforeEventAddHandler"));
class MailEventHandler
{
static function onBeforeEventAddHandler(&$event, &$lid, &$arFields, &$message_id, &$files)
{
// Меняем тип почтового события и ID почтового шаблона на свои
if ($event === 'FORM_FILLING_SIMPLE_FORM_1' && $message_id === '53') {
if (!is_array($files)) $files = [];
foreach ($arFields as $key => $field) {
if ($link = self::getLinkFromField($field)) {
if ($arFile = self::getFileFromLink($link)) {
$files[] = $arFile['FILE_ID'];
}
}
}
}
}
AddEventHandler("main", "OnBeforeEventAdd", array("MailEventHandler2", "onBeforeEventAddHandler2"));
class MailEventHandler2
{
static function onBeforeEventAddHandler2(&$event, &$lid, &$arFields, &$message_id, &$files)
{
if ($event === 'FORM_FILLING_SIMPLE_FORM_5' && $message_id === '58') {
if (!is_array($files)) $files = [];
foreach ($arFields as $key => $field) {
if ($link = self::getLinkFromField($field)) {
if ($arFile = self::getFileFromLink2($link)) {
$files[] = $arFile['FILE_ID'];
}
}
}
}
}