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/cvetdv.ru/bitrix/modules/catalog/lib/store/enablewizard/

Upload File :
current_dir [ Writeable] document_root [ Writeable]

 

Command :


[ Back ]     

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

namespace Bitrix\Catalog\Store\EnableWizard;

use Bitrix\Catalog\Access\AccessController;
use Bitrix\Catalog\Access\ActionDictionary;
use Bitrix\Catalog\Config\State;
use Bitrix\Catalog\v2\Integration\Landing\ShopManager;
use Bitrix\Crm\Integration\Sale\Reservation\Config\EntityFactory;
use Bitrix\Main\Error;
use Bitrix\Main\Localization\Loc;
use Bitrix\Main\Result;
use Bitrix\Crm\Integration\Sale\Reservation\Config\Entity\Deal;

class OnecEnabler extends Enabler
{
	public static function enable(array $options = []): Result
	{
		$result = new Result();

		if (!AccessController::getCurrent()->check(ActionDictionary::ACTION_PRODUCT_EDIT))
		{
			$result->addError(
				new Error(
					Loc::getMessage('ONEC_ENABLER_PRODUCT_DEACTIVATION_INSUFFICIENT_RIGHTS'),
					0,
					[
						'analyticsCode' => '1c_no_access_product_edit',
					],
				)
			);

			return $result;
		}

		$result = parent::enable($options);
		if (!$result->isSuccess())
		{
			return $result;
		}

		ProductDisabler::disable();
		(new ShopManager())->unpublishShops();
		State::setIsExternalCatalog(true);
		self::setDealReservationAutoMode();

		return $result;
	}

	public static function disable(): Result
	{
		$r = parent::disable();
		if (!$r->isSuccess())
		{
			return $r;
		}

		State::setIsExternalCatalog(false);

		return $r;
	}

	private static function setDealReservationAutoMode(): void
	{
		$dealConfig = EntityFactory::make(Deal::CODE);

		$values = $dealConfig->getValues();
		if ($values[Deal::RESERVATION_MODE_CODE] !== Deal::RESERVATION_MODE_OPTION_ON_ADD_TO_DOCUMENT)
		{
			$values[Deal::RESERVATION_MODE_CODE] = Deal::RESERVATION_MODE_OPTION_ON_ADD_TO_DOCUMENT;
			$dealConfig->setValues($values);
			$dealConfig->save();
		}
	}
}

Youez - 2016 - github.com/yon3zu
LinuXploit