1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/* |
4
|
|
|
* SPDX-License-Identifier: AGPL-3.0-only |
5
|
|
|
* SPDX-FileCopyrightText: Copyright 2007-2016 Zarafa Deutschland GmbH |
6
|
|
|
* SPDX-FileCopyrightText: Copyright 2020-2022 grommunio GmbH |
7
|
|
|
* |
8
|
|
|
* Provides the MEETINGRESPONSE command |
9
|
|
|
*/ |
10
|
|
|
|
11
|
|
|
class MeetingResponse extends RequestProcessor { |
12
|
|
|
/** |
13
|
|
|
* Handles the MeetingResponse command. |
14
|
|
|
* |
15
|
|
|
* @param int $commandCode |
16
|
|
|
* |
17
|
|
|
* @return bool |
18
|
|
|
*/ |
19
|
|
|
public function Handle($commandCode) { |
20
|
|
|
$requests = []; |
21
|
|
|
|
22
|
|
|
if (!self::$decoder->getElementStartTag(SYNC_MEETINGRESPONSE_MEETINGRESPONSE)) { |
23
|
|
|
return false; |
24
|
|
|
} |
25
|
|
|
|
26
|
|
|
while (self::$decoder->getElementStartTag(SYNC_MEETINGRESPONSE_REQUEST)) { |
27
|
|
|
$req = []; |
28
|
|
|
WBXMLDecoder::ResetInWhile("meetingResponseRequest"); |
29
|
|
|
while (WBXMLDecoder::InWhile("meetingResponseRequest")) { |
30
|
|
|
if (self::$decoder->getElementStartTag(SYNC_MEETINGRESPONSE_USERRESPONSE)) { |
31
|
|
|
$req["response"] = self::$decoder->getElementContent(); |
32
|
|
|
if (!self::$decoder->getElementEndTag()) { |
33
|
|
|
return false; |
34
|
|
|
} |
35
|
|
|
} |
36
|
|
|
|
37
|
|
|
if (self::$decoder->getElementStartTag(SYNC_MEETINGRESPONSE_FOLDERID)) { |
38
|
|
|
$req["folderid"] = self::$decoder->getElementContent(); |
39
|
|
|
if (!self::$decoder->getElementEndTag()) { |
40
|
|
|
return false; |
41
|
|
|
} |
42
|
|
|
} |
43
|
|
|
|
44
|
|
|
if (self::$decoder->getElementStartTag(SYNC_MEETINGRESPONSE_REQUESTID)) { |
45
|
|
|
$req["requestid"] = self::$decoder->getElementContent(); |
46
|
|
|
if (!self::$decoder->getElementEndTag()) { |
47
|
|
|
return false; |
48
|
|
|
} |
49
|
|
|
} |
50
|
|
|
|
51
|
|
|
if (self::$decoder->getElementStartTag(SYNC_MEETINGRESPONSE_INSTANCEID)) { |
52
|
|
|
$req["instanceid"] = self::$decoder->getElementContent(); |
53
|
|
|
if (!self::$decoder->getElementEndTag()) { |
54
|
|
|
return false; |
55
|
|
|
} |
56
|
|
|
} |
57
|
|
|
|
58
|
|
|
if (self::$decoder->getElementStartTag(SYNC_MEETINGRESPONSE_SENDRESPONSE)) { |
59
|
|
|
if (self::$decoder->getElementStartTag(SYNC_AIRSYNCBASE_BODY)) { |
60
|
|
|
if (self::$decoder->getElementStartTag(SYNC_AIRSYNCBASE_TYPE)) { |
61
|
|
|
$req["bodytype"] = self::$decoder->getElementContent(); |
62
|
|
|
if (!self::$decoder->getElementEndTag()) { |
63
|
|
|
return false; |
64
|
|
|
} |
65
|
|
|
} |
66
|
|
|
if (self::$decoder->getElementStartTag(SYNC_AIRSYNCBASE_DATA)) { |
67
|
|
|
$req["body"] = self::$decoder->getElementContent(); |
68
|
|
|
if (!self::$decoder->getElementEndTag()) { |
69
|
|
|
return false; |
70
|
|
|
} |
71
|
|
|
} |
72
|
|
|
if (!self::$decoder->getElementEndTag()) { |
73
|
|
|
return false; |
74
|
|
|
} |
75
|
|
|
} // end body |
76
|
|
|
if (self::$decoder->getElementStartTag(SYNC_MEETINGRESPONSE_PROPOSEDSTARTTIME)) { |
77
|
|
|
$req["proposedstarttime"] = self::$decoder->getElementContent(); |
78
|
|
|
if (!self::$decoder->getElementEndTag()) { |
79
|
|
|
return false; |
80
|
|
|
} |
81
|
|
|
} |
82
|
|
|
if (self::$decoder->getElementStartTag(SYNC_MEETINGRESPONSE_PROPOSEDENDTIME)) { |
83
|
|
|
$req["proposedendtime"] = self::$decoder->getElementContent(); |
84
|
|
|
if (!self::$decoder->getElementEndTag()) { |
85
|
|
|
return false; |
86
|
|
|
} |
87
|
|
|
} |
88
|
|
|
} // end send response |
89
|
|
|
|
90
|
|
|
$e = self::$decoder->peek(); |
91
|
|
|
if ($e[EN_TYPE] == EN_TYPE_ENDTAG) { |
92
|
|
|
self::$decoder->getElementEndTag(); |
93
|
|
|
|
94
|
|
|
break; |
95
|
|
|
} |
96
|
|
|
} |
97
|
|
|
array_push($requests, $req); |
98
|
|
|
} |
99
|
|
|
|
100
|
|
|
if (!self::$decoder->getElementEndTag()) { |
101
|
|
|
return false; |
102
|
|
|
} |
103
|
|
|
|
104
|
|
|
// output the error code, plus the ID of the calendar item that was generated by the |
105
|
|
|
// accept of the meeting response |
106
|
|
|
self::$encoder->StartWBXML(); |
107
|
|
|
self::$encoder->startTag(SYNC_MEETINGRESPONSE_MEETINGRESPONSE); |
108
|
|
|
|
109
|
|
|
foreach ($requests as $req) { |
110
|
|
|
$status = SYNC_MEETRESPSTATUS_SUCCESS; |
111
|
|
|
|
112
|
|
|
try { |
113
|
|
|
$backendFolderId = self::$deviceManager->GetBackendIdForFolderId($req["folderid"]); |
114
|
|
|
|
115
|
|
|
// if the source folder is an additional folder the backend has to be setup correctly |
116
|
|
|
if (!self::$backend->Setup(GSync::GetAdditionalSyncFolderStore($backendFolderId))) { |
117
|
|
|
throw new StatusException(sprintf("HandleMoveItems() could not Setup() the backend for folder id %s/%s", $req["folderid"], $backendFolderId), SYNC_MEETRESPSTATUS_SERVERERROR); |
118
|
|
|
} |
119
|
|
|
|
120
|
|
|
$calendarid = self::$backend->MeetingResponse($backendFolderId, $req); |
121
|
|
|
if ($calendarid === false) { |
122
|
|
|
throw new StatusException("HandleMeetingResponse() not possible", SYNC_MEETRESPSTATUS_SERVERERROR); |
123
|
|
|
} |
124
|
|
|
} |
125
|
|
|
catch (StatusException $stex) { |
126
|
|
|
$status = $stex->getCode(); |
127
|
|
|
} |
128
|
|
|
|
129
|
|
|
self::$encoder->startTag(SYNC_MEETINGRESPONSE_RESULT); |
130
|
|
|
self::$encoder->startTag(SYNC_MEETINGRESPONSE_REQUESTID); |
131
|
|
|
self::$encoder->content($req["requestid"]); |
132
|
|
|
self::$encoder->endTag(); |
133
|
|
|
|
134
|
|
|
self::$encoder->startTag(SYNC_MEETINGRESPONSE_STATUS); |
135
|
|
|
self::$encoder->content($status); |
136
|
|
|
self::$encoder->endTag(); |
137
|
|
|
|
138
|
|
|
if ($status == SYNC_MEETRESPSTATUS_SUCCESS && !empty($calendarid)) { |
139
|
|
|
self::$encoder->startTag(SYNC_MEETINGRESPONSE_CALENDARID); |
140
|
|
|
self::$encoder->content($calendarid); |
141
|
|
|
self::$encoder->endTag(); |
142
|
|
|
} |
143
|
|
|
self::$encoder->endTag(); |
144
|
|
|
self::$topCollector->AnnounceInformation(sprintf("Operation status %d", $status), true); |
145
|
|
|
} |
146
|
|
|
self::$encoder->endTag(); |
147
|
|
|
|
148
|
|
|
return true; |
149
|
|
|
} |
150
|
|
|
} |
151
|
|
|
|