AnonSec Shell
Server IP : 85.193.89.191  /  Your IP : 3.17.176.169
Web Server : Apache
System : Linux 956367-cx40159.tmweb.ru 3.10.0-1160.105.1.el7.x86_64 #1 SMP Thu Dec 7 15:39:45 UTC 2023 x86_64
User : bitrix ( 600)
PHP Version : 8.1.27
Disable Function : NONE
MySQL : OFF  |  cURL : OFF  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : ON  |  Pkexec : ON
Directory :  /home/bitrix/www/bitrix/modules/sender/lib/security/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ HOME ]     

Current File : /home/bitrix/www/bitrix/modules/sender/lib/security/accesschecker.php
<?php
/**
 * Bitrix Framework
 * @package bitrix
 * @subpackage sender
 * @copyright 2001-2012 Bitrix
 */
namespace Bitrix\Sender\Security;

use Bitrix\Main\Error;
use Bitrix\Main\Localization\Loc;
use Bitrix\Main\ErrorCollection;


Loc::loadMessages(__FILE__);

/**
 * Class AccessChecker
 * @package Bitrix\Sender\Security
 */
class AccessChecker
{
	const ERR_CODE_VIEW = 'ERR_VIEW';
	const ERR_CODE_EDIT = 'ERR_EDIT';
	const ERR_CODE_NOT_FOUND = 'ERR_NOT_FOUND';

	/**
	 * Get message.
	 *
	 * @param string $code Code.
	 * @return string
	 */
	public static function getMessage($code)
	{
		$message = Loc::getMessage('SENDER_SECURITY_ACCESS_CHECKER_'.mb_strtoupper($code));
		return $message ?: 'Unknown error.';
	}

	/**
	 * Get error.
	 *
	 * @param string $code Code.
	 * @return Error
	 */
	public static function getError($code = self::ERR_CODE_VIEW)
	{
		return new Error(self::getMessage($code));
	}

	/**
	 * Add error.
	 *
	 * @param ErrorCollection $collection Error collection.
	 * @param string $code Code.
	 * @return void
	 */
	public static function addError(ErrorCollection $collection, $code = self::ERR_CODE_VIEW)
	{
		$collection->setError(self::getError($code));
	}

	/**
	 * Check view access.
	 *
	 * @param ErrorCollection $collection Error collection.
	 * @param User $user User.
	 * @return bool
	 */
	public static function checkViewAccess(ErrorCollection $collection, User $user = null)
	{
		$user = $user ?: User::current();
		if (!$user->canView())
		{
			$collection->setError(new Error(
				self::getMessage(self::ERR_CODE_VIEW),
				self::ERR_CODE_VIEW
			));
			return false;
		}

		return true;
	}
}

Anon7 - 2022
AnonSec Team