- Модуль: sender
- Путь к файлу: ~/bitrix/modules/sender/lib/mailingchain.php
- Класс: BitrixSenderMailingChainTable
- Вызов: MailingChainTable::copy
static function copy(?int $id): ?int
{
$dataDb = static::getList(array('filter' => array('ID' => $id)));
if (!$data = $dataDb->fetch())
{
return null;
}
$copiedDb = static::add(array(
'MAILING_ID' => $data['MAILING_ID'],
'EMAIL_FROM' => $data['EMAIL_FROM'],
'TITLE' => $data['TITLE'],
'SUBJECT' => $data['SUBJECT'],
'MESSAGE' => $data['MESSAGE'],
'TEMPLATE_TYPE' => $data['TEMPLATE_TYPE'],
'TEMPLATE_ID' => $data['TEMPLATE_ID'],
'PRIORITY' => $data['PRIORITY'],
'LINK_PARAMS' => $data['LINK_PARAMS'],
));
if (!$copiedDb->isSuccess())
{
return null;
}
$copiedId = $copiedDb->getId();
$attachmentDb = MailingAttachmentTable::getList(array(
'filter' => array('=CHAIN_ID' => $id)
));
while($attachment = $attachmentDb->fetch())
{
$copiedFileId = CFile::copyFile($attachment['FILE_ID']);
if (!$copiedFileId)
{
continue;
}
MailingAttachmentTable::add(array(
'CHAIN_ID' => $copiedId,
'FILE_ID' => $copiedFileId
));
}
return $copiedId;
}