1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
messageindex.php
См. документацию.
1<?
2namespace Bitrix\Im\Update;
3
4use Bitrix\Im\Model\MessageTable;
5use Bitrix\Main\Update\Stepper;
6use Bitrix\Main\Localization\Loc;
7use Bitrix\Main\Loader;
8use Bitrix\Main\Config\Option;
9
10Loc::loadMessages(__FILE__);
11
12final class MessageIndex extends Stepper
13{
14 const OPTION_NAME = "im_index_message";
15 const STATUS_ENABLED = 'enabled';
16 const STATUS_DISABLED = 'disabled';
17 const STATUS_DEFAULT = 'default';
18
19 protected static $moduleId = "im";
20
24 public function execute(array &$result)
25 {
26 global $DB;
27
28 if (!Loader::includeModule(self::$moduleId))
29 {
30 return false;
31 }
32
33 $indexStatus = Option::get(self::$moduleId, self::OPTION_NAME.'_status', self::STATUS_DEFAULT);
34 if ($indexStatus === self::STATUS_DEFAULT)
35 {
36 if (IsModuleInstalled('bitrix24'))
37 {
38 return false;
39 }
40 }
41 elseif ($indexStatus === self::STATUS_DISABLED)
42 {
43 return false;
44 }
45
46 $return = false;
47
48 $params = Option::get(self::$moduleId, self::OPTION_NAME, "");
49 $params = ($params !== "" ? @unserialize($params, ["allowed_classes" => false]) : []);
50 $params = (is_array($params) ? $params : []);
51 if (empty($params))
52 {
53 $params = [
54 "lastId" => 0,
55 "number" => 0,
56 "count" => MessageTable::getCount(),
57 ];
58 }
59
60 if ($params["count"] > 0)
61 {
62 $result["title"] = Loc::getMessage("IM_UPDATE_MESSAGE_INDEX");
63 $result["progress"] = 1;
64 $result["steps"] = "";
65 $result["count"] = $params["count"];
66
67 $cursor = MessageTable::getList(
68 [
69 'order' => ['ID' => 'ASC'],
70 'filter' => [
71 '>ID' => $params["lastId"],
72 ],
73 'select' => ['ID'],
74 'offset' => 0,
75 'limit' => 5000
76 ]
77 );
78
79 $found = false;
80 while ($row = $cursor->fetch())
81 {
82 MessageTable::indexRecord($row['ID']);
83
84 $params["lastId"] = $row['ID'];
85 $params["number"]++;
86 $found = true;
87 }
88
89 if ($found)
90 {
91 Option::set(self::$moduleId, self::OPTION_NAME, serialize($params));
92 $return = true;
93 }
94
95 $result["progress"] = (int)($params["number"] * 100 / $params["count"]);
96 $result["steps"] = $params["number"];
97
98 if ($found === false)
99 {
100 Option::delete(self::$moduleId, ["name" => self::OPTION_NAME]);
101
102 if ($DB->IndexExists("b_im_message_index", array("SEARCH_CONTENT"), true))
103 {
104 \Bitrix\Im\Model\MessageIndexTable::getEntity()->enableFullTextIndex('SEARCH_CONTENT');
105 }
106 }
107 }
108 elseif ($params["count"] == 0)
109 {
110 Option::delete(self::$moduleId, ["name" => self::OPTION_NAME]);
111
112 if ($DB->IndexExists("b_im_message_index", array("SEARCH_CONTENT"), true))
113 {
114 \Bitrix\Im\Model\MessageIndexTable::getEntity()->enableFullTextIndex('SEARCH_CONTENT');
115 }
116 }
117
118 return $return;
119 }
120}
execute(array &$result)
Определения messageindex.php:24
const STATUS_ENABLED
Определения messageindex.php:15
const STATUS_DEFAULT
Определения messageindex.php:17
const STATUS_DISABLED
Определения messageindex.php:16
static $moduleId
Определения messageindex.php:19
const OPTION_NAME
Определения messageindex.php:14
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
Определения file_new.php:804
$result
Определения get_property_values.php:14
global $DB
Определения cron_frame.php:29
IsModuleInstalled($module_id)
Определения tools.php:5301
if( $daysToExpire >=0 &&$daysToExpire< 60 elseif)( $daysToExpire< 0)
Определения prolog_main_admin.php:393
if($inWords) echo htmlspecialcharsbx(Number2Word_Rus(roundEx($totalVatSum $params['CURRENCY']
Определения template.php:799