- Модуль: landing
- Путь к файлу: ~/bitrix/modules/landing/lib/restriction/landing.php
- Класс: BitrixLandingRestrictionLanding
- Вызов: Landing::isCreatingAllowed
static function isCreatingAllowed(string $code, array $params): bool
{
if (!BitrixMainLoader::includeModule('bitrix24'))
{
return true;
}
$optPrefix = 'landing_page_';
$optSuffix = ($params['action_type'] == 'publication') ? '_publication' : '';
$variableCode = $optPrefix . strtolower($params['type']) . $optSuffix;
$limit = (int) Feature::getVariable($variableCode);
if ($limit)
{
$filter = [
'CHECK_PERMISSIONS' => 'N',
'=SITE.TYPE' => $params['type'],
'!=SITE.SPECIAL' => 'Y'
];
if ($params['action_type'] == 'publication')
{
$filter['=ACTIVE'] = 'Y';
}
if (
isset($params['filter']) &&
is_array($params['filter'])
)
{
$filter = array_merge(
$filter,
$params['filter']
);
}
$check = BitrixLandingLanding::getList([
'select' => [
'CNT' => new EntityExpressionField('CNT', 'COUNT(*)')
],
'filter' => $filter,
'group' => []
])->fetch();
if ($check && $check['CNT'] >= $limit)
{
return false;
}
}
return true;
}