- Модуль: tasks
- Путь к файлу: ~/bitrix/modules/tasks/lib/integration/mail/task.php
- Класс: BitrixTasksIntegrationMailTask
- Вызов: Task::onReplyReceived
static function onReplyReceived(Event $event)
{
$taskId = intval($event->getParameter('entity_id'));
$userId = intval($event->getParameter('from'));
$message = trim($event->getParameter('content'));
$attachments = $event->getParameter('attachments');
if(!is_array($attachments))
{
$attachments = array();
}
// message can not be empty, so if only attachments supplied, use dummy message
if (
$message == ''
&& count($attachments) > 0
)
{
$message = Loc::getMessage('TASKS_MAIL_ATTACHMENTS');
}
if (
$taskId <= 0
|| $userId <= 0
|| $message == ''
)
{
return false;
}
list($message, $files) = static::processAttachments($message, $attachments, $userId);
try
{
if (Loader::includeModule('disk'))
{
BitrixDiskUfFileUserType::setValueForAllowEdit("FORUM_MESSAGE", true);
}
// forum will check rights, no need to worry
BitrixTasksIntegrationForumTaskComment::add($taskId, array(
'POST_MESSAGE' => $message,
'AUTHOR_ID' => $userId,
'SOURCE_ID' => 'EMAIL',
'UF_FORUM_MESSAGE_DOC' => $files,
));
}
catch(TasksException $e) // todo: get rid of this annoying catch by making BitrixTasks*Exception classes inherited from TasksException (dont forget about code)
{
if($e->checkOfType(TasksException::TE_TASK_NOT_FOUND_OR_NOT_ACCESSIBLE))
{
return false;
}
else
{
throw $e; // let it log
}
}
catch(BitrixTasksAccessDeniedException $e) // task not found or not accessible
{
return false;
}
return true; // required, dont remove
}