• Модуль: disk
  • Путь к файлу: ~/bitrix/modules/disk/lib/bizprocdocument.php
  • Класс: BitrixDiskBizProcDocument
  • Вызов: BizProcDocument::canUserOperateDocumentType
static function canUserOperateDocumentType($operation, $userId, $documentType, $parameters = array())
{
	$storageId = self::getStorageIdByType($documentType);
	if(!$storageId)
	{
		throw new CBPArgumentNullException('documentType');
	}
	/** @var Storage $storage */
	$storage = Storage::loadById($storageId, array('ROOT_OBJECT'));
	if(!$storage)
	{
		throw new CBPArgumentNullException('documentType');
	}
	$securityContext = $storage->getSecurityContext($userId);

	if($operation === CBPCanUserOperateOperation::CreateWorkflow)
	{
		return $storage->canCreateWorkflow($securityContext);
	}
	elseif($operation === CBPCanUserOperateOperation::WriteDocument)
	{
		return $storage->getRootObject()->canAdd($securityContext);
	}
	elseif($operation === CBPCanUserOperateOperation::ViewWorkflow || $operation === CBPCanUserOperateOperation::StartWorkflow)
	{
		if($operation === CBPCanUserOperateOperation::ViewWorkflow)
		{
			return $storage->getRootObject()->canRead($securityContext);
		}

		if($operation === CBPCanUserOperateOperation::StartWorkflow)
		{
			return $storage->canCreateWorkflow($securityContext);
		}
	}

	return false;
}