- Модуль: tasks
- Путь к файлу: ~/bitrix/modules/tasks/lib/integration/socialnetwork/usecase/taskupdated.php
- Класс: BitrixTasksIntegrationSocialNetworkUseCaseTaskUpdated
- Вызов: TaskUpdated::setSonetLogRights
private function setSonetLogRights(Message $message, array $params, TaskObject $task, array $previousFields): void
{
// TODO: this code was moved from classes/tasksnotifications and needs reraftoring
$logId = (int)$params['LOG_ID'];
$effectiveUserId = (int)$params['EFFECTIVE_USER_ID'];
if ($logId <= 0 || $effectiveUserId <= 0)
{
return;
}
// Get current rights
$currentRights = [];
$rightsResult = CSocNetLogRights::getList([], ['LOG_ID' => $logId]);
while ($right = $rightsResult->fetch())
{
$currentRights[] = $right['GROUP_CODE'];
}
$taskMembers = $message->getMetaData()->getUserRepository()->getRecepients(
$task,
$message->getSender()
);
$newRights = $this->recepients2Rights($taskMembers);
$oldGroupId = $previousFields['GROUP_ID'] ?? null;
$newGroupId = $task->getGroupId();
$groupChanged = (isset($newGroupId, $oldGroupId) && $newGroupId && $newGroupId !== (int)$oldGroupId);
// If rights really changed, update them
if (
$groupChanged
|| !empty(array_diff($currentRights, $newRights))
|| !empty(array_diff($newRights, $currentRights))
)
{
$groupRights = [];
if ($newGroupId)
{
$groupRights = $this->prepareRightsCodesForViewInGroupLiveFeed($newGroupId);
}
elseif (isset($oldGroupId))
{
$groupRights = $this->prepareRightsCodesForViewInGroupLiveFeed($oldGroupId);
}
CSocNetLogRights::deleteByLogID($logId);
foreach ($taskMembers as $user)
{
$code = $this->recepients2Rights([$user]);
$follow = !UserOption::isOptionSet($previousFields['ID'], $user->getId(), UserOptionOption::MUTED);
CSocNetLogRights::add($logId, $code, false, $follow);
}
if (!empty($groupRights))
{
CSocNetLogRights::add($logId, $groupRights);
}
}
}