• Модуль: tasks
  • Путь к файлу: ~/bitrix/modules/tasks/classes/general/commentitem.php
  • Класс: CTaskCommentItem
  • Вызов: CTaskCommentItem::isActionAllowed
public function isActionAllowed($actionId): bool
{
	CTaskAssert::assertLaxIntegers($actionId);
	$actionId = (int)$actionId;

	if (!in_array($actionId, [self::ACTION_COMMENT_ADD, self::ACTION_COMMENT_MODIFY, self::ACTION_COMMENT_REMOVE], true))
	{
		return false;
	}

	if ($actionId === self::ACTION_COMMENT_ADD)
	{
		return true; // you can view the task (if you reached this point, you obviously can)
	}

	try
	{
		$taskData = $this->oTaskItem->getData();
	}
	catch (TasksException $e)
	{
		return false;
	}

	$forumTopicId = $taskData['FORUM_TOPIC_ID'];

	if (!(int)$forumTopicId) // task even doesnt have a forum topic
	{
		return false;
	}

	if ($actionId === self::ACTION_COMMENT_MODIFY)
	{
		return CTaskComments::CanUpdateComment(
			$this->oTaskItem->getId(),
			$this->itemId,
			$this->executiveUserId,
			['FORUM_TOPIC_ID' => $forumTopicId]
		);
	}

	if ($actionId === self::ACTION_COMMENT_REMOVE)
	{
		return CTaskComments::CanRemoveComment(
			$this->oTaskItem->getId(),
			$this->itemId,
			$this->executiveUserId,
			['FORUM_TOPIC_ID' => $forumTopicId]
		);
	}

	return false;
}