1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
AddGuestActionMessage.php
См. документацию.
1<?php
2
3declare(strict_types=1);
4
5namespace Bitrix\Socialnetwork\Collab\Integration\IM\Message;
6
7use Bitrix\Main\Loader;
8use Bitrix\Main\Localization\Loc;
9use Bitrix\Socialnetwork\Collab\Integration\IM\ActionMessageFactory;
10use Bitrix\Socialnetwork\Collab\Integration\IM\ActionType;
11
13{
14 use MessageTrait;
15
16 protected int $collabId;
17 protected int $senderId;
18
19 public function __construct(int $collabId, int $senderId)
20 {
21 $this->collabId = $collabId;
22 $this->senderId = $senderId;
23 }
24
25 public function send(array $recipientIds = [], array $parameters = []): int
26 {
27 if (!Loader::includeModule('im'))
28 {
29 return 0;
30 }
31
32 if (empty($recipientIds))
33 {
34 return 0;
35 }
36
37 $skipChat = $parameters['skipChat'] ?? false;
38
39 if (!$skipChat)
40 {
41 $this->addUsersToChat($this->collabId, ...$recipientIds);
42 }
43
44 $recipientNames = [];
45 foreach ($recipientIds as $recipientId)
46 {
47 if ($recipientId === $this->senderId)
48 {
49 $factory = ActionMessageFactory::getInstance();
50 $acceptMessage = $factory->getActionMessage(ActionType::AcceptUser, $this->collabId, $this->senderId);
51
52 $acceptMessage->send();
53
54 continue;
55 }
56
57 $recipientNames[] = $this->getName($this->senderId, $recipientId, $this->collabId);
58 }
59
60 if (empty($recipientNames))
61 {
62 return 0;
63 }
64
65 $userNames = implode(', ', $recipientNames);
66 $senderName = $this->getName($this->senderId, $this->senderId, $this->collabId);
67
68 $count = count($recipientNames);
69 $key = 'SOCIALNETWORK_COLLAB_CHAT_USER_ADD_GUEST' . $this->getGenderSuffix($this->senderId);
70 $key .= $count > 1 ? '_MANY' : '';
71
72 $message = (string)Loc::getMessage(
73 $key,
74 [
75 '#SENDER_NAME#' => $senderName,
76 '#RECIPIENT#' => $userNames,
77 ],
78 );
79
80 return $this->sendMessage($message, $this->senderId, $this->collabId);
81 }
82}
$count
Определения admin_tab.php:4
send(array $recipientIds=[], array $parameters=[])
Определения AddGuestActionMessage.php:25
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
Определения file_new.php:804
addUsersToChat(int $collabId, int ... $userIds)
Определения MessageTrait.php:97
sendMessage(string $message, int $senderId, int $groupId, ?string $componentId=null)
Определения MessageTrait.php:120
getName(int $senderId, int $recipientId, int $collabId)
Определения MessageTrait.php:49
$message
Определения payment.php:8
if(empty($signedUserToken)) $key
Определения quickway.php:257
</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