• Модуль: tasks
  • Путь к файлу: ~/bitrix/modules/tasks/lib/rest/controllers/task/result.php
  • Класс: BitrixTasksRestControllersTaskResult
  • Вызов: Result::deleteFromCommentAction
public function deleteFromCommentAction(int $commentId)
{
	if (!$commentId)
	{
		$this->errorCollection->add([new Error('Comment not found.')]);
		return null;
	}

	$userId = $this->getUserId();
	if (!$userId)
	{
		$this->errorCollection->add([new Error('Access denied.')]);
		return null;
	}

	if (
		!Loader::includeModule('tasks')
		|| !Loader::includeModule('forum')
	)
	{
		$this->errorCollection->add([new Error('Module not loaded.')]);
		return null;
	}

	$comment = BitrixForumMessageTable::getById($commentId)->fetchObject();
	if (!$comment)
	{
		$this->errorCollection->add([new Error('Comment not found.')]);
		return null;
	}

	$taskId = (int) str_replace('TASK_', '', $comment->getXmlId());

	if (
		(
			!UserModel::createFromId($userId)->isAdmin()
			&& $comment->getAuthorId() !== $userId
		)
		|| !TaskAccessController::can($userId, ActionDictionary::ACTION_TASK_READ, $taskId)
	)
	{
		$this->errorCollection->add([new Error('Access denied.')]);
		return null;
	}

	(new ResultManager($userId))->deleteByComment($commentId);
	return null;
}