CheckList::update

  1. Bitrix24 API (v. 23.675.0)
  2. tasks
  3. CheckList
  4. update
  • Модуль: tasks
  • Путь к файлу: ~/bitrix/modules/tasks/lib/manager/task/checklist.php
  • Класс: Bitrix\Tasks\Manager\Task\CheckList
  • Вызов: CheckList::update
static function update($userId, $itemId, array $data, array $parameters = array('PUBLIC_MODE' => false))
{
	$errors = static::ensureHaveErrorCollection($parameters);

	if ($parameters['PUBLIC_MODE'])
	{
		$data = static::filterData($data, \CTaskCheckListItem::getPublicFieldMap(), $errors);
	}

	$item = null;
	$task = null;
	$display = null;

	if ($errors->checkNoFatals())
	{
		$taskId = 0;

		if (array_key_exists('TASK_ID', $parameters))
		{
			$taskId = intval($parameters['TASK_ID']);
		}

		if (!$taskId)
		{
			$taskId = \CTaskCheckListItem::getTaskIdByItemId($itemId);
		}

		if ($taskId)
		{
			$task = static::getTask($userId, $taskId);
			$item = new \CTaskCheckListItem($task, $itemId);

			try
			{
				$item->update($data);
			}
			catch (\TasksException $e)
			{
				$originMessage = $e->getMessageOrigin();
				$message = Loc::getMessage('TASKS_MANAGER_TASK_CHECKLIST_ITEMS').': '.$originMessage->messages[0]['text'];
				$errors->add($e->getCode(), $message);
			}
		}
		else
		{
			$errors->add('GETTING_TASK_ID_ERROR', Loc::getMessage('TASKS_MANAGER_TASK_CHECKLIST_GETTING_TASK_ID_ERROR'));
		}
	}

	if(is_a($item, "CTaskCheckListItem") && method_exists($item, 'getTitle'))
	{
		$display = htmlspecialcharsback($item->getTitle());
//			$display = UI::sanitizeString($display, array('a' => array('href'), 'img' => array('src')));
		$display = UI::convertBBCodeToHtml($display, array('PRESET' => 'BASIC'));
	}
	
	return array(
		'DATA' => array(
			'ID' => $itemId,
			'DISPLAY' => $display,
			'TITLE' => strip_tags($display)
		),
		'ERRORS' => $errors,
	);
}

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