1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
chatstartingcount.php
См. документацию.
1<?
2namespace Bitrix\Im\Update;
3
4use Bitrix\Im\Model\RelationTable;
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 ChatStartingCount extends Stepper
13{
14 private const OPTION_NAME = "im_chat_starting_counter";
15
16 protected static $moduleId = "im";
17
21 public function execute(array &$result)
22 {
23 global $DB;
24
25 if (!Loader::includeModule(self::$moduleId))
26 {
27 return false;
28 }
29
30 $return = false;
31
32 $params = Option::get(self::$moduleId, self::OPTION_NAME, "");
33 $params = ($params !== "" ? @unserialize($params, ["allowed_classes" => false]) : []);
34 $params = (is_array($params) ? $params : []);
35 if (empty($params))
36 {
37 $params = [
38 "lastId" => 0,
39 "number" => 0,
40 "count" => RelationTable::getCount(),
41 ];
42 }
43
44 if ($params["count"] > 0)
45 {
46 $result["steps"] = "";
47 $result["count"] = $params["count"];
48
49 $ids = RelationTable::getList(
50 [
51 'order' => ['ID' => 'ASC'],
52 'filter' => [
53 '>ID' => $params["lastId"],
54 '>START_ID' => 0
55 ],
56 'select' => ['ID'],
57 'offset' => 0,
58 'limit' => 100
59 ]
60 )->fetchAll();
61
62 $ids = array_map(function($item){
63 return $item['ID'];
64 }, $ids);
65
66 $idsCount = count($ids);
67 if ($idsCount > 0)
68 {
69 $params["lastId"] = $ids[$idsCount - 1];
70 $params["number"] += $idsCount;
71
72 $implodedIds = implode(',', $ids);
73 $DB->Query("
74 UPDATE b_im_relation R
75 INNER JOIN b_im_chat C ON R.CHAT_ID = C.ID
76 SET R.START_COUNTER = (
77 SELECT COUNT(1)
78 FROM b_im_message M
79 WHERE M.CHAT_ID = R.CHAT_ID AND M.ID < R.START_ID
80 )
81 WHERE R.ID IN (" .$implodedIds. ")
82 ");
83
84 Option::set(self::$moduleId, self::OPTION_NAME, serialize($params));
85 $return = true;
86 }
87 else
88 {
89 Option::delete(self::$moduleId, ["name" => self::OPTION_NAME]);
90 }
91
92 $result["steps"] = $params["number"];
93 }
94
95 return $return;
96 }
97}
execute(array &$result)
Определения chatstartingcount.php:21
</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
</p ></td >< td valign=top style='border-top:none;border-left:none;border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt;padding:0cm 2.0pt 0cm 2.0pt;height:9.0pt'>< p class=Normal align=center style='margin:0cm;margin-bottom:.0001pt;text-align:center;line-height:normal'>< a name=ТекстовоеПоле54 ></a ><?=($taxRate > count( $arTaxList) > 0) ? $taxRate."%"
Определения waybill.php:936
if($inWords) echo htmlspecialcharsbx(Number2Word_Rus(roundEx($totalVatSum $params['CURRENCY']
Определения template.php:799