Document::conductListAction

  1. Bitrix24 API (v. 23.675.0)
  2. catalog
  3. Document
  4. conductListAction
  • Модуль: catalog
  • Путь к файлу: ~/bitrix/modules/catalog/lib/controller/document.php
  • Класс: BitrixCatalogControllerDocument
  • Вызов: Document::conductListAction
public function conductListAction(array $documentIds): ?bool
{
	if (!Feature::isInventoryManagementEnabled())
	{
		$this->addError(new Error(Loc::getMessage('DOCUMENT_CONTROLLER_NO_INVENTORY_MANAGEMENT_ENABLED_ERROR')));

		return null;
	}

	if (!BitrixCatalogComponentUseStore::isUsed())
	{
		$this->addError(new Error(Loc::getMessage('DOCUMENT_CONTROLLER_MANAGEMENT_NOT_ENABLED')));

		return null;
	}

	global $APPLICATION;

	$documentData = $this->getDocumentData($documentIds);

	$userId = CurrentUser::get()->getId();
	foreach ($documentIds as $documentId)
	{
		$document = $documentData[$documentId] ?? null;
		if (!$document)
		{
			$this->addError(
				new Error(Loc::getMessage(
					'CATALOG_CONTROLLER_DOCUMENT_CONDUCT_GENERAL_ERROR',
					[
						'#ERROR#' => Loc::getMessage('CATALOG_CONTROLLER_DOCUMENT_NOT_FOUND'),
					]
				))
			);
			continue;
		}

		$documentTitle = $document['TITLE'] ?: StoreDocumentTable::getTypeList(true)[$document['DOC_TYPE']];

		$can = $this->accessController->check(
			ActionDictionary::ACTION_STORE_DOCUMENT_CONDUCT,
			StoreDocument::createFromArray($document)
		);
		if (!$can)
		{
			$this->addError(
				new Error(Loc::getMessage('CATALOG_CONTROLLER_DOCUMENT_CONDUCT_ERROR',
					[
						'#DOC_TITLE#' => htmlspecialcharsbx($documentTitle),
						'#ERROR#' => Loc::getMessage('DOCUMENT_CONTROLLER_NO_RIGHTS_ERROR'),
					]
				))
			);
			continue;
		}

		$isConducted = CCatalogDocs::conductDocument($documentId, $userId);
		if (!$isConducted)
		{
			if ($APPLICATION->GetException())
			{
				$this->addError(
					new Error(Loc::getMessage(
						'DOCUMENT_CONTROLLER_CONDUCT_ERROR',
						[
							'#DOC_TITLE#' => htmlspecialcharsbx($documentTitle),
							'#ERROR#' => htmlspecialcharsbx($APPLICATION->GetException()->GetString()),
						]
					))
				);
				$APPLICATION->ResetException();
			}
			else
			{
				$this->addError(
					new Error(Loc::getMessage('CATALOG_CONTROLLER_DOCUMENT_CONDUCT_GENERAL_ERROR',
						[
							'#DOC_TITLE#' => htmlspecialcharsbx($documentTitle),
						]
					))
				);
			}
		}
	}

	if (!$this->errorCollection->isEmpty())
	{
		return null;
	}

	return true;
}

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