1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
accesscontroller.php
См. документацию.
1<?php
8
10
17
19{
20 private const BASE_RULE = 'Base';
21
31 public function check(string $action, AccessibleItem $item = null, $params = null): bool
32 {
33 $ruleName = $this->getRuleName($action);
34
35 if (!$ruleName || !class_exists($ruleName))
36 {
38 }
39
40 $event = $this->sendEvent(EventDictionary::EVENT_ON_BEFORE_CHECK, $action, null, $params);
41 $isAccess = $event->isAccess();
42
43 if (!is_null($isAccess))
44 {
45 return $isAccess;
46 }
47
48 $params['action'] = $action;
49 $isAccess = (new $ruleName($this))->execute(null, $params);
50
51 if($isAccess)
52 {
53 return $isAccess;
54 }
55
56 $event = $this->sendEvent(EventDictionary::EVENT_ON_AFTER_CHECK, $action,null, $params, $isAccess);
57
58 $isAccess = $event->isAccess() ?? $isAccess;
59
60 return $isAccess;
61 }
62
63 public function isAdmin()
64 {
65 return $this->user->isAdmin();
66 }
67
68 protected function getRuleName(string $actionCode): ?string
69 {
70 $actionName = ActionDictionary::getActionName($actionCode);
71 if (!$actionName)
72 {
73 return null;
74 }
75
76 $action = explode('_', $actionName);
77 $action = array_map(
78 function($el)
79 {
80 return ucfirst(mb_strtolower($el));
81 }, $action
82 );
83
84 $ruleClass = $this->getRuleNamespace() .implode($action).self::RULE_SUFFIX;
85
86
87 if(class_exists($ruleClass))
88 {
89 return $ruleClass;
90 }
91
92 return $this->getRuleNamespace().self::BASE_RULE.self::RULE_SUFFIX;
93 }
94
95 protected function loadItem(int $itemId = null): ?AccessibleItem
96 {
97 return null;
98 }
99
100 protected function loadUser(int $userId): AccessibleUser
101 {
103 }
104}
if(!is_object($USER)||! $USER->IsAuthorized()) $userId
Определения check_mail.php:18
sendEvent(string $eventName, string $action, AccessibleItem $item=null, $params=null, bool $isAccess=null)
Определения baseaccesscontroller.php:146
loadItem(int $itemId=null)
Определения accesscontroller.php:95
getRuleName(string $actionCode)
Определения accesscontroller.php:68
check(string $action, AccessibleItem $item=null, $params=null)
Определения accesscontroller.php:31
static getActionName(string $value)
Определения actiondictionary.php:174
$event
Определения prolog_after.php:141
if($inWords) echo htmlspecialcharsbx(Number2Word_Rus(roundEx($totalVatSum $params['CURRENCY']
Определения template.php:799
$action
Определения file_dialog.php:21