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/rospirotorg.ru/bitrix/modules/sale/lib/

Upload File :
current_dir [ Writeable] document_root [ Writeable]

 

Command :


[ Back ]     

Current File : /home/bitrix/ext_www/rospirotorg.ru/bitrix/modules/sale/lib/propertyvalue.php
<?php

namespace Bitrix\Sale;

use Bitrix\Sale\Internals\Entity;
use Bitrix\Main;

/**
 * Class PropertyValue
 * @package Bitrix\Sale
 */
class PropertyValue extends PropertyValueBase
{
	/**
	 * @param Entity $order
	 * @return array
	 * @throws Main\ObjectNotFoundException
	 */
	protected static function extractPaySystemIdList(Entity $order)
	{
		if (!$order instanceof Order)
		{
			return [];
		}

		return $order->getPaySystemIdList();
	}

	/**
	 * @param Entity $order
	 * @return array
	 * @throws Main\ArgumentException
	 * @throws Main\ArgumentNullException
	 */
	protected static function extractDeliveryIdList(Entity $order)
	{
		if (!$order instanceof Order)
		{
			return [];
		}

		return $order->getDeliveryIdList();
	}

	protected static function extractTpLandingIdList(Entity $order) : array
	{
		if (!$order instanceof Order)
		{
			return [];
		}

		return $order->getTradeBindingCollection()->getTradingPlatformIdList();
	}

	protected static function extractTradingPlatformIdList(Entity $order): array
	{
		if (!$order instanceof Order)
		{
			return [];
		}

		return $order->getTradeBindingCollection()->getTradingPlatformIdList();
	}

	/**
	 * @return Result
	 * @throws Main\ArgumentException
	 * @throws Main\ArgumentOutOfRangeException
	 * @throws Main\NotImplementedException
	 * @throws Main\ObjectNotFoundException
	 */
	protected function update()
	{
		/** @var PropertyValueCollection $propertyCollection */
		$propertyCollection = $this->getCollection();

		/** @var OrderBase $order */
		if (!$order = $propertyCollection->getOrder())
		{
			throw new Main\ObjectNotFoundException('Entity "Order" not found');
		}

		$logFields = [];
		if ($order->getId() > 0)
		{
			$logFields = $this->getLogFieldsForUpdate();
		}

		$result = parent::update();
		if ($result->isSuccess())
		{
			if ($order->getId() > 0)
			{
				$this->addToLog('PROPERTY_UPDATE', $logFields);
			}
		}

		return $result;
	}

	/**
	 * @return array
	 */
	private function getLogFieldsForUpdate()
	{
		$logFields = [
			"NAME" => $this->getField("NAME"),
			"VALUE" => $this->getField("VALUE"),
			"CODE" => $this->getField("CODE"),
		];

		$fields = $this->getFields();
		$originalValues = $fields->getOriginalValues();
		if (array_key_exists("NAME", $originalValues))
			$logFields['OLD_NAME'] = $originalValues["NAME"];

		if (array_key_exists("VALUE", $originalValues))
			$logFields['OLD_VALUE'] = $originalValues["VALUE"];

		if (array_key_exists("CODE", $originalValues))
			$logFields['OLD_CODE'] = $originalValues["CODE"];

		return $logFields;
	}

	/**
	 * @return array
	 */
	private function getLogFieldsForAdd()
	{
		$logFields = [
			"NAME" => $this->getField("NAME"),
			"VALUE" => $this->getField("VALUE"),
			"CODE" => $this->getField("CODE"),
		];

		return $logFields;
	}

	/**
	 * @param $type
	 * @param $fields
	 * @throws Main\ArgumentException
	 * @throws Main\ObjectNotFoundException
	 */
	private function addToLog($type, $fields)
	{
		/** @var PropertyValueCollection $propertyCollection */
		$propertyCollection = $this->getCollection();

		/** @var OrderBase $order */
		if (!$order = $propertyCollection->getOrder())
		{
			throw new Main\ObjectNotFoundException('Entity "Order" not found');
		}

		$registry = Registry::getInstance(static::getRegistryType());

		/** @var OrderHistory $orderHistory */
		$orderHistory = $registry->getOrderHistoryClassName();
		$orderHistory::addLog(
			'PROPERTY',
			$order->getId(),
			$type,
			$this->getId(),
			$this,
			$fields,
			$orderHistory::SALE_ORDER_HISTORY_LOG_LEVEL_1
		);
	}

	/**
	 * @return Result
	 * @throws Main\ObjectNotFoundException
	 * @throws Main\ArgumentException
	 * @throws Main\ArgumentOutOfRangeException
	 * @throws Main\NotImplementedException
	 * @throws Main\ObjectNotFoundException
	 */
	protected function add()
	{
		/** @var PropertyValueCollection $propertyCollection */
		$propertyCollection = $this->getCollection();

		/** @var OrderBase $order */
		if (!$order = $propertyCollection->getOrder())
		{
			throw new Main\ObjectNotFoundException('Entity "Order" not found');
		}

		$logFields = [];
		if ($order->getId() > 0)
		{
			$logFields = $this->getLogFieldsForAdd();
		}

		$result = parent::add();
		if ($result->isSuccess())
		{
			if ($order->getId() > 0)
			{
				$this->addToLog('PROPERTY_ADD', $logFields);
			}
		}

		return $result;
	}
}

Youez - 2016 - github.com/yon3zu
LinuXploit