Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
sendereditinvitation.php
1<?php
2
3
5
10
12{
13 public const METHOD = 'edit';
14 public const DECISION_CHANGE = 'C';
18 private $changeFields;
19
20
24 public function executeAfterSuccessfulInvitation(): void
25 {
26 }
27
32 protected function getContent(): array
33 {
34 $attachmentManager = new AttachmentEditManager($this->event);
35 $this->uid = $attachmentManager->getUid();
36
37 if (!$this->uid)
38 {
39 return [];
40 }
41
42 return [[
43 'CONTENT' => Encoding::convertEncoding($attachmentManager->getContent(), SITE_CHARSET, "utf-8"),
44 'CONTENT_TYPE' => self::CONTENT_TYPE,
45 'METHOD' => mb_strtolower(self::METHOD),
46 'CHARSET' => self::CHARSET,
47 'NAME' => self::ATTACHMENT_NAME,
48 'ID' => Helper::getUniqId(),
49 ]];
50 }
51
56 protected function getMailEventField(): array
57 {
58 return [
59 "=Reply-To" => "{$this->context->getAddresser()->getFullName()} <{$this->context->getAddresser()->getEmail()}>",
60 "=From" => "{$this->context->getAddresser()->getFullName()} <{$this->context->getAddresser()->getEmail()}>",
61 "=Message-Id" => $this->getMessageId(),
62 "=In-Reply-To" => $this->getMessageReplyTo(),
63 'EMAIL_FROM' => $this->context->getAddresser()->getEmail(),
64 'EMAIL_TO' => $this->context->getReceiver()->getEmail(),
65 'MESSAGE_SUBJECT' => $this->getSubjectMessage(),
66 'MESSAGE_PHP' => $this->getBodyMessage(),
67 'CONFIRM_CODE' => 'TRUE',
68 'NAME' => $this->event['NAME'],
69 'METHOD' => self::METHOD,
70 'CHANGE_FIELDS_TITLE' => $this->getChangeFieldsTitle(),
71 'DETAIL_LINK' => Helper::getDetailLink(
72 $this->getEventId(),
73 $this->getEventOwnerId(),
75 ),
76 'DECISION_YES_LINK' => Helper::getPubEventLinkWithParameters(
77 $this->getEventId(),
78 $this->getEventOwnerId(),
80 self::DECISION_YES
81 ),
82 'DECISION_NO_LINK' => Helper::getPubEventLinkWithParameters(
83 $this->getEventId(),
84 $this->getEventOwnerId(),
86 self::DECISION_NO
87 ),
88 'CHANGE_DECISION_LINK' => Helper::getPubEventLinkWithParameters(
89 $this->getEventId(),
90 $this->getEventOwnerId(),
92 self::DECISION_CHANGE
93 ),
94 'REQUEST_DECISION' => $this->event['MEETING']['REINVITE'] ? 'Y' : 'N',
95 'DATE_FROM' => $this->event['DATE_FROM'],
96 'DATE_TO' => $this->event['DATE_TO'],
97 'TZ_FROM' => $this->event['TZ_FROM'],
98 'TZ_TO' => $this->event['TZ_TO'],
99 'FULL_DAY' => $this->event['SKIP_TIME'] ? 'Y' : 'N',
100 'CHANGE_FIELDS' => $this->getChangeFieldsString(),
101 ];
102 }
103
107 protected function getMessageReplyTo(): string
108 {
109 return $this->getMessageId();
110 }
111
115 protected function getChangeFieldsTitle(): string
116 {
117 $fields = $this->context->getChangeFields();
118 if (count($fields) === 1)
119 {
120 switch ($fields[0]['fieldKey'])
121 {
122 case 'DATE_FROM':
123 return Loc::getMessage('EC_CALENDAR_ICAL_MAIL_CHANGE_FIELD_TITLE_DATE');
124 case 'LOCATION':
125 return Loc::getMessage('EC_CALENDAR_ICAL_MAIL_CHANGE_FIELD_TITLE_LOCATION');
126 case 'ATTENDEES':
127 return Loc::getMessage('EC_CALENDAR_ICAL_MAIL_CHANGE_FIELD_TITLE_ATTENDEES');
128 case 'RRULE':
129 return Loc::getMessage('EC_CALENDAR_ICAL_MAIL_CHANGE_FIELD_TITLE_RRULE');
130 case 'NAME':
131 return Loc::getMessage('EC_CALENDAR_ICAL_MAIL_CHANGE_FIELD_TITLE_NAME');
132 default:
133 return Loc::getMessage('EC_CALENDAR_ICAL_MAIL_METHOD_EDIT');
134 }
135 }
136
137 return Loc::getMessage('EC_CALENDAR_ICAL_MAIL_METHOD_EDIT');
138 }
139
143 protected function getSubjectTitle(): string
144 {
145 if (Loader::includeModule('bitrix24') && \CBitrix24::isFreeLicense())
146 {
147 return Loc::getMessage("EC_CALENDAR_ICAL_MAIL_METHOD_EDIT");
148 }
149
150 return Loc::getMessage("EC_CALENDAR_ICAL_MAIL_METHOD_EDIT") . ": {$this->event['NAME']}";
151 }
152
153 protected function getChangeFieldsString(): string
154 {
155 $res = [];
156 if (count($this->context->getChangeFields()) > 0)
157 {
158 foreach ($this->context->getChangeFields() as $changeField)
159 {
160 $res[] = $changeField['fieldKey'];
161 }
162 }
163 return implode(';', $res);
164 }
165}
static getDetailLink(int $eventId, int $userId, int $dateCreateTimestamp)
Definition helper.php:335
static getPubEventLinkWithParameters(int $eventId, int $userId, int $dateCreateTimestamp, string $decision)
Definition helper.php:347
static getMessage($code, $replace=null, $language=null)
Definition loc.php:29