- Модуль: sender
- Путь к файлу: ~/bitrix/modules/sender/lib/entity/letter.php
- Класс: BitrixSenderEntityLetter
- Вызов: Letter::copy
public function copy()
{
$configurationId = $this->getMessage()->getConfiguration()->getId();
if (!$configurationId)
{
return null;
}
$result = $this->getMessage()->copyConfiguration($configurationId);
if (!$result->isSuccess() || !$result->getId())
{
return null;
}
$data = array(
'CAMPAIGN_ID' => $this->get('CAMPAIGN_ID'),
'MESSAGE_CODE' => $this->get('MESSAGE_CODE'),
'MESSAGE_ID' => $result->getId(),
'REITERATE' => $this->get('REITERATE'),
'TEMPLATE_TYPE' => $this->get('TEMPLATE_TYPE'),
'TEMPLATE_ID' => $this->get('TEMPLATE_ID'),
'CREATED_BY' => $this->getUser()->getId(),
'UPDATED_BY' => $this->getUser()->getId(),
'IS_TRIGGER' => $this->get('IS_TRIGGER'),
'TITLE' => Loc::getMessage('SENDER_ENTITY_LETTER_COPY_PREFIX') . ' ' . $this->get('TITLE'),
'SEGMENTS_INCLUDE' => $this->get('SEGMENTS_INCLUDE'),
'SEGMENTS_EXCLUDE' => $this->get('SEGMENTS_EXCLUDE'),
);
$instance = static::create()->mergeData($data);
$instance->save();
$this->getErrorCollection()->add($instance->getErrors());
if (!is_null($this->getMessage()->getConfiguration()->get('MESSAGE')))
{
FileTable::syncFiles(
$instance->getId(),
0,
$this->getMessage()->getConfiguration()->get('MESSAGE')
);
}
return $instance->getId();
}