UserOption::delete

  1. Bitrix24 API (v. 23.675.0)
  2. tasks
  3. UserOption
  4. delete
  • Модуль: tasks
  • Путь к файлу: ~/bitrix/modules/tasks/lib/internals/useroption.php
  • Класс: BitrixTasksInternalsUserOption
  • Вызов: UserOption::delete
static function delete(int $taskId, int $userId, int $option): Result
{
	static::onBeforeOptionChanged($taskId, $userId, $option);

	$deleteResult = new Result();

	if ($taskId <= 0 || $userId <= 0 || !static::isOption($option))
	{
		$deleteResult->addError(0, 'Some parameter is wrong.');
		return $deleteResult;
	}

	$item = UserOptionTable::getList([
		'select' => ['ID'],
		'filter' => [
			'TASK_ID' => $taskId,
			'USER_ID' => $userId,
			'OPTION_CODE' => $option,
		],
	])->fetch();

	if ($item)
	{
		$tableDeleteResult = UserOptionTable::delete($item);
		if (!$tableDeleteResult->isSuccess())
		{
			$deleteResult->addError(1, 'Deleting from table failed.');
			return $deleteResult;
		}
		static::onOptionChanged($taskId, $userId, $option, false);
	}

	return $deleteResult;
}

Добавить комментарий