24 private const LIMIT_BY_TEMPLATES_MINIMAL = [
31 private const OVER_LIMIT_TEMPLATES = [
38 private const NEW_STORE_CODE =
'store_v3';
46 private static function checkLimitByTemplates(array $filter,
int $limit): bool
49 $currentSiteId =
null;
50 $currentSiteTemplate =
null;
52 if (isset($filter[
'!ID']))
54 $currentSiteId = $filter[
'!ID'];
58 $res = \Bitrix\Landing\Site::getList([
60 'ID',
'XML_ID',
'TPL_CODE'
64 while ($row = $res->fetch())
72 $res = \Bitrix\Landing\Site::getList([
74 'ID',
'XML_ID',
'TPL_CODE'
77 'CHECK_PERMISSIONS' =>
'N',
78 'ID' => $currentSiteId
81 if ($row = $res->fetch())
90 $templatesLimits = self::LIMIT_BY_TEMPLATES_MINIMAL;
92 $limit = max($limit, 1);
93 foreach ($sites as $row)
95 if (!$row[
'TPL_CODE'])
97 if (mb_strpos($row[
'XML_ID'],
'|') !==
false)
99 [, $row[
'TPL_CODE']] = explode(
'|', $row[
'XML_ID']);
104 foreach ($templatesLimits as $code => $cnt)
106 if (strpos($row[
'TPL_CODE'], $code) === 0)
108 $row[
'TPL_CODE'] = $code;
113 if ($currentSiteId && $currentSiteId === $row[
'ID'])
115 $currentSiteTemplate = $row[
'TPL_CODE'];
118 if (!($templates[$row[
'TPL_CODE']] ??
null))
120 $templates[$row[
'TPL_CODE']] = 0;
122 $templates[$row[
'TPL_CODE']]++;
124 if (!in_array($row[
'TPL_CODE'], self::OVER_LIMIT_TEMPLATES,
true))
133 && $currentSiteTemplate === self::NEW_STORE_CODE
134 && self::isNew2021Tariff()
137 \CBitrixComponent::includeComponentClass(
'bitrix:landing.site_master');
138 $optionName = \LandingSiteMasterComponent::getShopInstallCountOptionName($currentSiteTemplate);
148 && in_array($row[
'TPL_CODE'], self::OVER_LIMIT_TEMPLATES,
true)
156 foreach ($templatesLimits as $code => $templateLimit)
159 isset($templates[$code])
160 && $templates[$code] > $templateLimit
168 if ($limit < $templatesCount)
178 if (!Loader::includeModule(
'bitrix24'))
184 \CBitrix24::getLicenseType(),
185 [
'basic',
'std',
'pro']
197 if (!Loader::includeModule(
'bitrix24'))
203 $params[
'action_type'] ===
'publication'
208 if (!isset($params[
'filter'][
'!ID']))
213 $siteId = $params[
'filter'][
'!ID'];
214 $site = SiteCore::getList([
215 'select' => [
'ID' ,
'DATE_CREATE'],
216 'filter' => [
'ID' => $siteId],
219 if ($site[
'DATE_CREATE']->getTimestamp() >= $dateWhenClosedFree->getTimestamp())
225 $optPrefix =
'landing_site_';
226 $optSuffix = ($params[
'action_type'] ==
'publication') ?
'_publication' :
'';
227 $variableCode = $optPrefix . strtolower($params[
'type']) . $optSuffix;
228 $limit = (int) Feature::getVariable($variableCode);
233 'CHECK_PERMISSIONS' =>
'N',
234 '=TYPE' => $params[
'type'],
238 if ($params[
'action_type'] ==
'publication')
240 $filter[
'=ACTIVE'] =
'Y';
244 isset($params[
'filter']) &&
245 is_array($params[
'filter'])
248 $filter = array_merge(
254 if ($params[
'action_type'] ===
'publication' && $params[
'type'] ===
'STORE')
256 return self::checkLimitByTemplates($filter, $limit);
259 $check = SiteCore::getList([
266 if ($check && $check[
'CNT'] >= $limit)
284 if (!Loader::includeModule(
'bitrix24'))
289 $availableCount = Feature::getVariable(
290 'landing_free_domain'
292 if ($availableCount ===
null)
296 if (($params[
'trueOnNotNull'] ??
false))
300 if ($availableCount > 0)
302 $check = Domain::getList([
311 if ($check && $check[
'CNT'] >= $availableCount)
327 $methodName = __CLASS__ .
'::' . __FUNCTION__ .
'(' . ($setActive ?
'true' :
'false') .
');';
329 if ($executeAfterSeconds > 0)
334 'landing',
'N', 0,
'',
'Y',
335 $dateTime->add(
'+' . $executeAfterSeconds .
' seconds')
341 \CAgent::removeAgent($methodName,
'landing');
345 $res = SiteCore::getList([
352 '=DOMAIN.ACTIVE' => $setActive ?
'N' :
'Y',
353 '!DOMAIN.PROVIDER' => null
356 while ($site = $res->fetch())
358 if ($site[
'ACTIVE'] === ($setActive ?
'N' :
'Y'))
360 SiteCore::update($site[
'ID'], [
361 'ACTIVE' => $setActive ?
'Y' :
'N'
364 Domain::update($site[
'DOMAIN_ID'], [
365 'ACTIVE' => $setActive ?
'Y' :
'N'
381 $tariffTtl = $resetFreeTime + self::FREE_DOMAIN_GRACE_DAYS * 86400;
393 if (Loader::includeModule(
'bitrix24'))
395 return Feature::isFeatureEnabled(
'landing_allow_export');
407 if (Loader::includeModule(
'bitrix24'))
409 return !Feature::isFeatureEnabled(
'landing_hide_terms_footer');
422 static $checkedSites = [];
424 if (array_key_exists($siteId, $checkedSites))
426 return $checkedSites[$siteId];
429 $checkedSites[$siteId] =
true;
431 if (Loader::includeModule(
'bitrix24'))
433 if (!\CBitrix24::isEmailConfirmed())
435 $checkedSites[$siteId] =
false;
439 return $checkedSites[$siteId];
449 static $checkedSites = [];
451 if (array_key_exists($siteId, $checkedSites))
453 return $checkedSites[$siteId];
456 $checkedSites[$siteId] =
true;
458 if (Loader::includeModule(
'bitrix24'))
460 $checkedSites[$siteId] = (
new PhoneVerify(
'landing_site', $siteId))->isVerified();
463 return $checkedSites[$siteId];
static createFromTimestamp($timestamp)