Task::updateInlineFiles

  1. Bitrix24 API (v. 23.675.0)
  2. tasks
  3. Task
  4. updateInlineFiles
  • Модуль: tasks
  • Путь к файлу: ~/bitrix/modules/tasks/lib/control/task.php
  • Класс: BitrixTasksControlTask
  • Вызов: Task::updateInlineFiles
private function updateInlineFiles(array $fields, array $relations): array
{
	if (empty($relations))
	{
		return $fields;
	}

	$searchTpl = '[DISK FILE ID=%s]';

	$search = [];
	$replace = [];

	foreach ($relations as $source => $destination)
	{
		$search[] = sprintf($searchTpl, $source);
		$replace[] = sprintf($searchTpl, $destination);

		if (!preg_match('/^'.BitrixDiskUfFileUserType::NEW_FILE_PREFIX.'/', $source))
		{
			$attachedObject = AttachedObject::loadById($source);
			if($attachedObject)
			{
				$search[] = sprintf($searchTpl, BitrixDiskUfFileUserType::NEW_FILE_PREFIX.$attachedObject->getObjectId());
				$replace[] = sprintf($searchTpl, $destination);
			}
		}
	}

	$fields['DESCRIPTION'] = str_replace($search, $replace, $fields['DESCRIPTION']);

	return $fields;
}

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