- Модуль: im
- Путь к файлу: ~/bitrix/modules/im/lib/V2/Link/Task/TaskService.php
- Класс: BitrixImV2LinkTaskTaskService
- Вызов: TaskService::prepareDataForCreateSlider
public function prepareDataForCreateSlider(Chat $chat, ?Message $message = null): Result
{
$result = new Result();
if (!Loader::includeModule('tasks'))
{
return $result->addError(new TaskError(TaskError::TASKS_NOT_INSTALLED));
}
$userId = $this->getContext()->getUserId();
$chat->setContext($this->context);
$data = ['PARAMS' => []];
$data['LINK'] = str_replace(
['#USER_ID#', '#ID#'],
$userId,
BitrixMainConfigOption::get('intranet', 'search_user_url', SITE_DIR . 'company/personal/user/#USER_ID#/')
) . 'tasks/task/edit/0/';
$data['PARAMS']['RESPONSIBLE_ID'] = $userId;
$data['PARAMS']['IM_CHAT_ID'] = $chat->getChatId();
if ($chat->getEntityType() !== 'SONET_GROUP')
{
$data['PARAMS']['AUDITORS'] = implode(",", $this->getAuditors($chat));
}
if ($chat->getEntityType() === 'SONET_GROUP')
{
$data['PARAMS']['GROUP_ID'] = (int)$chat->getEntityId();
}
if ($chat instanceof ChatOpenLineChat && Loader::includeModule('crm'))
{
$entityData = explode('|', $chat->getEntityData1() ?? '');
if (isset($entityData[0], $entityData[1], $entityData[2]) && $entityData[0] === 'Y')
{
$crmType = CCrmOwnerTypeAbbr::ResolveByTypeID(CCrmOwnerType::ResolveID($entityData[1]));
$data['PARAMS']['UF_CRM_TASK'] = $crmType.'_'.$entityData[2];
}
}
if (isset($message))
{
$message->setContext($this->context);
$data['PARAMS']['DESCRIPTION'] = CIMShare::PrepareText([
'CHAT_ID' => $chat->getChatId(),
'MESSAGE_ID' => $message->getMessageId(),
'MESSAGE_TYPE' => $chat->getType(),
'MESSAGE' => $message->getMessage(),
'AUTHOR_ID' => $message->getAuthorId(),
'FILES' => $this->getFilesForPrepareText($message)
]);
$fileIds = $this->getFilesIdsForTaskFromMessage($message);
if (!empty($fileIds))
{
$diskFileUFCode = BitrixTasksIntegrationDiskUserField::getMainSysUFCode();
$data['PARAMS'][$diskFileUFCode] = $fileIds;
$signer = new Signer();
$data['PARAMS'][$diskFileUFCode . '_SIGN'] = $signer->sign(Json::encode($fileIds), static::SIGNATURE_SALT);
}
$data['PARAMS']['IM_MESSAGE_ID'] = $message->getMessageId();
}
return $result->setResult($data);
}