36 parent::__construct($userId);
48 if (isset($USER) && $USER instanceof \CUser)
50 $userId = (int)$USER->GetID();
53 return static::getInstance($userId);
69 return $this->checkLegacy($action);
73 if (is_array($params))
75 $params[
'action'] = $action;
78 return parent::check($action, $item, $params);
96 $ruleObject = $this->ruleFactory->createFromAction($action, $this);
97 if (! $ruleObject instanceof
BaseRule)
102 $params = [
'action' => $action];
107 : $ruleObject->getPermissionValue($params)
116 private function checkLegacy(
string $action): bool
118 if (CurrentUser::get()->
isAdmin())
124 $legacyAction =
null;
125 if (array_key_exists($action, $legacyActions))
127 $legacyAction = $action;
131 foreach ($legacyActions as $oldAction => $newActions)
133 if (in_array($action, $newActions,
true))
135 $legacyAction = $oldAction;
142 return $legacyAction && CurrentUser::get()->canDoOperation($legacyAction);
147 return $this->user->isAdmin() || (Loader::includeModule(
"bitrix24") && \CBitrix24::isPortalAdmin($this->user->getUserId()));
170 if (empty($allowStoresIds))
174 $allowStoresIds = array_map(
'intval', $allowStoresIds);
179 $allStoresId = PermissionDictionary::VALUE_VARIATION_ALL;
181 in_array($defaultStoreId, $allowStoresIds,
true)
182 || in_array($allStoresId, $allowStoresIds,
true)
185 return $defaultStoreId;
189 return reset($allowStoresIds);
196 public function hasIblockAccess(
string $action): bool
199 $rule = $this->iblockRuleFactory->createFromAction($action, $this);
205 return $rule->execute();
218 if ($permissionValue ===
null)
223 if (is_array($permissionValue))
225 return in_array(PermissionDictionary::VALUE_VARIATION_ALL, $permissionValue,
true);
228 return $this->
check($action);
static createFromId(int $userId)