- Модуль: tasks
- Путь к файлу: ~/bitrix/modules/tasks/lib/integration/forum/task/comment.php
- Класс: BitrixTasksIntegrationForumTaskComment
- Вызов: Comment::processMentions
static function processMentions(array $fields): array
{
$newMentionedUserIds = [];
if (
TaskLimit::isLimitExceeded()
|| !is_array($fields)
|| !isset($fields['MESSAGE']['POST_MESSAGE'], $fields['PARAMS']['AUX'])
|| ($fields['PARAMS']['AUX'] === 'Y' && $fields['PARAMS']['IS_PING_COMMENT'] !== 'Y')
)
{
return $newMentionedUserIds;
}
preg_match_all(
"/[users*=s*([^]]*)](.+?)[/user]/is" . BX_UTF_PCRE_MODIFIER,
$fields['MESSAGE']['POST_MESSAGE'],
$matches
);
if (!is_array($matches) || empty($matches) || !is_array($matches[1]) || empty($matches[1]))
{
return $newMentionedUserIds;
}
$mentionedUserIds = array_filter(array_map('intval', $matches[1]));
if (empty($mentionedUserIds))
{
return $newMentionedUserIds;
}
$task = false;
$taskData = false;
$taskMembers = [];
if (isset($fields['PARAMS']['XML_ID']))
{
preg_match("/TASK_(d+)/is" . BX_UTF_PCRE_MODIFIER, $fields['PARAMS']['XML_ID'], $matches);
if (is_array($matches) && !empty($matches[1]) && (int)$matches[1])
{
try
{
$task = new CTaskItem((int)$matches[1], User::getId());
$taskData = $task->getData();
$taskMembers = CTaskNotifications::getRecipientsIDs($taskData, false);
}
catch (TasksException | CTaskAssertException $e)
{
}
}
}
if (!empty($taskMembers))
{
foreach ($mentionedUserIds as $userId)
{
if (!in_array($userId, $taskMembers))
{
$newMentionedUserIds[] = (int)$userId;
}
}
}
if ($task && $taskData)
{
if (!empty($newMentionedUserIds))
{
static::addNewAuditorsFromMentions($task, $newMentionedUserIds);
static::sendUpdateNotificationToOldMembers($taskData, $newMentionedUserIds);
}
static::unmuteMentionedUsers($task, $mentionedUserIds);
}
return $newMentionedUserIds;
}