25 if (!Loader::includeModule(self::$moduleId))
32 $params = Option::get(self::$moduleId, self::OPTION_NAME,
"");
33 $params = ($params !==
"" ? @unserialize($params, [
"allowed_classes" =>
false]) : []);
34 $params = (is_array($params) ? $params : []);
40 "count" => RelationTable::getCount(),
44 if ($params[
"count"] > 0)
46 $result[
"steps"] =
"";
47 $result[
"count"] = $params[
"count"];
49 $ids = RelationTable::getList(
51 'order' => [
'ID' =>
'ASC'],
53 '>ID' => $params[
"lastId"],
62 $ids = array_map(
function($item){
66 $idsCount = count($ids);
69 $params[
"lastId"] = $ids[$idsCount - 1];
70 $params[
"number"] += $idsCount;
72 $implodedIds = implode(
',', $ids);
74 UPDATE b_im_relation R
75 INNER JOIN b_im_chat C ON R.CHAT_ID = C.ID
76 SET R.START_COUNTER = (
79 WHERE M.CHAT_ID = R.CHAT_ID AND M.ID < R.START_ID
81 WHERE R.ID IN (" .$implodedIds.
")
84 Option::set(self::$moduleId, self::OPTION_NAME, serialize($params));
89 Option::delete(self::$moduleId, [
"name" => self::OPTION_NAME]);
92 $result[
"steps"] = $params[
"number"];