1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
publicevent.php
См. документацию.
1<?php
2namespace Bitrix\Calendar\Controller;
3
4use Bitrix\Calendar\Core\Event\Event;
5use Bitrix\Calendar\ICal\IcsManager;
6use Bitrix\Calendar\ICal\MailInvitation\AttachmentEditManager;
7use Bitrix\Calendar\ICal\MailInvitation\Helper;
8use Bitrix\Calendar\Public;
9use Bitrix\Calendar\Core\Mappers;
10use Bitrix\Main\Error;
11use Bitrix\Main\Localization\Loc;
12use Bitrix\Main\Engine\ActionFilter;
13
14Loc::loadMessages(__FILE__);
15
17{
18 protected ?Event $event;
19
20 public function configureActions(): array
21 {
22 return [
23 'handleDecision' => [
24 '-prefilters' => [
25 ActionFilter\Authentication::class,
26 ActionFilter\Csrf::class
27 ],
28 '+postfilters' => [
30 ],
31 ],
32 'getIcsFileContent' => [
33 '-prefilters' => [
34 ActionFilter\Authentication::class,
35 ActionFilter\Csrf::class
36 ],
37 '+postfilters' => [
39 ],
40 ],
41 ];
42 }
43
44 public function handleDecisionAction(int $eventId, string $hash, string $decision): string
45 {
46 $this->event = (new Mappers\Event())->getById($eventId);
47
48 if ($this->event === null || !Public\PublicEvent::isHashValid($this->event, $hash))
49 {
50 $this->addError(new Error('Event not found'));
51
52 return '';
53 }
54
55 $status = $decision === 'Y' ? 'Y' : 'N';
56 if ($this->event->getMeetingStatus() === $decision)
57 {
58 return $status;
59 }
60
61 \CCalendarEvent::SetMeetingStatus(
62 [
63 'userId' => $this->event->getOwner()->getId(),
64 'eventId' => $this->event->getId(),
65 'status' => $status,
66 'personalNotification' => true,
67 ],
68 );
69
70 return $status;
71 }
72
73 public function getIcsFileContentAction(int $eventId, string $hash): string
74 {
75 $this->event = (new Mappers\Event())->getById($eventId);
76 if (!$this->event || !Public\PublicEvent::isHashValid($this->event, $hash))
77 {
78 $this->addError(new Error('Event not found'));
79
80 return '';
81 }
82
83 $detailLink = Public\PublicEvent::getDetailLinkFromEvent($this->event);
84 if ($detailLink === null)
85 {
86 $this->addError(new Error('Event doesnt have owner or date'));
87
88 return '';
89 }
90
91 if ($this->event->getMeetingDescription()?->getHideGuests())
92 {
93 $this->event->setAttendeesCollection(null);
94 }
95
96 $descriptionParams = [
97 'eventUrl' => $detailLink,
98 ];
99
100 $attachmentManager = new AttachmentEditManager($this->getEventArrayForIcs($descriptionParams));
101 if (!$attachmentManager->getUid())
102 {
103 return IcsManager::getInstance()->getIcsFileContent($this->event, $descriptionParams);
104 }
105
106 return $attachmentManager->getContent();
107 }
108
109 private function getEventArrayForIcs(array $descriptionParams): array
110 {
111 $parentId = $this->event->getParentId();
112 $eventArray = (new Mappers\Event())->convertToArray($this->event);
113 $description = IcsManager::getInstance()->prepareEventDescription($this->event, $descriptionParams);
114 $eventArray['DESCRIPTION'] = str_replace("\\n", "\n", $description);
115 $eventArray['ICAL_ORGANIZER'] = Helper::getAttendee($eventArray['MEETING_HOST'], $parentId, false);
116 if (!$this->event->getMeetingDescription()?->getHideGuests())
117 {
118 $eventArray['ICAL_ATTENDEES'] = Helper::getAttendeesByEventParentId($parentId);
119 }
120
121 $eventArray['ICAL_ATTACHES'] = Helper::getMailAttaches(null, $eventArray['MEETING_HOST'], $parentId);
122
123 return $eventArray;
124 }
125}
$hash
Определения ajax_redirector.php:8
getIcsFileContentAction(int $eventId, string $hash)
Определения publicevent.php:73
handleDecisionAction(int $eventId, string $hash, string $decision)
Определения publicevent.php:44
static getDetailLinkFromEvent(Event $event)
Определения publicevent.php:38
addError(Error $error)
Определения controller.php:1070
Определения error.php:15
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
Определения file_new.php:804
if(Loader::includeModule( 'bitrix24')) elseif(Loader::includeModule('intranet') &&CIntranetUtils::getPortalZone() !=='ru') $description
Определения .description.php:24
$status
Определения session.php:10