1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
event.php
См. документацию.
1<?php
2
3namespace Bitrix\Socialnetwork\Internals\EventService;
4
5use Bitrix\Main\Type\DateTime;
6use Bitrix\Socialnetwork\Internals\EventService\Recepients\Collector;
7use Bitrix\Socialnetwork\Internals\EventService\Recepients\Recepient;
8use Bitrix\Socialnetwork\Internals\EventService\Recepients\RecepientCollection;
9use Bitrix\Socialnetwork\Internals\EventService\Recepients\SonetRightsRecepient;
10use Bitrix\Socialnetwork\Internals\EventService\Recepients\WorkgroupRequestRecipient;
11
17
18class Event
19{
20 protected int|null $eventId = null;
21 protected array $data = [];
23
24 public function __construct(
25 protected string $hitId,
26 protected string $type = ''
27 )
28 {
29 $this->dateTime = new DateTime();
30 }
31
32 public function setId(int $eventId): self
33 {
34 $this->eventId = $eventId;
35
36 return $this;
37 }
38
39 public function setData(array $data = []): self
40 {
41 $this->data = $this->prepareData($data);
42
43 return $this;
44 }
45
46 public function getId(): int|null
47 {
48 return $this->eventId;
49 }
50
51 public function getType(): string
52 {
53 return $this->type;
54 }
55
56 public function getDateTime(): DateTime
57 {
58 return $this->dateTime;
59 }
60
61 public function getData(): array
62 {
63 return $this->data;
64 }
65
66 public function getUserId(): int
67 {
68 return (int)($this->data['USER_ID'] ?? 0);
69 }
70
71 public function getGroupId(): int
72 {
73 return (int)($this->data['GROUP_ID'] ?? 0);
74 }
75
76 public function getEntityTypeId(): string|null
77 {
78 return $this->data['ENTITY_TYPE_ID'] ?? null;
79 }
80
81 public function getEntityId(): int
82 {
83 return (int)($this->data['ENTITY_ID'] ?? 0);
84 }
85
86 public function getHash(): string
87 {
88 return md5($this->hitId . $this->type . json_encode($this->data));
89 }
90
91 protected function prepareData(array $data = []): array
92 {
93 $validFields = [
94 'GROUP_ID',
95 'PREVIOUS_GROUP_ID',
96 'NAME',
97 'PROJECT_DATE_START',
98 'PROJECT_DATE_FINISH',
99 'IMAGE_ID',
100 'AVATAR_TYPE',
101 'OPENED',
102 'CLOSED',
103 'VISIBLE',
104 'PROJECT',
105 'KEYWORDS',
106 'USER_ID',
107 'TITLE',
108 'RECEPIENTS',
109 'SONET_LOG_ID',
110 'SONET_LOG_COMMENT_ID',
111 'FEATURE_ID',
112 'SPACE_ID',
113 'TYPE_ID',
114 'ENTITY_ID',
115 'ENTITY_TYPE_ID',
116 'ID',
117 'ATTENDEES_CODES',
118 'EVENT_ID',
119 'ROLE',
120 'OLD_ROLE',
121 'NEW_ROLE',
122 'INITIATED_BY_TYPE',
123 'OLD_INITIATED_BY_TYPE',
124 'LOG_RIGHTS',
125 'LOG_RIGHTS_BEFORE_UPDATE',
126 'OLD_MEMBERS',
127 'NEW_MEMBERS',
128 'ATTENDEES_BEFORE_UPDATE',
129 'ATTENDEES_AFTER_UPDATE',
130 'ATTENDEES_CODES_BEFORE_UPDATE',
131 'ATTENDEES_CODES_AFTER_UPDATE',
132 'COMMENT_ID',
133 'MESSAGE_ID',
134 ];
135
136 if (!empty($data['TASK_ID']))
137 {
138 $data['ID'] = $data['TASK_ID'];
139 }
140
141 if (is_array($data['NEW_RECORD'] ?? null))
142 {
143 $data = array_merge($data, $data['NEW_RECORD']);
144 }
145
146 foreach ($data as $key => $row)
147 {
148 if (!in_array($key, $validFields, true))
149 {
150 unset($data[$key]);
151 }
152 }
153
154 return $data;
155 }
156
157 public function getRecepients(): Collector
158 {
159 $eventType = $this->getType();
160 $data = $this->getData();
161
162 switch ($eventType)
163 {
165 return new RecepientCollection(...[new Recepient($data['USER_ID'])]);
172 return new SonetRightsRecepient($data['SONET_LOG_ID'], $data['LOG_RIGHTS'] ?? null);
176 return new WorkgroupRequestRecipient($data['GROUP_ID']);
177 default:
178 // in case recipient ids are defined
179 if (isset($data['RECEPIENTS']) && is_array($data['RECEPIENTS']))
180 {
181 $recipients = [];
182 foreach ($data['RECEPIENTS'] as $id)
183 {
184 $recipients[] = new Recepient($id);
185 }
186 return new RecepientCollection(...$recipients);
187 }
188
189 // in case there is one recipient
190 if (isset($data['USER_ID']))
191 {
192 return new RecepientCollection(...[new Recepient($data['USER_ID'])]);
193 }
194 }
195
196 return new RecepientCollection(...[]);
197 }
198
199 public function collectNewData(): void
200 {
201 return;
202 }
203
204 public function getOldFields(): array
205 {
206 return [];
207 }
208
209 public function getNewFields(): array
210 {
211 return [];
212 }
213}
$type
Определения options.php:106
prepareData(array $data=[])
Определения event.php:91
setData(array $data=[])
Определения event.php:39
__construct(protected string $hitId, protected string $type='')
Определения event.php:24
$data['IS_AVAILABLE']
Определения .description.php:13
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
Определения file_new.php:804
if(empty($signedUserToken)) $key
Определения quickway.php:257