26 protected function getInitData(): array
28 if (!\
Bitrix\Main\Loader::includeModule(
'im'))
39 $dom = $block->getDom();
43 isset($filter[
'type']) &&
44 is_string($filter[
'type'])
47 $type = mb_strtolower(trim($filter[
'type']));
52 isset($filter[
'attributeData']) &&
53 is_string($filter[
'attributeData']) &&
54 mb_strpos($filter[
'attributeData'],
'@')
57 [$attrSelector, $attrCode] = explode(
'@', $filter[
'attributeData']);
58 $attrCode = mb_strtolower($attrCode);
59 $resultNode = $dom->querySelector($attrSelector);
62 if ($type == self::CHAT_TYPE_PERSONAL)
64 $return[
'CHAT_ID'] = (int) $resultNode->getAttribute($attrCode);
66 if (!$return[
'CHAT_ID'])
69 $resultNode->setAttribute($attrCode, $return[
'CHAT_ID']);
73 else if ($type == self::CHAT_TYPE_GROUP)
75 $return[
'CHAT_ID'] = trim($resultNode->getAttribute($attrCode));
77 if (preg_match(
'/[^\d]+/', $return[
'CHAT_ID']))
79 $chantEntity = json_decode(htmlspecialcharsback($return[
'CHAT_ID']),
true);
80 if (is_array($chantEntity))
82 if (isset($chantEntity[
'ID']))
84 $chatId = $chantEntity[
'ID'];
85 unset($chantEntity[
'ID']);
86 $res = \Bitrix\Landing\Chat\Chat::update(
93 $res = \Bitrix\Landing\Chat\Chat::add(
97 if ($res->isSuccess())
99 $return[
'CHAT_ID'] = $res->getId();
100 $resultNode->setAttribute(
101 $attrCode, $return[
'CHAT_ID']
107 else if (!$return[
'CHAT_ID'])
109 unset($return[
'CHAT_ID']);
111 $return[
'CHAT_ID'] = (int)$return[
'CHAT_ID'];
112 if ($return[
'CHAT_ID'])
114 \Bitrix\Landing\Chat\Binding::bindingBlock(
115 $return[
'CHAT_ID'], $block->getId()
125 isset($filter[
'attributeButton']) &&
126 is_string($filter[
'attributeButton']) &&
127 mb_strpos($filter[
'attributeButton'],
'@')
130 [$attrSelector, $attrCode] = explode(
'@', $filter[
'attributeButton']);
131 $attrCode = mb_strtolower($attrCode);
132 $resultNode = $dom->querySelector($attrSelector);
135 $return[
'SEND_TITLE'] = $resultNode->getAttribute($attrCode);
136 if (!$return[
'SEND_TITLE'])
138 $return[
'SEND_TITLE'] =
Loc::getMessage(
'LANDING_SUBTYPE_BUTTON_SEND');
139 $resultNode->setAttribute($attrCode, $return[
'SEND_TITLE']);
146 if ($return && $type)
148 $return[
'TYPE'] = $type;
154 $block->saveContent($dom->saveHTML());
169 $userFilter = [
'=ACTIVE' =>
'Y'];
170 $chatId = $initData[
'CHAT_ID'];
171 $chatType = $initData[
'TYPE'];
174 'text' => $initData[
'SEND_TITLE']
178 if ($chatType == $this::CHAT_TYPE_PERSONAL)
180 $sendButton[
'href'] =
'#chat' . $chatId;
181 $userFilter[
'ID'] = $chatId;
183 else if ($chatType == $this::CHAT_TYPE_GROUP)
185 $sendButton[
'href'] =
'#join' . $chatId;
186 $userFilter[
'ID'] = \Bitrix\Landing\Chat\Chat::getMembersId(
189 if (!$userFilter[
'ID'])
191 $userFilter[
'ID'] = -1;
201 $res = \Bitrix\Main\UserTable::getList([
203 'ID',
'LOGIN',
'NAME',
'LAST_NAME',
'SECOND_NAME',
204 'WORK_POSITION',
'PERSONAL_PHOTO'
206 'filter' => $userFilter
208 while ($user = $res->fetch())
210 if (Cache::isCaching())
213 'intranet_user_' . $user[
'ID']
218 'WORK_POSITION' => \htmlspecialcharsbx($user[
'WORK_POSITION']),
219 'NAME' => $name = \htmlspecialcharsbx(\CUser::formatName(
220 \CSite::getNameFormat(),
224 'src' => \CIMChat::getAvatarImage($user[
'PERSONAL_PHOTO']),
227 'SEND' => $sendButton
240 $initData = $this->getInitData();
static loadMessages($file)
static getMessage($code, $replace=null, $language=null)