2namespace Bitrix\Landing\Restriction;
4use Bitrix\Bitrix24\Feature;
5use Bitrix\Bitrix24\PhoneVerify;
6use Bitrix\Landing\Manager;
7use Bitrix\Main\Config\Option;
9use Bitrix\Landing\Domain;
10use Bitrix\Landing\Rights;
11use Bitrix\Landing\Site as SiteCore;
12use Bitrix\Main\Loader;
13use Bitrix\Main\Type\DateTime;
25 private const LIMIT_BY_TEMPLATES_MINIMAL = [
32 private const OVER_LIMIT_TEMPLATES = [
39 private const NEW_STORE_CODE =
'store_v3';
47 private static function checkLimitByTemplates(
array $filter,
int $limit): bool
50 $currentSiteId =
null;
51 $currentSiteTemplate =
null;
55 $currentSiteId =
$filter[
'!ID'];
59 $res = SiteCore::getList([
61 'ID',
'XML_ID',
'TPL_CODE'
65 while ($row =
$res->fetch())
73 $res = SiteCore::getList([
75 'ID',
'XML_ID',
'TPL_CODE'
78 'CHECK_PERMISSIONS' =>
'N',
79 'ID' => $currentSiteId
82 if ($row =
$res->fetch())
91 $templatesLimits = self::LIMIT_BY_TEMPLATES_MINIMAL;
93 $limit = max($limit, 1);
96 if (!$row[
'TPL_CODE'])
98 if (mb_strpos($row[
'XML_ID'],
'|') !==
false)
100 [, $row[
'TPL_CODE']] = explode(
'|', $row[
'XML_ID']);
105 foreach ($templatesLimits as
$code => $cnt)
107 if (strpos($row[
'TPL_CODE'],
$code) === 0)
109 $row[
'TPL_CODE'] =
$code;
114 if ($currentSiteId && $currentSiteId === $row[
'ID'])
116 $currentSiteTemplate = $row[
'TPL_CODE'];
119 if (!($templates[$row[
'TPL_CODE']] ??
null))
121 $templates[$row[
'TPL_CODE']] = 0;
123 $templates[$row[
'TPL_CODE']]++;
125 if (!in_array($row[
'TPL_CODE'], self::OVER_LIMIT_TEMPLATES,
true))
134 && $currentSiteTemplate === self::NEW_STORE_CODE
135 && self::isNew2021Tariff()
138 \CBitrixComponent::includeComponentClass(
'bitrix:landing.site_master');
139 $optionName = \LandingSiteMasterComponent::getShopInstallCountOptionName($currentSiteTemplate);
149 && in_array($row[
'TPL_CODE'], self::OVER_LIMIT_TEMPLATES,
true)
157 foreach ($templatesLimits as
$code => $templateLimit)
160 isset($templates[
$code])
161 && $templates[
$code] > $templateLimit
169 if ($limit < $templatesCount)
179 if (!Loader::includeModule(
'bitrix24'))
185 \CBitrix24::getLicenseType(),
186 [
'basic',
'std',
'pro']
198 if (!Loader::includeModule(
'bitrix24'))
204 $params[
'action_type'] ===
'publication'
209 if (!isset(
$params[
'filter'][
'!ID']))
215 $site = SiteCore::getList([
216 'select' => [
'ID' ,
'DATE_CREATE'],
219 $dateWhenClosedFree = DateTime::createFromTimestamp(
'1646238000');
220 if (
$site[
'DATE_CREATE']->getTimestamp() >= $dateWhenClosedFree->getTimestamp())
226 $optPrefix =
'landing_site_';
227 $optSuffix = (
$params[
'action_type'] ==
'publication') ?
'_publication' :
'';
228 $variableCode = $optPrefix . strtolower(
$params[
'type']) . $optSuffix;
229 $limit = (int) Feature::getVariable($variableCode);
234 'CHECK_PERMISSIONS' =>
'N',
239 if (
$params[
'action_type'] ==
'publication')
255 if (
$params[
'action_type'] ===
'publication' &&
$params[
'type'] ===
'STORE')
257 return self::checkLimitByTemplates(
$filter, $limit);
260 $check = SiteCore::getList([
267 if ($check && $check[
'CNT'] >= $limit)
285 if (!Loader::includeModule(
'bitrix24'))
290 $availableCount = Feature::getVariable(
291 'landing_free_domain'
293 if ($availableCount ===
null)
297 if ((
$params[
'trueOnNotNull'] ??
false))
301 if ($availableCount > 0)
303 $check = Domain::getList([
312 if ($check && $check[
'CNT'] >= $availableCount)
328 $methodName = __CLASS__ .
'::' . __FUNCTION__ .
'(' . ($setActive ?
'true' :
'false') .
');';
330 if ($executeAfterSeconds > 0)
335 'landing',
'N', 0,
'',
'Y',
336 $dateTime->add(
'+' . $executeAfterSeconds .
' seconds')
342 \CAgent::removeAgent($methodName,
'landing');
346 $res = SiteCore::getList([
353 '=DOMAIN.ACTIVE' => $setActive ?
'N' :
'Y',
354 '!DOMAIN.PROVIDER' =>
null
359 if (
$site[
'ACTIVE'] === ($setActive ?
'N' :
'Y'))
361 SiteCore::update(
$site[
'ID'], [
362 'ACTIVE' => $setActive ?
'Y' :
'N'
365 Domain::update(
$site[
'DOMAIN_ID'], [
366 'ACTIVE' => $setActive ?
'Y' :
'N'
382 $tariffTtl = $resetFreeTime + self::FREE_DOMAIN_GRACE_DAYS * 86400;
394 if (Loader::includeModule(
'bitrix24'))
396 return Feature::isFeatureEnabled(
'landing_allow_export');
408 if (Loader::includeModule(
'bitrix24'))
410 return !Feature::isFeatureEnabled(
'landing_hide_terms_footer');
423 static $checkedSites = [];
425 if (array_key_exists(
$siteId, $checkedSites))
432 if (Loader::includeModule(
'bitrix24'))
434 if (!\CBitrix24::isEmailConfirmed())
436 $checkedSites[
$siteId] =
false;
450 static $checkedSites = [];
452 if (array_key_exists(
$siteId, $checkedSites))
459 if (Loader::includeModule(
'bitrix24'))
461 $checkedSites[
$siteId] = (
new PhoneVerify(
'landing_site',
$siteId))->isVerified();
470 $sites = SiteCore::getList([
486 if (
$res->isSuccess())
488 $ids[] =
$site[
'ID'];
491 $stringIds = implode(
',', $ids);
492 Option::set(
'landing',
'unpublished_ids', $stringIds);
500 \Bitrix\Main\Update\Stepper::bindClass(
'Bitrix\Landing\Update\Site\Publish',
'landing', 10);
506 $sites = SiteCore::getList([
515 'DATE_CREATE' =>
'DESC'
522 '!ID' =>
$site[
'ID'],
525 'action_type' =>
'publication',
527 if (!self::isCreatingAllowed(
'limit_sites_number',
$params))
529 SiteCore::unpublic(
$site[
'ID']);
static getOption($code, $default=null)
static isFreePublicAllowed()
static licenseIsFreeSite(string $type)
static isCreatingAllowed(string $code, array $params)
static publishByLicenseChange()
static isTermsFooterShow()
static isEmailConfirmed(int $siteId)
static getFreeDomainSuspendedTime()
static unpublishByScannerLockPortal()
const FREE_DOMAIN_GRACE_DAYS
static manageFreeDomains(bool $setActive, int $executeAfterSeconds=0)
static checkLimitsByLicenseChange()
static isFreeDomainAllowed(string $code, array $params)
static isPhoneConfirmed(int $siteId)
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
if(!is_null($config))($config as $configItem)(! $configItem->isVisible()) $code
if($inWords) echo htmlspecialcharsbx(Number2Word_Rus(roundEx($totalVatSum $params['CURRENCY']