• Модуль: tasks
  • Путь к файлу: ~/bitrix/modules/tasks/classes/general/taskitem.php
  • Класс: CTaskItem
  • Вызов: CTaskItem::stopWatch
public function stopWatch($userId = 0)
{
	// Force reload cache
	$this->markCacheAsDirty();

	try
	{
		$arTask = $this->getData($bEscaped = false);
	}
	catch (TasksException $e)
	{
		static::throwExceptionVerbose();
	}

	if(!($userId = intval($userId)))
	{
		$userId = $this->executiveUserId;
	}

	$key = array_search($userId, $arTask['AUDITORS']);

	// Am I auditor?
	if ($key !== false)
	{
		unset($arTask['AUDITORS'][$key]);
		$arFields = array('AUDITORS' => $arTask['AUDITORS']);
		$this->markCacheAsDirty();
		$o = new CTasks();
		$arParams = array(
			'USER_ID'               => $this->executiveUserId,
			'CHECK_RIGHTS_ON_FILES' => true
		);

		/** @noinspection PhpDeprecationInspection */
		if ($o->update($this->taskId, $arFields, $arParams) !== true)
		{
			static::throwExceptionVerbose($o->GetErrors());
		}
	}
}