Bitrix-D7
23.9
Загрузка...
Поиск...
Не найдено
livefeedindexcomment.php
1
<?
2
namespace
Bitrix\Forum\Update
;
3
4
use \Bitrix\Main\Update\Stepper;
5
use \Bitrix\Main\Localization\Loc;
6
use \Bitrix\Forum\Integration;
7
use \Bitrix\Socialnetwork\Item\LogIndex;
8
use \Bitrix\Socialnetwork\LogCommentTable;
9
use \Bitrix\Socialnetwork\LogIndexTable;
10
use \Bitrix\Main\Config\Option;
11
use \Bitrix\Main\Loader;
12
13
Loc::loadMessages
(__FILE__);
14
15
final
class
LivefeedIndexComment
extends
Stepper
16
{
17
protected
static
$moduleId
=
"forum"
;
18
19
public
function
execute
(array &$result)
20
{
21
if
(!(
22
Loader::includeModule(
"forum"
)
23
&& Loader::includeModule(
"socialnetwork"
)
24
&& Option::get(
'forum'
,
'needLivefeedIndexComment'
,
'Y'
) ==
'Y'
25
))
26
{
27
return
false
;
28
}
29
30
$return =
false
;
31
32
$params = Option::get(
"forum"
,
"livefeedindexcomment"
,
""
);
33
$params = ($params !==
""
? @unserialize($params, [
"allowed_classes"
=>
false
]) : array());
34
$params = (is_array($params) ? $params : array());
35
if
(empty($params))
36
{
37
$params = array(
38
"lastId"
=> 0,
39
"number"
=> 0,
40
"count"
=> LogCommentTable::getCount(
41
array(
42
'@EVENT_ID'
=> Integration\Socialnetwork\LogComment::getEventIdList(),
43
'!SOURCE_ID'
=>
false
44
)
45
)
46
);
47
}
48
49
if
($params[
"count"
] > 0)
50
{
51
$result[
"title"
] =
Loc::getMessage
(
"FUPD_LF_FORUM_COMMENT_EVENT_INDEX_TITLE"
);
52
$result[
"progress"
] = 1;
53
$result[
"steps"
] =
""
;
54
$result[
"count"
] = $params[
"count"
];
55
56
$res = LogCommentTable::getList(array(
57
'order'
=> array(
'ID'
=>
'ASC'
),
58
'filter'
=> array(
59
'>ID'
=> $params[
"lastId"
],
60
'@EVENT_ID'
=> Integration\Socialnetwork\LogComment::getEventIdList(),
61
'!SOURCE_ID'
=>
false
62
),
63
'select'
=> array(
'ID'
,
'EVENT_ID'
,
'SOURCE_ID'
),
64
'offset'
=> 0,
65
'limit'
=> 100
66
));
67
68
$found =
false
;
69
while
($record = $res->fetch())
70
{
71
LogIndex::setIndex(array(
72
'itemType'
=> LogIndexTable::ITEM_TYPE_COMMENT,
73
'itemId'
=> $record[
'ID'
],
74
'fields'
=> $record
75
));
76
77
$params[
"lastId"
] = $record[
'ID'
];
78
$params[
"number"
]++;
79
$found =
true
;
80
}
81
82
if
($found)
83
{
84
Option::set(
"forum"
,
"livefeedindexcomment"
, serialize($params));
85
$return =
true
;
86
}
87
88
$result[
"progress"
] = intval($params[
"number"
] * 100/ $params[
"count"
]);
89
$result[
"steps"
] = $params[
"number"
];
90
91
if
($found ===
false
)
92
{
93
Option::delete(
"forum"
, array(
"name"
=>
"livefeedindexcomment"
));
94
Option::set(
'forum'
,
'needLivefeedIndexComment'
,
'N'
);
95
}
96
}
97
return
$return;
98
}
99
}
100
?>
Bitrix\Forum\Update\LivefeedIndexComment
Definition
livefeedindexcomment.php:16
Bitrix\Forum\Update\LivefeedIndexComment\execute
execute(array &$result)
Definition
livefeedindexcomment.php:19
Bitrix\Forum\Update\LivefeedIndexComment\$moduleId
static $moduleId
Definition
livefeedindexcomment.php:17
Bitrix\Main\Localization\Loc\loadMessages
static loadMessages($file)
Definition
loc.php:64
Bitrix\Main\Localization\Loc\getMessage
static getMessage($code, $replace=null, $language=null)
Definition
loc.php:29
Bitrix\Main\Update\Stepper
Definition
stepper.php:27
Bitrix\Forum\Update
Definition
livefeedconvertservicemessage.php:2
modules
forum
lib
update
livefeedindexcomment.php
Создано системой
1.10.0