1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
service.php
См. документацию.
1<?php
2namespace Bitrix\Calendar\Sharing\Notification;
3
4use Bitrix\Calendar\Core\Event\Event;
5use Bitrix\Calendar\Sharing\Link\EventLink;
6use Bitrix\Calendar\Sharing\Link\CrmDealLink;
7use Bitrix\Calendar\Sharing;
8
9abstract class Service
10{
11 protected Event $event;
14 protected ?Event $oldEvent = null;
15 protected ?int $initiatorId = null;
16 private array $users = [];
17
21 public function getEvent(): Event
22 {
23 return $this->event;
24 }
25
30 public function setEvent(Event $event): self
31 {
32 $this->event = $event;
33
34 return $this;
35 }
36
40 public function getEventLink(): EventLink
41 {
42 return $this->eventLink;
43 }
44
49 public function setEventLink(EventLink $eventLink): self
50 {
51 $this->eventLink = $eventLink;
52
53 return $this;
54 }
55
61 {
62 $this->crmDealLink = $crmDealLink;
63
64 return $this;
65 }
66
71 public function setOldEvent(Event $oldEvent): self
72 {
73 $this->oldEvent = $oldEvent;
74
75 return $this;
76 }
77
78 public function setInitiatorId(?int $id): self
79 {
80 $this->initiatorId = $id;
81
82 return $this;
83 }
84
88 protected function getEventFormattedDateTime(): string
89 {
90 $from = $this->event->getStart();
91 $to = $this->event->getEnd();
92 $isFullDay = $this->event->isFullDayEvent();
93 return Sharing\Helper::formatTimeInterval($from, $to, $isFullDay);
94 }
95
99 protected function getOwner(): array
100 {
101 $ownerId = (int)$this->eventLink->getOwnerId();
102
103 return $this->getUser($ownerId);
104 }
105
106 protected function getInitiator(): array
107 {
108 if ($this->initiatorId === null)
109 {
110 return $this->getOwner();
111 }
112
113 return $this->getUser($this->initiatorId);
114 }
115
119 protected function getCalendarLink(): ?string
120 {
121 if ($this->eventLink->getParentLinkHash())
122 {
123 $sharingLinkFactory = new Sharing\Link\Factory();
124 $userLink = $sharingLinkFactory->getLinkByHash($this->eventLink->getParentLinkHash());
125 if ($userLink)
126 {
127 return $userLink->getUrl();
128 }
129 }
130 return null;
131 }
132
136 protected function getAttendeesList(): array
137 {
138 $attendeeListResult = \CCalendarEvent::getAttendeeList([$this->event->getId()]);
139
140 return $attendeeListResult['attendeeList'][$this->event->getId()];
141 }
142
143 private function getUser(int $id): array
144 {
145 if (in_array($id, $this->users, true))
146 {
147 return $this->users[$id];
148 }
149
150 $userInfo = Sharing\Helper::getUserInfo($id);
151
152 $eventAttendees = $this->getAttendeesList();
153 $userAttendeeInfo = current(array_filter($eventAttendees, static function(array $attendee) use ($id): bool {
154 $attendeeId = $attendee['id'] ?? null;
155
156 return $attendeeId === $id;
157 }));
158
159 if (isset($userAttendeeInfo['status']) && !in_array($userAttendeeInfo['status'], ['Q', 'Y', 'N'], true))
160 {
161 $userAttendeeInfo['status'] = 'Q';
162 }
163
164 $this->users[$id] = [
165 'ID' => $id,
166 'NAME' => "{$userInfo['name']} {$userInfo['lastName']}",
167 'PHOTO' => $userInfo['photo'],
168 'GENDER' => $userInfo['gender'],
169 'STATUS' => $userAttendeeInfo['status'] ?? 'Q',
170 ];
171
172 return $this->users[$id];
173 }
174
179 abstract public function notifyAboutMeetingStatus(string $to): bool;
180
185 abstract public function notifyAboutSharingEventEdit(string $to): bool;
186}
static formatTimeInterval(Date $from, Date $to, bool $isFullDay)
Определения helper.php:249
static getUserInfo(int $userId)
Определения helper.php:144
setCrmDealLink(CrmDealLink $crmDealLink)
Определения service.php:60
setOldEvent(Event $oldEvent)
Определения service.php:71
setEventLink(EventLink $eventLink)
Определения service.php:49
setEvent(Event $event)
Определения service.php:30
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
Определения file_new.php:804
$event
Определения prolog_after.php:141