28 if (!Loader::includeModule(self::$moduleId))
33 $indexStatus = Option::get(self::$moduleId, self::OPTION_NAME.
'_status', self::STATUS_DEFAULT);
34 if ($indexStatus === self::STATUS_DEFAULT)
36 if (IsModuleInstalled(
'bitrix24'))
41 elseif ($indexStatus === self::STATUS_DISABLED)
48 $params = Option::get(self::$moduleId, self::OPTION_NAME,
"");
49 $params = ($params !==
"" ? @unserialize($params, [
"allowed_classes" =>
false]) : []);
50 $params = (is_array($params) ? $params : []);
56 "count" => MessageTable::getCount(),
60 if ($params[
"count"] > 0)
63 $result[
"progress"] = 1;
64 $result[
"steps"] =
"";
65 $result[
"count"] = $params[
"count"];
67 $cursor = MessageTable::getList(
69 'order' => [
'ID' =>
'ASC'],
71 '>ID' => $params[
"lastId"],
80 while ($row = $cursor->fetch())
82 MessageTable::indexRecord($row[
'ID']);
84 $params[
"lastId"] = $row[
'ID'];
91 Option::set(self::$moduleId, self::OPTION_NAME, serialize($params));
95 $result[
"progress"] = (int)($params[
"number"] * 100 / $params[
"count"]);
96 $result[
"steps"] = $params[
"number"];
100 Option::delete(self::$moduleId, [
"name" => self::OPTION_NAME]);
102 if ($DB->IndexExists(
"b_im_message_index", array(
"SEARCH_CONTENT"),
true))
104 \Bitrix\Im\Model\MessageIndexTable::getEntity()->enableFullTextIndex(
'SEARCH_CONTENT');
108 elseif ($params[
"count"] == 0)
110 Option::delete(self::$moduleId, [
"name" => self::OPTION_NAME]);
112 if ($DB->IndexExists(
"b_im_message_index", array(
"SEARCH_CONTENT"),
true))
114 \Bitrix\Im\Model\MessageIndexTable::getEntity()->enableFullTextIndex(
'SEARCH_CONTENT');