• Модуль: tasks
  • Путь к файлу: ~/bitrix/modules/tasks/classes/general/taskcomments.php
  • Класс: CTaskComments
  • Вызов: CTaskComments::CheckUpdateRemoveCandidate
static function CheckUpdateRemoveCandidate($taskId, $commentId, $userId, $arParams)
{
	$filter = array('TOPIC_ID' => $arParams['FORUM_TOPIC_ID']);

	// have no idea in which case the following parameters will be used:
	if(isset($arParams['FORUM_ID']))
		$filter['FORUM_ID'] = $arParams['FORUM_ID'];
	if(isset($arParams['APPROVED']))
		$filter['APPROVED'] = $arParams['APPROVED'];

	$res = CForumMessage::GetListEx(
		array('ID' => 'ASC'),
		$filter,
		false,
		0,
		array('bShowAll' => true)
	);

	// Take last message
	$comment = false;
	$lastComment = false;
	$cnt = 0;
	while ($ar = $res->fetch())
	{
		if($ar['ID'] == $commentId)
			$comment = $ar;

		$lastComment = $ar;
		$cnt++;
	}

	if ( $cnt == 0 ) // no comments in the topic
		return (false);

	if ( empty($comment) ) // comment not found
		return (false);

	if (
		CTasksTools::isAdmin($userId)
		|| CTasksTools::IsPortalB24Admin($userId)
	)
	{
		return (true);
	}
	elseif ($userId == $lastComment['AUTHOR_ID'])
	{
		if ($commentId != $lastComment['ID'])	// it's not the last comment
			return (false);
		else
			return (true);
	}
	else
		return (false);
}