Bitrix-D7
23.9
Загрузка...
Поиск...
Не найдено
livefeedindexcomment.php
1
<?
2
namespace
Bitrix\Blog\Update
;
3
4
use \Bitrix\Main\Update\Stepper;
5
use \Bitrix\Main\Localization\Loc;
6
use \Bitrix\Blog\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
=
"blog"
;
18
19
public
function
execute
(array &$result)
20
{
21
if
(!(
22
Loader::includeModule(
"blog"
)
23
&& Loader::includeModule(
"socialnetwork"
)
24
&& Option::get(
'blog'
,
'needLivefeedIndexComment'
,
'Y'
) ==
'Y'
25
))
26
{
27
return
false
;
28
}
29
30
$return =
false
;
31
32
$params = Option::get(
"blog"
,
"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_BLOG_COMMENT_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(
"blog"
,
"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(
"blog"
, array(
"name"
=>
"livefeedindexcomment"
));
94
Option::set(
'blog'
,
'needLivefeedIndexComment'
,
'N'
);
95
}
96
}
97
return
$return;
98
}
99
}
100
?>
Bitrix\Blog\Update\LivefeedIndexComment
Definition
livefeedindexcomment.php:16
Bitrix\Blog\Update\LivefeedIndexComment\execute
execute(array &$result)
Definition
livefeedindexcomment.php:19
Bitrix\Blog\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\ORM\Data\DataManager\getList
static getList(array $parameters=array())
Definition
datamanager.php:441
Bitrix\Main\ORM\Data\DataManager\getCount
static getCount($filter=array(), array $cache=array())
Definition
datamanager.php:526
Bitrix\Main\Update\Stepper
Definition
stepper.php:27
Bitrix\Blog\Update
Definition
livefeedindexcomment.php:2
modules
blog
lib
update
livefeedindexcomment.php
Создано системой
1.10.0