Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
livefeedindexcomment.php
1<?
3
4use \Bitrix\Main\Update\Stepper;
5use \Bitrix\Main\Localization\Loc;
6use \Bitrix\Blog\Integration;
7use \Bitrix\Socialnetwork\Item\LogIndex;
8use \Bitrix\Socialnetwork\LogCommentTable;
9use \Bitrix\Socialnetwork\LogIndexTable;
10use \Bitrix\Main\Config\Option;
11use \Bitrix\Main\Loader;
12
13Loc::loadMessages(__FILE__);
14
15final 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,
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?>
static loadMessages($file)
Definition loc.php:64
static getMessage($code, $replace=null, $language=null)
Definition loc.php:29
static getList(array $parameters=array())
static getCount($filter=array(), array $cache=array())