- Модуль: landing
- Путь к файлу: ~/bitrix/modules/landing/lib/rights.php
- Класс: BitrixLandingRights
- Вызов: Rights::hasAdditionalRight
static function hasAdditionalRight($code, $type = null, bool $checkExtraRights = false, bool $strict = false)
{
static $options = [];
if ($checkExtraRights && self::hasExtraRights())
{
return true;
}
if (!is_string($code))
{
return false;
}
if ($type === null)
{
$type = SiteType::getCurrentScopeId();
}
if ($type !== null)
{
$type = mb_strtolower($type);
//@todo: hotfix for group right
if ($type == SiteType::SCOPE_CODE_GROUP)
{
return true;
}
$code = $type . '_' . $code;
}
if (array_key_exists($code, self::ADDITIONAL_RIGHTS))
{
if (!self::isFeatureOn())
{
return true;
}
if (!self::getContextUserId())
{
return false;
}
if (Manager::isAdmin())
{
if (in_array($code, self::REVERSE_RIGHTS))
{
return false;
}
return true;
}
$accessCodes = [];
if (!isset($options[$code]))
{
$options[$code] = Manager::getOption('access_codes_' . $code, '');
$options[$code] = unserialize($options[$code], ['allowed_classes' => false]);
}
$option = $options[$code];
if (!is_array($option) && !$strict)
{
return true;
}
if (empty($option))
{
return false;
}
if (self::isExtendedMode())
{
if (isset($option[0]) && is_array($option[0]))
{
$accessCodes = $option[0];
}
}
else
{
if (isset($option[0]))
{
unset($option[0]);
}
foreach ($option as $roleAccess)
{
$accessCodes = array_merge($accessCodes, (array)$roleAccess);
}
$accessCodes = array_unique($accessCodes);
}
if ($accessCodes)
{
static $accessCodesStatic = [];
sort($accessCodes);
$accessCodesStr = implode('|', $accessCodes);
if (array_key_exists($accessCodesStr, $accessCodesStatic))
{
return $accessCodesStatic[$accessCodesStr];
}
$res = UserAccessTable::getList([
'select' => [
'USER_ID'
],
'filter' => [
'=ACCESS_CODE' => $accessCodes,
'USER_ID' => self::getContextUserId()
]
]);
$accessCodesStatic[$accessCodesStr] = (boolean)$res->fetch();
return $accessCodesStatic[$accessCodesStr];
}
return false;
}
return false;
}