Bitrix-D7
23.9
Загрузка...
Поиск...
Не найдено
service.php
1
<?php
2
namespace
Bitrix\Calendar\Sharing\Notification
;
3
4
use
Bitrix\Calendar\Core\Event\Event
;
5
use
Bitrix\Calendar\Sharing\Link\EventLink
;
6
use
Bitrix\Calendar\Sharing\Link\CrmDealLink
;
7
use
Bitrix\Calendar\Sharing
;
8
9
abstract
class
Service
10
{
11
protected
Event
$event
;
12
protected
EventLink
$eventLink
;
13
protected
CrmDealLink
$crmDealLink
;
14
protected
?
Event
$oldEvent
=
null
;
15
private
?array $owner =
null
;
16
20
public
function
getEvent
():
Event
21
{
22
return
$this->event;
23
}
24
29
public
function
setEvent
(
Event
$event): self
30
{
31
$this->
event
= $event;
32
33
return
$this;
34
}
35
39
public
function
getEventLink
():
EventLink
40
{
41
return
$this->eventLink;
42
}
43
48
public
function
setEventLink
(
EventLink
$eventLink): self
49
{
50
$this->eventLink = $eventLink;
51
52
return
$this;
53
}
54
59
public
function
setCrmDealLink
(
CrmDealLink
$crmDealLink): self
60
{
61
$this->crmDealLink = $crmDealLink;
62
63
return
$this;
64
}
65
70
public
function
setOldEvent
(
Event
$oldEvent): self
71
{
72
$this->oldEvent = $oldEvent;
73
74
return
$this;
75
}
76
80
protected
function
getEventFormattedDateTime
(): string
81
{
82
$from = $this->
event
->getStart();
83
$to = $this->
event
->getEnd();
84
$isFullDay = $this->
event
->isFullDayEvent();
85
return
Sharing\Helper::formatTimeInterval($from, $to, $isFullDay);
86
}
87
91
protected
function
getOwner
(): array
92
{
93
if
(is_array($this->owner))
94
{
95
return
$this->owner;
96
}
97
98
$ownerId = $this->eventLink->getOwnerId();
99
$info = Sharing\Helper::getOwnerInfo($ownerId);
100
$ownerAttendee = current(array_filter($this->
getAttendeesList
(),
static
function
($att) use ($ownerId) {
101
return
$att[
'id'
] === $ownerId;
102
}));
103
104
if
(isset($ownerAttendee[
'status'
]) && !in_array($ownerAttendee[
'status'
], [
'Q'
,
'Y'
,
'N'
],
true
))
105
{
106
$ownerAttendee[
'status'
] =
'Q'
;
107
}
108
109
$this->owner = [
110
'ID'
=> $ownerId,
111
'NAME'
=>
"{$info['name']} {$info['lastName']}"
,
112
'PHOTO'
=> $info[
'photo'
],
113
'GENDER'
=> $info[
'gender'
],
114
'STATUS'
=> $ownerAttendee[
'status'
] ??
'Q'
,
115
];
116
117
return
$this->owner;
118
}
119
123
protected
function
getCalendarLink
(): ?string
124
{
125
if
($this->eventLink->getParentLinkHash())
126
{
127
$sharingLinkFactory =
new
Sharing\Link\Factory
();
128
$userLink = $sharingLinkFactory->getLinkByHash($this->eventLink->getParentLinkHash());
129
if
($userLink)
130
{
131
return
$userLink->getUrl();
132
}
133
}
134
return
null
;
135
}
136
140
protected
function
getAttendeesList
(): array
141
{
142
return \CCalendarEvent::getAttendeeList($this->event->getId())[
'attendeeList'
][$this->
event
->getId()];
143
}
144
150
abstract
public
function
notifyAboutMeetingStatus
(
string
$to): bool;
151
156
abstract
public
function
notifyAboutSharingEventEdit
(
string
$to): bool;
157
}
Bitrix\Calendar\Core\Event\Event
Definition
event.php:20
Bitrix\Calendar\Core\Mappers\Factory
Definition
factory.php:6
Bitrix\Calendar\Sharing\Link\CrmDealLink
Definition
crmdeallink.php:8
Bitrix\Calendar\Sharing\Link\EventLink
Definition
eventlink.php:5
Bitrix\Calendar\Sharing\Notification\Service
Definition
service.php:10
Bitrix\Calendar\Sharing\Notification\Service\getEvent
getEvent()
Definition
service.php:20
Bitrix\Calendar\Sharing\Notification\Service\$oldEvent
Event $oldEvent
Definition
service.php:14
Bitrix\Calendar\Sharing\Notification\Service\setCrmDealLink
setCrmDealLink(CrmDealLink $crmDealLink)
Definition
service.php:59
Bitrix\Calendar\Sharing\Notification\Service\getAttendeesList
getAttendeesList()
Definition
service.php:140
Bitrix\Calendar\Sharing\Notification\Service\$event
Event $event
Definition
service.php:11
Bitrix\Calendar\Sharing\Notification\Service\setOldEvent
setOldEvent(Event $oldEvent)
Definition
service.php:70
Bitrix\Calendar\Sharing\Notification\Service\$crmDealLink
CrmDealLink $crmDealLink
Definition
service.php:13
Bitrix\Calendar\Sharing\Notification\Service\getCalendarLink
getCalendarLink()
Definition
service.php:123
Bitrix\Calendar\Sharing\Notification\Service\getEventFormattedDateTime
getEventFormattedDateTime()
Definition
service.php:80
Bitrix\Calendar\Sharing\Notification\Service\setEventLink
setEventLink(EventLink $eventLink)
Definition
service.php:48
Bitrix\Calendar\Sharing\Notification\Service\setEvent
setEvent(Event $event)
Definition
service.php:29
Bitrix\Calendar\Sharing\Notification\Service\notifyAboutSharingEventEdit
notifyAboutSharingEventEdit(string $to)
Bitrix\Calendar\Sharing\Notification\Service\notifyAboutMeetingStatus
notifyAboutMeetingStatus(string $to)
Bitrix\Calendar\Sharing\Notification\Service\getEventLink
getEventLink()
Definition
service.php:39
Bitrix\Calendar\Sharing\Notification\Service\getOwner
getOwner()
Definition
service.php:91
Bitrix\Calendar\Sharing\Notification\Service\$eventLink
EventLink $eventLink
Definition
service.php:12
Bitrix\Calendar\Sharing\Notification
Definition
mail.php:2
Bitrix\Calendar\Sharing
Definition
analytics.php:3
modules
calendar
lib
sharing
notification
service.php
Создано системой
1.10.0