Bitrix-D7
23.9
Загрузка...
Поиск...
Не найдено
domainua.php
1
<?php
2
3
namespace
Bitrix\Landing\Site\Update
;
4
5
use
Bitrix\Landing\Internals\DomainTable
;
6
use
Bitrix\Landing\Internals\LandingTable
;
7
use
Bitrix\Landing\Manager
;
8
use
Bitrix\Main\SystemException
;
9
13
class
DomainUa
extends
Update
14
{
15
protected
const
DOMAIN_UA
=
'.bitrix24site.ua'
;
16
protected
const
OPTION_IS_FORM_REBUILD
=
'is_ua_forms_rebuild'
;
17
23
public
static
function
update
(
int
$siteId): bool
24
{
25
$site =
self::getId
($siteId);
26
$domainId = (int)$site[
'DOMAIN_ID'
];
27
28
29
if
(!self::isNeedDomainUpdate($domainId))
30
{
31
return
true
;
32
}
33
34
if
(
35
!self::updateDomain($domainId, $site)
36
|| !
self::unPublicationPages
($siteId)
37
)
38
{
39
return
false
;
40
}
41
42
if
(self::isNeedFormsUpdate())
43
{
44
self::updateForms
();
45
}
46
47
return
true
;
48
}
49
59
protected
static
function
isNeedDomainUpdate
(
int
$domainId): bool
60
{
61
$res = DomainTable::getList([
62
'select'
=> [
63
'ID'
,
'DOMAIN'
,
64
],
65
'filter'
=> [
66
'ID'
=> $domainId,
67
],
68
]);
69
if
($row = $res->fetch())
70
{
71
// todo: check if it is our domain?
72
$domainLength = strlen(self::DOMAIN_UA);
73
74
return
substr($row[
'DOMAIN'
], -1 * $domainLength) ===
self::DOMAIN_UA
;
75
}
76
77
return
false
;
78
}
79
87
protected
static
function
updateDomain
(
int
$domainId, array $site): bool
88
{
89
try
90
{
91
$siteController =
Manager::getExternalSiteController
();
92
if
($siteController)
93
{
94
$publicUrl =
Manager::getPublicationPath
($site[
'ID'
]);
95
$zone =
Manager::getZone
();
96
$domainName = $siteController::addRandomDomain(
97
$publicUrl,
98
$site[
'TYPE'
],
99
$zone ===
'ua'
?
'eu'
: $zone
100
);
101
102
103
if
($domainName)
104
{
105
// todo: need set prev id?
106
$resDomain = DomainTable::update($domainId, [
107
'DOMAIN'
=> $domainName,
108
]);
109
110
return
$resDomain->isSuccess();
111
}
112
}
113
}
114
catch
(
SystemException
$ex)
115
{
116
}
117
118
return
false
;
119
}
120
130
protected
static
function
unPublicationPages
(
int
$siteId): bool
131
{
132
$res =
LandingTable::getList
([
133
'select'
=> [
'ID'
],
134
'filter'
=> [
135
'SITE_ID'
=> $siteId,
136
'ACTIVE'
=>
'Y'
,
137
],
138
]);
139
while
($landing = $res->fetch())
140
{
141
$resUpdate = LandingTable::update($landing[
'ID'
], [
142
'ACTIVE'
=>
'N'
,
143
'PUBLIC'
=>
'N'
,
144
]);
145
146
if
(!$resUpdate->isSuccess())
147
{
148
return
false
;
149
}
150
}
151
152
return
true
;
153
}
154
159
protected
static
function
isNeedFormsUpdate
(): bool
160
{
161
$option =
Manager::getOption
(self::OPTION_IS_FORM_REBUILD,
'N'
);
162
163
164
return
$option ===
'N'
;
165
}
166
171
protected
static
function
updateForms
(): bool
172
{
173
\CAgent::AddAgent(
174
'\\Bitrix\\Crm\\UI\\Webpack\\Guest::rebuildAgent();'
,
175
"crm"
,
176
"N"
,
177
60,
178
""
,
179
"Y"
,
180
\ConvertTimeStamp(time() + \CTimeZone::GetOffset() + 60,
"FULL"
)
181
);
182
183
\CAgent::AddAgent(
184
'\\Bitrix\\Crm\\WebForm\\Manager::updateScriptCacheAgent();'
,
185
"crm"
,
186
"N"
,
187
60,
188
""
,
189
"Y"
,
190
\ConvertTimeStamp(time() + \CTimeZone::GetOffset() + 100,
"FULL"
)
191
);
192
193
\CAgent::AddAgent(
194
'\\Bitrix\\Crm\\SiteButton\\Manager::updateScriptCacheAgent();'
,
195
"crm"
,
196
"N"
,
197
60,
198
""
,
199
"Y"
,
200
\ConvertTimeStamp(time() + \CTimeZone::GetOffset() + 300,
"FULL"
)
201
);
202
203
\CAgent::AddAgent(
204
'\\Bitrix\\Crm\\UI\\Webpack\\CallTracker::rebuildAgent();'
,
205
"crm"
,
206
"N"
,
207
60,
208
""
,
209
"Y"
,
210
\ConvertTimeStamp(time() + \CTimeZone::GetOffset() + 400,
"FULL"
)
211
);
212
213
\CAgent::AddAgent(
214
'\\Bitrix\\Crm\\UI\\Webpack\\CallTrackerEditor::rebuildAgent();'
,
215
"crm"
,
216
"N"
,
217
60,
218
""
,
219
"Y"
,
220
\ConvertTimeStamp(time() + \CTimeZone::GetOffset() + 450,
"FULL"
)
221
);
222
223
Manager::setOption
(self::OPTION_IS_FORM_REBUILD,
'Y'
);
224
225
// now is always true. If error - rebuild forms manually, not by updater
226
return
true
;
227
}
228
}
Bitrix\Landing\Assets\Manager
Definition
manager.php:20
Bitrix\Landing\Internals\DomainTable
Definition
domain.php:28
Bitrix\Landing\Internals\LandingTable
Definition
landing.php:32
Bitrix\Landing\Internals\LandingTable\getList
static getList(array $params=array())
Definition
landing.php:602
Bitrix\Landing\Manager\getOption
static getOption($code, $default=null)
Definition
manager.php:160
Bitrix\Landing\Manager\setOption
static setOption($code, $value)
Definition
manager.php:171
Bitrix\Landing\Manager\getPublicationPath
static getPublicationPath($siteCode=null, $siteId=null, $createPubPath=false)
Definition
manager.php:396
Bitrix\Landing\Manager\getZone
static getZone()
Definition
manager.php:925
Bitrix\Landing\Manager\getExternalSiteController
static getExternalSiteController()
Definition
manager.php:1324
Bitrix\Landing\Site\Update\DomainUa
Definition
domainua.php:14
Bitrix\Landing\Site\Update\DomainUa\unPublicationPages
static unPublicationPages(int $siteId)
Definition
domainua.php:130
Bitrix\Landing\Site\Update\DomainUa\DOMAIN_UA
const DOMAIN_UA
Definition
domainua.php:15
Bitrix\Landing\Site\Update\DomainUa\updateDomain
static updateDomain(int $domainId, array $site)
Definition
domainua.php:87
Bitrix\Landing\Site\Update\DomainUa\isNeedDomainUpdate
static isNeedDomainUpdate(int $domainId)
Definition
domainua.php:59
Bitrix\Landing\Site\Update\DomainUa\OPTION_IS_FORM_REBUILD
const OPTION_IS_FORM_REBUILD
Definition
domainua.php:16
Bitrix\Landing\Site\Update\DomainUa\updateForms
static updateForms()
Definition
domainua.php:171
Bitrix\Landing\Site\Update\DomainUa\update
static update(int $siteId)
Definition
domainua.php:23
Bitrix\Landing\Site\Update\DomainUa\isNeedFormsUpdate
static isNeedFormsUpdate()
Definition
domainua.php:159
Bitrix\Landing\Site\Update\Update
Definition
update.php:5
Bitrix\Landing\Site\Update\Update\getId
static getId(int $siteId)
Definition
update.php:18
Bitrix\Main\SystemException
Definition
exception.php:8
Bitrix\Landing\Site\Update
Definition
chatsales.php:3
modules
landing
lib
site
update
domainua.php
Создано системой
1.10.0