4use \Bitrix\Main\Localization\Loc;
5use \Bitrix\Main\Entity;
6use \Bitrix\Landing\Landing;
7use \Bitrix\Landing\Manager;
8use \Bitrix\Landing\Rights;
9use \Bitrix\Landing\Role;
10use \Bitrix\Landing\TemplateRef;
11use \Bitrix\Landing\Landing\Cache;
67 'autocomplete' =>
true,
74 'title' =>
Loc::getMessage(
'LANDING_TABLE_FIELD_LANDING_INITIATOR_APP_CODE')
81 'default_value' =>
'Y'
85 'default_value' =>
'N'
89 'default_value' =>
'Y'
93 'default_value' =>
'N'
102 'save_data_modification' => array(
'\Bitrix\Main\Text\Emoji',
'getSaveModificator'),
103 'fetch_data_modification' => array(
'\Bitrix\Main\Text\Emoji',
'getFetchModificator'),
121 'SITE' =>
new Entity\ReferenceField(
123 'Bitrix\Landing\Internals\SiteTable',
124 array(
'=this.SITE_ID' =>
'ref.ID')
126 'AREAS' =>
new Entity\ReferenceField(
128 'Bitrix\Landing\Internals\TemplateRefTable',
129 array(
'=this.ID' =>
'ref.LANDING_ID')
133 'default_value' =>
'N'
137 'default_value' =>
'N'
147 'default_value' => 10
150 'title' =>
'History step',
157 'CREATED_BY' =>
new Entity\ReferenceField(
159 'Bitrix\Main\UserTable',
160 array(
'=this.CREATED_BY_ID' =>
'ref.ID')
166 'MODIFIED_BY' =>
new Entity\ReferenceField(
168 'Bitrix\Main\UserTable',
169 array(
'=this.MODIFIED_BY_ID' =>
'ref.ID')
193 isset($params[
'filter'][
'CHECK_PERMISSIONS']) &&
194 $params[
'filter'][
'CHECK_PERMISSIONS'] ==
'N'
203 $allowedSites ? [
'SITE_ID' => $allowedSites] : []
205 if (empty($buildFilter))
212 !isset($params[
'filter']) ||
213 !is_array($params[
'filter'])
216 $params[
'filter'] = [];
219 !isset($params[
'runtime']) ||
220 !is_array($params[
'runtime'])
223 $params[
'runtime'] = [];
226 !isset($params[
'group']) ||
227 !is_array($params[
'group'])
230 $params[
'group'] = [];
236 static $expectedRoles =
null;
237 if ($expectedRoles ===
null)
246 '=this.SITE_ID' =>
'ref.ENTITY_ID',
247 '=ref.ENTITY_ID' => [0]
251 $runtimeParams[
'=ref.ROLE_ID'] = [0];
256 $runtimeParams[
'@ref.ROLE_ID'] = [implode(
',', $expectedRoles)];
258 $params[
'runtime'][] =
new Entity\ReferenceField(
260 'Bitrix\Landing\Internals\RightsTable',
262 [
'join_type' =>
'INNER']
265 $params[
'group'][] =
'SITE_ID';
268 $params[
'filter'][] = $buildFilter;
281 $result =
new Entity\EventResult();
282 $primary = $event->getParameter(
'primary');
283 $fields = $event->getParameter(
'fields');
284 $modifyFields = array();
285 $existFields = array();
294 'SITE_ID',
'FOLDER_ID',
295 'INITIATOR_APP_CODE',
296 'ID_INDEX' =>
'SITE.LANDING_ID_INDEX'
299 'ID' => $primary[
'ID'],
300 '=DELETED' => [
'Y',
'N']
303 $existFields = $res->fetch();
308 if (($fields[
'FOLDER_ID'] ??
null) && ($fields[
'FOLDER_SKIP_CHECK'] ??
'N') !==
'Y')
310 if (empty($existFields[
'SITE_ID']))
312 $existFields[
'SITE_ID'] = $fields[
'SITE_ID'];
314 $res = FolderTable::getList([
319 'SITE_ID' => $existFields[
'SITE_ID'],
320 'ID' => $fields[
'FOLDER_ID']
325 $result->setErrors(array(
337 isset($fields[
'CODE']) &&
339 !isset($existFields[
'CODE']) ||
340 $existFields[
'CODE'] != $fields[
'CODE']
344 if (preg_match(
'#^([\w]+)\_([\d]+)\_([\d]+)$#', $fields[
'CODE'], $matches))
346 $result->setErrors(array(
357 if (isset($fields[
'INITIATOR_APP_CODE']))
359 $existFields[
'INITIATOR_APP_CODE'] = $fields[
'INITIATOR_APP_CODE'];
363 if (isset($fields[
'DELETED']))
366 $modifyFields[
'ACTIVE'] =
'N';
367 $fields[
'ACTIVE'] =
'N';
369 if ($fields[
'DELETED'] ==
'Y' && $primary)
371 if ($existFields[
'ID_INDEX'] == $primary[
'ID'])
379 'SITE_ID' => $existFields[
'SITE_ID'],
384 if (count($sitesCheck) > 1)
399 if (array_key_exists(
'SITE_ID', $fields))
401 $res = \Bitrix\Landing\Site::getList(array(
406 'ID' => $fields[
'SITE_ID']
411 $result->setErrors(array(
420 else if ($existFields)
422 if ($existFields[
'SITE_ID'])
424 $fields[
'SITE_ID'] = $existFields[
'SITE_ID'];
428 $result->setErrors(array(
439 $fields[
'SITE_ID'] = 0;
458 'LANDING_TABLE_ERROR_LD_ACCESS_DENIED_ADD'
460 $result->setErrors(array(
471 $freeAccessFields = [
481 $freeAccessFields = $fields;
483 'ACTIVE',
'DATE_PUBLIC',
'DELETED'
485 foreach ($higherAccess as $key)
487 if (isset($freeAccessFields[$key]))
489 unset($freeAccessFields[$key]);
492 $freeAccessFields = array_keys($freeAccessFields);
496 $freeAccessFields[] =
'ACTIVE';
497 $freeAccessFields[] =
'DATE_PUBLIC';
501 $freeAccessFields[] =
'DELETED';
505 $freeAccessFields[] =
'ACTIVE';
508 foreach ($fields as $key => $val)
510 if (!in_array($key, $freeAccessFields))
513 'LANDING_TABLE_ERROR_LD_ACCESS_DENIED_' . $key
518 'LANDING_TABLE_ERROR_LD_ACCESS_DENIED'
521 $result->setErrors(array(
534 if (array_key_exists(
'ADDITIONAL_FIELDS', $fields))
536 self::$additionalFields = $fields[
'ADDITIONAL_FIELDS'];
537 $result->unsetFields(array(
'ADDITIONAL_FIELDS'));
541 self::$additionalFields = array();
546 array_key_exists(
'CODE', $fields) &&
547 mb_strpos($fields[
'CODE'],
'/') !==
false
550 $result->setErrors(array(
553 'SLASH_IS_NOT_ALLOWED'
560 array_key_exists(
'CODE', $fields) &&
561 $fields[
'CODE'] ==
'' &&
562 !isset($fields[
'FOLDER'])
565 $result->setErrors(array(
574 $actionType == self::ACTION_TYPE_ADD && array_key_exists(
'TITLE', $fields) &&
575 (!array_key_exists(
'CODE', $fields) || trim($fields[
'CODE']) ==
'')
578 $fields[
'CODE'] = \CUtil::translit(
579 trim($fields[
'TITLE']),
582 'replace_space' =>
'',
583 'replace_other' =>
''
585 if (!$fields[
'CODE'])
587 $fields[
'CODE'] = randString(12);
589 $modifyFields[
'CODE'] = $fields[
'CODE'];
592 $result->modifyFields($modifyFields);
602 public static function getList(array $params = array())
607 !isset($params[
'filter']) ||
608 !is_array($params[
'filter'])
611 $params[
'filter'] = array();
614 !isset($params[
'filter'][
'DELETED']) &&
615 !isset($params[
'filter'][
'=DELETED'])
618 $params[
'filter'][
'=DELETED'] =
'N';
621 !isset($params[
'filter'][
'SITE.DELETED']) &&
622 !isset($params[
'filter'][
'=SITE.DELETED'])
625 $params[
'filter'][
'=SITE.DELETED'] =
'N';
628 if (isset($params[
'filter'][
'CHECK_PERMISSIONS']))
630 unset($params[
'filter'][
'CHECK_PERMISSIONS']);
635 if (isset($params[
'filter'][
'SITE.TYPE']))
637 $type = $params[
'filter'][
'SITE.TYPE'];
638 unset($params[
'filter'][
'SITE.TYPE']);
640 if (isset($params[
'filter'][
'=SITE.TYPE']))
642 $type = $params[
'filter'][
'=SITE.TYPE'];
643 unset($params[
'filter'][
'=SITE.TYPE']);
645 $allowedTypes = \Bitrix\Landing\Site\Type::getFilterType();
646 $params[
'filter'][
'=SITE.TYPE'] = in_array($type, (array)$allowedTypes)
650 return parent::getList($params);
680 $result =
new Entity\EventResult();
681 $primary = $event->getParameter(
'primary');
689 'ID' => $primary[
'ID'],
690 'CHECK_PERMISSIONS' =>
'N',
691 '=SITE.DELETED' => [
'Y',
'N'],
692 '=DELETED' => [
'Y',
'N']
695 if ($site = $res->fetch())
704 $result->setErrors(array(
716 $result->setErrors(array(
735 $result =
new Entity\EventResult();
737 if (!empty(self::$additionalFields))
739 $primary = $event->getParameter(
'primary');
742 self::$additionalFields
756 $primary = $event->getParameter(
'primary');
757 $fields = $event->getParameter(
'fields');
764 if (isset($primary[
'ID']) && array_key_exists(
'CODE', $fields))
766 $landingId = (int)$primary[
'ID'];
773 if ($landing->getMeta()[
'RULE'])
779 if ($landing->exist())
781 if ($fields[
'FOLDER_ID'] ??
null)
788 '!ID' => $primary[
'ID'],
789 'FOLDER_ID' => $fields[
'FOLDER_ID'],
790 '=CODE' => $fields[
'CODE']
800 $landingUrl = $landing->getPublicUrl(
false,
false);
802 if ($resolvedId && $landingId !== $resolvedId)
817 if (self::$additionalFields)
821 parent::update($landingId, $reUpdate);
834 $primary = $event->getParameter(
'primary');
835 $fields = $event->getParameter(
'fields');
838 if ($primary && isset($fields[
'SITE_ID']))
845 'SITE_ID' => $fields[
'SITE_ID'],
846 'CHECK_PERMISSIONS' =>
'N'
850 if (count($res->fetchAll()) == 1)
853 SiteTable::update($fields[
'SITE_ID'], array(
854 'LANDING_ID_INDEX' => $primary[
'ID']
872 $primary = $event->getParameter(
'primary');
873 $fields = $event->getParameter(
'fields');
877 Cache::clear($primary[
'ID']);
882 array_key_exists(
'SITE_ID', $fields) &&
886 \Bitrix\Landing\Site::update(
904 $primary = $event->getParameter(
'primary');
906 if (isset($primary[
'ID']))
910 \Bitrix\Landing\File::deleteFromLanding($primary[
'ID']);
911 \Bitrix\Landing\Syspage::deleteForLanding($primary[
'ID']);
912 \Bitrix\Landing\Hook::deleteForLanding($primary[
'ID']);
913 \Bitrix\Landing\TemplateRef::deleteArea($primary[
'ID']);
914 \Bitrix\Landing\TemplateRef::setForLanding($primary[
'ID'], array());
915 \Bitrix\Landing\UrlRewrite::removeForLanding($primary[
'ID']);
918 $res = \Bitrix\Landing\Site::getList(array(
923 'LANDING_ID_INDEX' => $primary[
'ID']
926 if ($site = $res->fetch())
933 'SITE_ID' => $site[
'ID']
939 while ($page = $res->fetch())
943 \Bitrix\Landing\Site::update(
946 'LANDING_ID_INDEX' => $page[
'ID']
static getList(array $params=array())
static prepareChange(Entity\Event $event, $actionType)
static OnBeforeDelete(Entity\Event $event)
static revertCode(Entity\Event $event)
static OnAfterDelete(Entity\Event $event)
static OnAfterUpdate(Entity\Event $event)
static OnBeforeAdd(Entity\Event $event)
static setAccessFilter($params)
static saveAdditionalFields(Entity\Event $event)
static OnBeforeUpdate(Entity\Event $event)
static OnAfterAdd(Entity\Event $event)
static disableCheckDeleted()
static disableCheckUniqueAddress()
static isCheckUniqueAddress()
static resolveIdByPublicUrl(string $landingUrl, int $siteId)
static enableCheckDeleted()
static createInstance($id, array $params=array())
static saveAdditionalFields($id, array $data)
static enableCheckUniqueAddress()
static isLandingDeleteLocked(int $landingId)
static getRandomString(int $length)
static getAccessFilter(array $additionalFilterOr=[])
static getOperationsForSite($siteId)
static hasAccessForSite($siteId, $accessType, $deleted=false)
static getExpectedRoleIds()
static landingIsArea($lid)
static loadMessages($file)
static getMessage($code, $replace=null, $language=null)
static getList(array $parameters=array())