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/lists/lib/security/ |
Upload File : |
<? namespace Bitrix\Lists\Security; use Bitrix\Main\Error; use Bitrix\Main\Errorable; use Bitrix\Main\ErrorCollection; use Bitrix\Main\ErrorableImplementation; class IblockRight implements RightEntity, Errorable { use ErrorableImplementation; const ACCESS_DENIED = "ACCESS_DENIED"; const READ = "canRead"; const EDIT = "canEdit"; private $listsPermission; private $rightParam; public function __construct(RightParam $rightParam) { $this->rightParam = $rightParam; $this->errorCollection = new ErrorCollection; } /** * Sets the access label that is needed to verify the rights of the entity. * * @param string $listsPermission Access label. */ public function setListsPermission($listsPermission) { $this->listsPermission = $listsPermission; } /** * Checks the read access to the iblock. * * @return bool */ public function canRead() { if ( $this->listsPermission < \CListPermissions::CAN_READ && !( \CIBlockRights::userHasRightTo( $this->rightParam->getIblockId(), $this->rightParam->getIblockId(), 'element_read' ) ) ) { $this->errorCollection->setError(new Error('Access denied', self::ACCESS_DENIED)); return false; } return true; } /** * Checks the edit access to the iblock. * * @return bool */ public function canEdit() { if( ( $this->rightParam->getIblockId() && $this->listsPermission < \CListPermissions::IS_ADMIN && !\CIBlockRights::userHasRightTo( $this->rightParam->getIblockId(), $this->rightParam->getIblockId(), "iblock_edit") ) || ( !$this->rightParam->getIblockId() && $this->listsPermission < \CListPermissions::IS_ADMIN ) ) { $this->errorCollection->setError(new Error("Access denied", self::ACCESS_DENIED)); return false; } return true; } }