1C-Bitrix
25.700.0
Загрузка...
Поиск...
Не найдено
locationduplicatecleaner.php
См. документацию.
1
<?php
2
3
namespace
Bitrix\Calendar\Update;
4
use Bitrix\Main\Loader;
5
use Bitrix\Main\Update\Stepper;
6
7
class
LocationDuplicateCleaner
extends
Stepper
8
{
9
protected
static
$moduleId
=
"calendar"
;
10
11
public
static
function
className
()
12
{
13
return
get_called_class();
14
}
15
21
public
function
execute
(
array
&
$result
): bool
22
{
23
if
(!Loader::includeModule(
"calendar"
))
24
{
25
return
self::FINISH_EXECUTION;
26
}
27
28
if
($dataToClean = $this->getEntryDataToClean())
29
{
30
$this->cleanDuplicates((
int
)$dataToClean[
'PARENT_ID'
], (
int
)$dataToClean[
'LASTID'
]);
31
return
self::CONTINUE_EXECUTION;
32
}
33
34
return
self::FINISH_EXECUTION;
35
}
36
40
private
function
getEntryDataToClean(): ?
array
41
{
42
global
$DB
;
43
$strSql =
"select
44
MAX(ID) as LASTID,
45
PARENT_ID,
46
COUNT(1) as CNT
47
from
48
b_calendar_event
49
where
50
CAL_TYPE='location'
51
group by
52
PARENT_ID
53
having CNT > 1
54
order by ID desc
55
limit 1"
;
56
57
$res
=
$DB
->Query($strSql);
58
if
($entry =
$res
->Fetch())
59
{
60
return
$entry;
61
}
62
return
null
;
63
}
64
70
private
function
cleanDuplicates(
int
$parentId,
int
$entryToLeave): void
71
{
72
global
$DB
;
73
$strSql =
"delete from
74
b_calendar_event
75
where
76
CAL_TYPE = 'location'
77
and PARENT_ID = '"
.$parentId.
"'
78
and ID != '"
.$entryToLeave.
"'
79
limit 1000"
;
80
81
$DB
->Query($strSql);
82
}
83
}
Bitrix\Calendar\Update\LocationDuplicateCleaner
Определения
locationduplicatecleaner.php:8
Bitrix\Calendar\Update\LocationDuplicateCleaner\execute
execute(array &$result)
Определения
locationduplicatecleaner.php:21
Bitrix\Calendar\Update\LocationDuplicateCleaner\$moduleId
static $moduleId
Определения
locationduplicatecleaner.php:9
Bitrix\Calendar\Update\LocationDuplicateCleaner\className
static className()
Определения
locationduplicatecleaner.php:11
Bitrix\Main\Update\Stepper
Определения
stepper.php:29
array
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
Определения
file_new.php:804
$res
$res
Определения
filter_act.php:7
$result
$result
Определения
get_property_values.php:14
$DB
global $DB
Определения
cron_frame.php:29
bitrix
modules
calendar
lib
update
locationduplicatecleaner.php
Создано системой
1.14.0