Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
icalmailmanager.php
1<?php
2
3
5
13
14Loader::includeModule('calendar');
15
17{
18 public const CONTENT_TYPES = ['application/ics', 'text/calendar'];
19
20 public static function manageRequest($params): void
21 {
23 }
24
25 public static function handleReply(Calendar $icalComponent): bool
26 {
28 ->handle()
29 ->isSuccess();
30 }
31
36 public static function parseRequest(string $content): ?Calendar
37 {
38 return InboxManager::createInstance($content)
39 ->parseContent()
40 ->getComponent();
41 }
42
43 public static function parseFile($fileId)
44 {
45 $data = ICalMailManager::getFileContent($fileId);
46
47 if (!empty($data))
48 {
50 }
51
52 return null;
53 }
54
55 public static function getFileContent($fileId)
56 {
57 $fileArray = \CFile::makeFileArray($fileId);
58 if (!empty($fileArray))
59 {
60 return \Bitrix\Main\IO\File::getFileContents($fileArray['tmp_name']);
61 }
62
63 return null;
64 }
65
66 public static function hasICalAttachments(array $attachments)
67 {
68 foreach ($attachments as $item)
69 {
70 if (in_array($item['CONTENT-TYPE'], ICalMailManager::CONTENT_TYPES))
71 {
72 return true;
73 }
74 }
75
76 return false;
77 }
78
79 public static function handleRequest(
80 Calendar $icalComponent,
81 int $userId,
82 string $decision,
83 $message
84 )
85 {
86 $handler = IncomingInvitationRequestHandler::createInstance();
87 $handler->setIcalComponent($icalComponent)
88 ->setUserId($userId)
89 ->setDecision($decision)
90 ->setEmailFrom($message['FIELD_TO'])
91 ->setEmailTo($message['FIELD_FROM'])
92 ->handle()
93 ;
94
95 return $handler->getEventId();
96 }
97
98 public static function handleCancel(Calendar $icalComponent, $userId)
99 {
100 return IncomingInvitationCancelHandler::createWithComponent($userId, $icalComponent)
101 ->handle();
102 }
103}
static handleRequest(Calendar $icalComponent, int $userId, string $decision, $message)
static handleCancel(Calendar $icalComponent, $userId)