UserOptionController::add

  1. Bitrix24 API (v. 23.675.0)
  2. tasks
  3. UserOptionController
  4. add
  • Модуль: tasks
  • Путь к файлу: ~/bitrix/modules/tasks/lib/internals/project/useroption/useroptioncontroller.php
  • Класс: BitrixTasksInternalsProjectUserOptionUserOptionController
  • Вызов: UserOptionController::add
public function add(int $option): Result
{
	$addResult = new Result();

	if (!$this->isOption($option))
	{
		$addResult->addError(0, 'Wrong option.');
		return $addResult;
	}

	$data = [
		'PROJECT_ID' => $this->projectId,
		'USER_ID' => $this->userId,
		'OPTION_CODE' => $option,
	];

	$item = ProjectUserOptionTable::getList([
		'select' => ['ID'],
		'filter' => $data,
	])->fetch();

	if (!$item)
	{
		$tableAddResult = ProjectUserOptionTable::add($data);
		if (!$tableAddResult->isSuccess())
		{
			$addResult->addError(2, 'Adding to table failed.');
			return $addResult;
		}

		$this->onAfterOptionAdded($option);

		return $addResult;
	}

	$addResult->addError(1, 'Option is already exist.');

	return $addResult;
}

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