Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
landing.php
1<?php
3
4use \Bitrix\Bitrix24\Feature;
5use \Bitrix\Main\Entity;
6
7class Landing
8{
15 public static function isCreatingAllowed(string $code, array $params): bool
16 {
17 if (!\Bitrix\Main\Loader::includeModule('bitrix24'))
18 {
19 return true;
20 }
21
22 $optPrefix = 'landing_page_';
23 $optSuffix = ($params['action_type'] == 'publication') ? '_publication' : '';
24 $variableCode = $optPrefix . strtolower($params['type']) . $optSuffix;
25 $limit = (int) Feature::getVariable($variableCode);
26
27 if ($limit)
28 {
29 $filter = [
30 'CHECK_PERMISSIONS' => 'N',
31 '=SITE.TYPE' => $params['type'],
32 '!=SITE.SPECIAL' => 'Y'
33 ];
34 if ($params['action_type'] == 'publication')
35 {
36 $filter['=ACTIVE'] = 'Y';
37 }
38 if (
39 isset($params['filter']) &&
40 is_array($params['filter'])
41 )
42 {
43 $filter = array_merge(
44 $filter,
45 $params['filter']
46 );
47 }
48 $check = \Bitrix\Landing\Landing::getList([
49 'select' => [
50 'CNT' => new Entity\ExpressionField('CNT', 'COUNT(*)')
51 ],
52 'filter' => $filter,
53 'group' => []
54 ])->fetch();
55 if ($check && $check['CNT'] >= $limit)
56 {
57 return false;
58 }
59 }
60
61 return true;
62 }
63}
static isCreatingAllowed(string $code, array $params)
Definition landing.php:15