Stages::update

  1. Bitrix24 API (v. 23.675.0)
  2. tasks
  3. Stages
  4. update
  • Модуль: tasks
  • Путь к файлу: ~/bitrix/modules/tasks/lib/dispatcher/publicaction/task/stages.php
  • Класс: BitrixTasksDispatcherPublicActionTaskStages
  • Вызов: Stages::update
public function update($id, $fields, $isAdmin = false)
{
	$id = (int)$id;
	// check
	if (!($stage = StagesTable::getById($id)->fetch()))
	{
		$this->errors->add(
			'NOT_FOUND',
			Loc::getMessage('STAGES_ERROR_NOT_FOUND')
		);
	}
	// update
	if ($this->errors->checkNoFatals())
	{
		$update = array();
		if (isset($fields['TITLE']))
		{
			$update['TITLE'] = $fields['TITLE'];
		}
		else
		{
			$update['TITLE'] = $stage['TITLE'];
		}
		if (isset($fields['COLOR']))
		{
			$update['COLOR'] = $fields['COLOR'];
		}
		if (isset($fields['AFTER_ID']))
		{
			$update['AFTER_ID'] = $fields['AFTER_ID'];
		}
		if (!empty($update))
		{
			$update['ID'] = $id;
			$update['ENTITY_ID'] = $stage['ENTITY_ID'];
			StagesTable::setWorkMode($stage['ENTITY_TYPE']);
			if ($this->modify($update, $isAdmin))
			{
				return true;
			}
		}
		else
		{
			$this->errors->add(
				'EMPTY_DATA',
				Loc::getMessage('STAGES_ERROR_EMPTY_DATA')
			);
		}
	}

	return null;
}

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