1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
notification.php
См. документацию.
1<?php
8
9namespace Bitrix\Sender\Integration\Im;
10
11use Bitrix\Main\Loader;
12use Bitrix\Sender\Security;
13use Bitrix\Sender\Entity;
14
20{
22 protected $to = array();
23
25 protected $message;
26
32 public static function canUse()
33 {
34 if (!Loader::includeModule('im'))
35 {
36 return false;
37 }
38 else
39 {
40 return true;
41 }
42 }
43
49 public static function create()
50 {
51 return new static();
52 }
53
60 public function setTo(array $list)
61 {
62 $this->to = $list;
63 return $this;
64 }
65
72 public function addTo($userId)
73 {
74 $this->to[] = $userId;
75 $this->to = array_unique($this->to);
76
77 return $this;
78 }
79
85 public function toAllAuthors()
86 {
88 'select' => array('CREATED_BY'),
89 'filter' => array(
90 '=MESSAGE_CODE',
91 '!=CREATED_BY' => null
92 ),
93 'group' => array('CREATED_BY'),
94 'cache' => array('ttl' => 3600),
95 ));
96 foreach ($list as $item)
97 {
98 $this->addTo($item['CREATED_BY']);
99 }
100
101 return $this;
102 }
103
109 public function toCurrentUser()
110 {
111 $this->addTo(Security\User::current()->getId());
112 return $this;
113 }
114
121 public function withMessage($message)
122 {
123 $this->message = $message;
124 return $this;
125 }
126
132 public function send()
133 {
134 if (!static::canUse())
135 {
136 return;
137 }
138
139 if (count($this->to) === 0 || !$this->message)
140 {
141 return;
142 }
143
144 foreach ($this->to as $userId)
145 {
146 $fields = array(
147 "TO_USER_ID" => $userId,
148 "FROM_USER_ID" => 0,
149 "NOTIFY_TYPE" => IM_NOTIFY_SYSTEM,
150 "NOTIFY_MODULE" => "sender",
151 //"NOTIFY_EVENT" => $imNotifyEvent,
152 //"NOTIFY_TAG" => $notifyTag,
153 "NOTIFY_MESSAGE" => $this->message
154 );
155 \CIMNotify::Add($fields);
156 }
157 }
158}
if(!is_object($USER)||! $USER->IsAuthorized()) $userId
Определения check_mail.php:18
static getList(array $parameters=array())
Определения letter.php:91
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
Определения file_new.php:804
const IM_NOTIFY_SYSTEM
Определения include.php:38
</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
$fields
Определения yandex_run.php:501