@@ -21,55 +21,55 @@ |
||
21 | 21 | */ |
22 | 22 | class CalendarRoot extends \Sabre\DAVACL\AbstractPrincipalCollection |
23 | 23 | { |
24 | - /** |
|
25 | - * CalDAV backend. |
|
26 | - * |
|
27 | - * @var Backend\BackendInterface |
|
28 | - */ |
|
29 | - protected $caldavBackend; |
|
24 | + /** |
|
25 | + * CalDAV backend. |
|
26 | + * |
|
27 | + * @var Backend\BackendInterface |
|
28 | + */ |
|
29 | + protected $caldavBackend; |
|
30 | 30 | |
31 | - /** |
|
32 | - * Constructor. |
|
33 | - * |
|
34 | - * This constructor needs both an authentication and a caldav backend. |
|
35 | - * |
|
36 | - * By default this class will show a list of calendar collections for |
|
37 | - * principals in the 'principals' collection. If your main principals are |
|
38 | - * actually located in a different path, use the $principalPrefix argument |
|
39 | - * to override this. |
|
40 | - * |
|
41 | - * @param string $principalPrefix |
|
42 | - */ |
|
43 | - public function __construct(PrincipalBackend\BackendInterface $principalBackend, Backend\BackendInterface $caldavBackend, $principalPrefix = 'principals') |
|
44 | - { |
|
45 | - parent::__construct($principalBackend, $principalPrefix); |
|
46 | - $this->caldavBackend = $caldavBackend; |
|
47 | - } |
|
31 | + /** |
|
32 | + * Constructor. |
|
33 | + * |
|
34 | + * This constructor needs both an authentication and a caldav backend. |
|
35 | + * |
|
36 | + * By default this class will show a list of calendar collections for |
|
37 | + * principals in the 'principals' collection. If your main principals are |
|
38 | + * actually located in a different path, use the $principalPrefix argument |
|
39 | + * to override this. |
|
40 | + * |
|
41 | + * @param string $principalPrefix |
|
42 | + */ |
|
43 | + public function __construct(PrincipalBackend\BackendInterface $principalBackend, Backend\BackendInterface $caldavBackend, $principalPrefix = 'principals') |
|
44 | + { |
|
45 | + parent::__construct($principalBackend, $principalPrefix); |
|
46 | + $this->caldavBackend = $caldavBackend; |
|
47 | + } |
|
48 | 48 | |
49 | - /** |
|
50 | - * Returns the nodename. |
|
51 | - * |
|
52 | - * We're overriding this, because the default will be the 'principalPrefix', |
|
53 | - * and we want it to be Sabre\CalDAV\Plugin::CALENDAR_ROOT |
|
54 | - * |
|
55 | - * @return string |
|
56 | - */ |
|
57 | - public function getName() |
|
58 | - { |
|
59 | - return Plugin::CALENDAR_ROOT; |
|
60 | - } |
|
49 | + /** |
|
50 | + * Returns the nodename. |
|
51 | + * |
|
52 | + * We're overriding this, because the default will be the 'principalPrefix', |
|
53 | + * and we want it to be Sabre\CalDAV\Plugin::CALENDAR_ROOT |
|
54 | + * |
|
55 | + * @return string |
|
56 | + */ |
|
57 | + public function getName() |
|
58 | + { |
|
59 | + return Plugin::CALENDAR_ROOT; |
|
60 | + } |
|
61 | 61 | |
62 | - /** |
|
63 | - * This method returns a node for a principal. |
|
64 | - * |
|
65 | - * The passed array contains principal information, and is guaranteed to |
|
66 | - * at least contain a uri item. Other properties may or may not be |
|
67 | - * supplied by the authentication backend. |
|
68 | - * |
|
69 | - * @return \Sabre\DAV\INode |
|
70 | - */ |
|
71 | - public function getChildForPrincipal(array $principal) |
|
72 | - { |
|
73 | - return new CalendarHome($this->caldavBackend, $principal); |
|
74 | - } |
|
62 | + /** |
|
63 | + * This method returns a node for a principal. |
|
64 | + * |
|
65 | + * The passed array contains principal information, and is guaranteed to |
|
66 | + * at least contain a uri item. Other properties may or may not be |
|
67 | + * supplied by the authentication backend. |
|
68 | + * |
|
69 | + * @return \Sabre\DAV\INode |
|
70 | + */ |
|
71 | + public function getChildForPrincipal(array $principal) |
|
72 | + { |
|
73 | + return new CalendarHome($this->caldavBackend, $principal); |
|
74 | + } |
|
75 | 75 | } |
@@ -21,88 +21,88 @@ |
||
21 | 21 | */ |
22 | 22 | class Plugin extends ServerPlugin |
23 | 23 | { |
24 | - /** |
|
25 | - * This initializes the plugin. |
|
26 | - * |
|
27 | - * This function is called by Sabre\DAV\Server, after |
|
28 | - * addPlugin is called. |
|
29 | - * |
|
30 | - * This method should set up the required event subscriptions. |
|
31 | - */ |
|
32 | - public function initialize(Server $server) |
|
33 | - { |
|
34 | - $server->resourceTypeMapping['Sabre\\CalDAV\\Subscriptions\\ISubscription'] = |
|
35 | - '{http://calendarserver.org/ns/}subscribed'; |
|
24 | + /** |
|
25 | + * This initializes the plugin. |
|
26 | + * |
|
27 | + * This function is called by Sabre\DAV\Server, after |
|
28 | + * addPlugin is called. |
|
29 | + * |
|
30 | + * This method should set up the required event subscriptions. |
|
31 | + */ |
|
32 | + public function initialize(Server $server) |
|
33 | + { |
|
34 | + $server->resourceTypeMapping['Sabre\\CalDAV\\Subscriptions\\ISubscription'] = |
|
35 | + '{http://calendarserver.org/ns/}subscribed'; |
|
36 | 36 | |
37 | - $server->xml->elementMap['{http://calendarserver.org/ns/}source'] = |
|
38 | - 'Sabre\\DAV\\Xml\\Property\\Href'; |
|
37 | + $server->xml->elementMap['{http://calendarserver.org/ns/}source'] = |
|
38 | + 'Sabre\\DAV\\Xml\\Property\\Href'; |
|
39 | 39 | |
40 | - $server->on('propFind', [$this, 'propFind'], 150); |
|
41 | - } |
|
40 | + $server->on('propFind', [$this, 'propFind'], 150); |
|
41 | + } |
|
42 | 42 | |
43 | - /** |
|
44 | - * This method should return a list of server-features. |
|
45 | - * |
|
46 | - * This is for example 'versioning' and is added to the DAV: header |
|
47 | - * in an OPTIONS response. |
|
48 | - * |
|
49 | - * @return array |
|
50 | - */ |
|
51 | - public function getFeatures() |
|
52 | - { |
|
53 | - return ['calendarserver-subscribed']; |
|
54 | - } |
|
43 | + /** |
|
44 | + * This method should return a list of server-features. |
|
45 | + * |
|
46 | + * This is for example 'versioning' and is added to the DAV: header |
|
47 | + * in an OPTIONS response. |
|
48 | + * |
|
49 | + * @return array |
|
50 | + */ |
|
51 | + public function getFeatures() |
|
52 | + { |
|
53 | + return ['calendarserver-subscribed']; |
|
54 | + } |
|
55 | 55 | |
56 | - /** |
|
57 | - * Triggered after properties have been fetched. |
|
58 | - */ |
|
59 | - public function propFind(PropFind $propFind, INode $node) |
|
60 | - { |
|
61 | - // There's a bunch of properties that must appear as a self-closing |
|
62 | - // xml-element. This event handler ensures that this will be the case. |
|
63 | - $props = [ |
|
64 | - '{http://calendarserver.org/ns/}subscribed-strip-alarms', |
|
65 | - '{http://calendarserver.org/ns/}subscribed-strip-attachments', |
|
66 | - '{http://calendarserver.org/ns/}subscribed-strip-todos', |
|
67 | - ]; |
|
56 | + /** |
|
57 | + * Triggered after properties have been fetched. |
|
58 | + */ |
|
59 | + public function propFind(PropFind $propFind, INode $node) |
|
60 | + { |
|
61 | + // There's a bunch of properties that must appear as a self-closing |
|
62 | + // xml-element. This event handler ensures that this will be the case. |
|
63 | + $props = [ |
|
64 | + '{http://calendarserver.org/ns/}subscribed-strip-alarms', |
|
65 | + '{http://calendarserver.org/ns/}subscribed-strip-attachments', |
|
66 | + '{http://calendarserver.org/ns/}subscribed-strip-todos', |
|
67 | + ]; |
|
68 | 68 | |
69 | - foreach ($props as $prop) { |
|
70 | - if (200 === $propFind->getStatus($prop)) { |
|
71 | - $propFind->set($prop, '', 200); |
|
72 | - } |
|
73 | - } |
|
74 | - } |
|
69 | + foreach ($props as $prop) { |
|
70 | + if (200 === $propFind->getStatus($prop)) { |
|
71 | + $propFind->set($prop, '', 200); |
|
72 | + } |
|
73 | + } |
|
74 | + } |
|
75 | 75 | |
76 | - /** |
|
77 | - * Returns a plugin name. |
|
78 | - * |
|
79 | - * Using this name other plugins will be able to access other plugins |
|
80 | - * using \Sabre\DAV\Server::getPlugin |
|
81 | - * |
|
82 | - * @return string |
|
83 | - */ |
|
84 | - public function getPluginName() |
|
85 | - { |
|
86 | - return 'subscriptions'; |
|
87 | - } |
|
76 | + /** |
|
77 | + * Returns a plugin name. |
|
78 | + * |
|
79 | + * Using this name other plugins will be able to access other plugins |
|
80 | + * using \Sabre\DAV\Server::getPlugin |
|
81 | + * |
|
82 | + * @return string |
|
83 | + */ |
|
84 | + public function getPluginName() |
|
85 | + { |
|
86 | + return 'subscriptions'; |
|
87 | + } |
|
88 | 88 | |
89 | - /** |
|
90 | - * Returns a bunch of meta-data about the plugin. |
|
91 | - * |
|
92 | - * Providing this information is optional, and is mainly displayed by the |
|
93 | - * Browser plugin. |
|
94 | - * |
|
95 | - * The description key in the returned array may contain html and will not |
|
96 | - * be sanitized. |
|
97 | - * |
|
98 | - * @return array |
|
99 | - */ |
|
100 | - public function getPluginInfo() |
|
101 | - { |
|
102 | - return [ |
|
103 | - 'name' => $this->getPluginName(), |
|
104 | - 'description' => 'This plugin allows users to store iCalendar subscriptions in their calendar-home.', |
|
105 | - 'link' => null, |
|
106 | - ]; |
|
107 | - } |
|
89 | + /** |
|
90 | + * Returns a bunch of meta-data about the plugin. |
|
91 | + * |
|
92 | + * Providing this information is optional, and is mainly displayed by the |
|
93 | + * Browser plugin. |
|
94 | + * |
|
95 | + * The description key in the returned array may contain html and will not |
|
96 | + * be sanitized. |
|
97 | + * |
|
98 | + * @return array |
|
99 | + */ |
|
100 | + public function getPluginInfo() |
|
101 | + { |
|
102 | + return [ |
|
103 | + 'name' => $this->getPluginName(), |
|
104 | + 'description' => 'This plugin allows users to store iCalendar subscriptions in their calendar-home.', |
|
105 | + 'link' => null, |
|
106 | + ]; |
|
107 | + } |
|
108 | 108 | } |
@@ -22,183 +22,183 @@ |
||
22 | 22 | */ |
23 | 23 | class Subscription extends Collection implements ISubscription, IACL |
24 | 24 | { |
25 | - use ACLTrait; |
|
26 | - |
|
27 | - /** |
|
28 | - * caldavBackend. |
|
29 | - * |
|
30 | - * @var SubscriptionSupport |
|
31 | - */ |
|
32 | - protected $caldavBackend; |
|
33 | - |
|
34 | - /** |
|
35 | - * subscriptionInfo. |
|
36 | - * |
|
37 | - * @var array |
|
38 | - */ |
|
39 | - protected $subscriptionInfo; |
|
40 | - |
|
41 | - /** |
|
42 | - * Constructor. |
|
43 | - */ |
|
44 | - public function __construct(SubscriptionSupport $caldavBackend, array $subscriptionInfo) |
|
45 | - { |
|
46 | - $this->caldavBackend = $caldavBackend; |
|
47 | - $this->subscriptionInfo = $subscriptionInfo; |
|
48 | - |
|
49 | - $required = [ |
|
50 | - 'id', |
|
51 | - 'uri', |
|
52 | - 'principaluri', |
|
53 | - 'source', |
|
54 | - ]; |
|
55 | - |
|
56 | - foreach ($required as $r) { |
|
57 | - if (!isset($subscriptionInfo[$r])) { |
|
58 | - throw new \InvalidArgumentException('The '.$r.' field is required when creating a subscription node'); |
|
59 | - } |
|
60 | - } |
|
61 | - } |
|
62 | - |
|
63 | - /** |
|
64 | - * Returns the name of the node. |
|
65 | - * |
|
66 | - * This is used to generate the url. |
|
67 | - * |
|
68 | - * @return string |
|
69 | - */ |
|
70 | - public function getName() |
|
71 | - { |
|
72 | - return $this->subscriptionInfo['uri']; |
|
73 | - } |
|
74 | - |
|
75 | - /** |
|
76 | - * Returns the last modification time. |
|
77 | - * |
|
78 | - * @return int|null |
|
79 | - */ |
|
80 | - public function getLastModified() |
|
81 | - { |
|
82 | - if (isset($this->subscriptionInfo['lastmodified'])) { |
|
83 | - return $this->subscriptionInfo['lastmodified']; |
|
84 | - } |
|
85 | - } |
|
86 | - |
|
87 | - /** |
|
88 | - * Deletes the current node. |
|
89 | - */ |
|
90 | - public function delete() |
|
91 | - { |
|
92 | - $this->caldavBackend->deleteSubscription( |
|
93 | - $this->subscriptionInfo['id'] |
|
94 | - ); |
|
95 | - } |
|
96 | - |
|
97 | - /** |
|
98 | - * Returns an array with all the child nodes. |
|
99 | - * |
|
100 | - * @return \Sabre\DAV\INode[] |
|
101 | - */ |
|
102 | - public function getChildren() |
|
103 | - { |
|
104 | - return []; |
|
105 | - } |
|
106 | - |
|
107 | - /** |
|
108 | - * Updates properties on this node. |
|
109 | - * |
|
110 | - * This method received a PropPatch object, which contains all the |
|
111 | - * information about the update. |
|
112 | - * |
|
113 | - * To update specific properties, call the 'handle' method on this object. |
|
114 | - * Read the PropPatch documentation for more information. |
|
115 | - */ |
|
116 | - public function propPatch(PropPatch $propPatch) |
|
117 | - { |
|
118 | - return $this->caldavBackend->updateSubscription( |
|
119 | - $this->subscriptionInfo['id'], |
|
120 | - $propPatch |
|
121 | - ); |
|
122 | - } |
|
123 | - |
|
124 | - /** |
|
125 | - * Returns a list of properties for this nodes. |
|
126 | - * |
|
127 | - * The properties list is a list of propertynames the client requested, |
|
128 | - * encoded in clark-notation {xmlnamespace}tagname. |
|
129 | - * |
|
130 | - * If the array is empty, it means 'all properties' were requested. |
|
131 | - * |
|
132 | - * Note that it's fine to liberally give properties back, instead of |
|
133 | - * conforming to the list of requested properties. |
|
134 | - * The Server class will filter out the extra. |
|
135 | - * |
|
136 | - * @param array $properties |
|
137 | - * |
|
138 | - * @return array |
|
139 | - */ |
|
140 | - public function getProperties($properties) |
|
141 | - { |
|
142 | - $r = []; |
|
143 | - |
|
144 | - foreach ($properties as $prop) { |
|
145 | - switch ($prop) { |
|
146 | - case '{http://calendarserver.org/ns/}source': |
|
147 | - $r[$prop] = new Href($this->subscriptionInfo['source']); |
|
148 | - break; |
|
149 | - default: |
|
150 | - if (array_key_exists($prop, $this->subscriptionInfo)) { |
|
151 | - $r[$prop] = $this->subscriptionInfo[$prop]; |
|
152 | - } |
|
153 | - break; |
|
154 | - } |
|
155 | - } |
|
156 | - |
|
157 | - return $r; |
|
158 | - } |
|
159 | - |
|
160 | - /** |
|
161 | - * Returns the owner principal. |
|
162 | - * |
|
163 | - * This must be a url to a principal, or null if there's no owner |
|
164 | - * |
|
165 | - * @return string|null |
|
166 | - */ |
|
167 | - public function getOwner() |
|
168 | - { |
|
169 | - return $this->subscriptionInfo['principaluri']; |
|
170 | - } |
|
171 | - |
|
172 | - /** |
|
173 | - * Returns a list of ACE's for this node. |
|
174 | - * |
|
175 | - * Each ACE has the following properties: |
|
176 | - * * 'privilege', a string such as {DAV:}read or {DAV:}write. These are |
|
177 | - * currently the only supported privileges |
|
178 | - * * 'principal', a url to the principal who owns the node |
|
179 | - * * 'protected' (optional), indicating that this ACE is not allowed to |
|
180 | - * be updated. |
|
181 | - * |
|
182 | - * @return array |
|
183 | - */ |
|
184 | - public function getACL() |
|
185 | - { |
|
186 | - return [ |
|
187 | - [ |
|
188 | - 'privilege' => '{DAV:}all', |
|
189 | - 'principal' => $this->getOwner(), |
|
190 | - 'protected' => true, |
|
191 | - ], |
|
192 | - [ |
|
193 | - 'privilege' => '{DAV:}all', |
|
194 | - 'principal' => $this->getOwner().'/calendar-proxy-write', |
|
195 | - 'protected' => true, |
|
196 | - ], |
|
197 | - [ |
|
198 | - 'privilege' => '{DAV:}read', |
|
199 | - 'principal' => $this->getOwner().'/calendar-proxy-read', |
|
200 | - 'protected' => true, |
|
201 | - ], |
|
202 | - ]; |
|
203 | - } |
|
25 | + use ACLTrait; |
|
26 | + |
|
27 | + /** |
|
28 | + * caldavBackend. |
|
29 | + * |
|
30 | + * @var SubscriptionSupport |
|
31 | + */ |
|
32 | + protected $caldavBackend; |
|
33 | + |
|
34 | + /** |
|
35 | + * subscriptionInfo. |
|
36 | + * |
|
37 | + * @var array |
|
38 | + */ |
|
39 | + protected $subscriptionInfo; |
|
40 | + |
|
41 | + /** |
|
42 | + * Constructor. |
|
43 | + */ |
|
44 | + public function __construct(SubscriptionSupport $caldavBackend, array $subscriptionInfo) |
|
45 | + { |
|
46 | + $this->caldavBackend = $caldavBackend; |
|
47 | + $this->subscriptionInfo = $subscriptionInfo; |
|
48 | + |
|
49 | + $required = [ |
|
50 | + 'id', |
|
51 | + 'uri', |
|
52 | + 'principaluri', |
|
53 | + 'source', |
|
54 | + ]; |
|
55 | + |
|
56 | + foreach ($required as $r) { |
|
57 | + if (!isset($subscriptionInfo[$r])) { |
|
58 | + throw new \InvalidArgumentException('The '.$r.' field is required when creating a subscription node'); |
|
59 | + } |
|
60 | + } |
|
61 | + } |
|
62 | + |
|
63 | + /** |
|
64 | + * Returns the name of the node. |
|
65 | + * |
|
66 | + * This is used to generate the url. |
|
67 | + * |
|
68 | + * @return string |
|
69 | + */ |
|
70 | + public function getName() |
|
71 | + { |
|
72 | + return $this->subscriptionInfo['uri']; |
|
73 | + } |
|
74 | + |
|
75 | + /** |
|
76 | + * Returns the last modification time. |
|
77 | + * |
|
78 | + * @return int|null |
|
79 | + */ |
|
80 | + public function getLastModified() |
|
81 | + { |
|
82 | + if (isset($this->subscriptionInfo['lastmodified'])) { |
|
83 | + return $this->subscriptionInfo['lastmodified']; |
|
84 | + } |
|
85 | + } |
|
86 | + |
|
87 | + /** |
|
88 | + * Deletes the current node. |
|
89 | + */ |
|
90 | + public function delete() |
|
91 | + { |
|
92 | + $this->caldavBackend->deleteSubscription( |
|
93 | + $this->subscriptionInfo['id'] |
|
94 | + ); |
|
95 | + } |
|
96 | + |
|
97 | + /** |
|
98 | + * Returns an array with all the child nodes. |
|
99 | + * |
|
100 | + * @return \Sabre\DAV\INode[] |
|
101 | + */ |
|
102 | + public function getChildren() |
|
103 | + { |
|
104 | + return []; |
|
105 | + } |
|
106 | + |
|
107 | + /** |
|
108 | + * Updates properties on this node. |
|
109 | + * |
|
110 | + * This method received a PropPatch object, which contains all the |
|
111 | + * information about the update. |
|
112 | + * |
|
113 | + * To update specific properties, call the 'handle' method on this object. |
|
114 | + * Read the PropPatch documentation for more information. |
|
115 | + */ |
|
116 | + public function propPatch(PropPatch $propPatch) |
|
117 | + { |
|
118 | + return $this->caldavBackend->updateSubscription( |
|
119 | + $this->subscriptionInfo['id'], |
|
120 | + $propPatch |
|
121 | + ); |
|
122 | + } |
|
123 | + |
|
124 | + /** |
|
125 | + * Returns a list of properties for this nodes. |
|
126 | + * |
|
127 | + * The properties list is a list of propertynames the client requested, |
|
128 | + * encoded in clark-notation {xmlnamespace}tagname. |
|
129 | + * |
|
130 | + * If the array is empty, it means 'all properties' were requested. |
|
131 | + * |
|
132 | + * Note that it's fine to liberally give properties back, instead of |
|
133 | + * conforming to the list of requested properties. |
|
134 | + * The Server class will filter out the extra. |
|
135 | + * |
|
136 | + * @param array $properties |
|
137 | + * |
|
138 | + * @return array |
|
139 | + */ |
|
140 | + public function getProperties($properties) |
|
141 | + { |
|
142 | + $r = []; |
|
143 | + |
|
144 | + foreach ($properties as $prop) { |
|
145 | + switch ($prop) { |
|
146 | + case '{http://calendarserver.org/ns/}source': |
|
147 | + $r[$prop] = new Href($this->subscriptionInfo['source']); |
|
148 | + break; |
|
149 | + default: |
|
150 | + if (array_key_exists($prop, $this->subscriptionInfo)) { |
|
151 | + $r[$prop] = $this->subscriptionInfo[$prop]; |
|
152 | + } |
|
153 | + break; |
|
154 | + } |
|
155 | + } |
|
156 | + |
|
157 | + return $r; |
|
158 | + } |
|
159 | + |
|
160 | + /** |
|
161 | + * Returns the owner principal. |
|
162 | + * |
|
163 | + * This must be a url to a principal, or null if there's no owner |
|
164 | + * |
|
165 | + * @return string|null |
|
166 | + */ |
|
167 | + public function getOwner() |
|
168 | + { |
|
169 | + return $this->subscriptionInfo['principaluri']; |
|
170 | + } |
|
171 | + |
|
172 | + /** |
|
173 | + * Returns a list of ACE's for this node. |
|
174 | + * |
|
175 | + * Each ACE has the following properties: |
|
176 | + * * 'privilege', a string such as {DAV:}read or {DAV:}write. These are |
|
177 | + * currently the only supported privileges |
|
178 | + * * 'principal', a url to the principal who owns the node |
|
179 | + * * 'protected' (optional), indicating that this ACE is not allowed to |
|
180 | + * be updated. |
|
181 | + * |
|
182 | + * @return array |
|
183 | + */ |
|
184 | + public function getACL() |
|
185 | + { |
|
186 | + return [ |
|
187 | + [ |
|
188 | + 'privilege' => '{DAV:}all', |
|
189 | + 'principal' => $this->getOwner(), |
|
190 | + 'protected' => true, |
|
191 | + ], |
|
192 | + [ |
|
193 | + 'privilege' => '{DAV:}all', |
|
194 | + 'principal' => $this->getOwner().'/calendar-proxy-write', |
|
195 | + 'protected' => true, |
|
196 | + ], |
|
197 | + [ |
|
198 | + 'privilege' => '{DAV:}read', |
|
199 | + 'principal' => $this->getOwner().'/calendar-proxy-read', |
|
200 | + 'protected' => true, |
|
201 | + ], |
|
202 | + ]; |
|
203 | + } |
|
204 | 204 | } |
@@ -21,270 +21,270 @@ |
||
21 | 21 | */ |
22 | 22 | class Invite implements NotificationInterface |
23 | 23 | { |
24 | - /** |
|
25 | - * A unique id for the message. |
|
26 | - * |
|
27 | - * @var string |
|
28 | - */ |
|
29 | - protected $id; |
|
30 | - |
|
31 | - /** |
|
32 | - * Timestamp of the notification. |
|
33 | - * |
|
34 | - * @var \DateTime |
|
35 | - */ |
|
36 | - protected $dtStamp; |
|
37 | - |
|
38 | - /** |
|
39 | - * A url to the recipient of the notification. This can be an email |
|
40 | - * address (mailto:), or a principal url. |
|
41 | - * |
|
42 | - * @var string |
|
43 | - */ |
|
44 | - protected $href; |
|
45 | - |
|
46 | - /** |
|
47 | - * The type of message, see the SharingPlugin::STATUS_* constants. |
|
48 | - * |
|
49 | - * @var int |
|
50 | - */ |
|
51 | - protected $type; |
|
52 | - |
|
53 | - /** |
|
54 | - * True if access to a calendar is read-only. |
|
55 | - * |
|
56 | - * @var bool |
|
57 | - */ |
|
58 | - protected $readOnly; |
|
59 | - |
|
60 | - /** |
|
61 | - * A url to the shared calendar. |
|
62 | - * |
|
63 | - * @var string |
|
64 | - */ |
|
65 | - protected $hostUrl; |
|
66 | - |
|
67 | - /** |
|
68 | - * Url to the sharer of the calendar. |
|
69 | - * |
|
70 | - * @var string |
|
71 | - */ |
|
72 | - protected $organizer; |
|
73 | - |
|
74 | - /** |
|
75 | - * The name of the sharer. |
|
76 | - * |
|
77 | - * @var string |
|
78 | - */ |
|
79 | - protected $commonName; |
|
80 | - |
|
81 | - /** |
|
82 | - * The name of the sharer. |
|
83 | - * |
|
84 | - * @var string |
|
85 | - */ |
|
86 | - protected $firstName; |
|
87 | - |
|
88 | - /** |
|
89 | - * The name of the sharer. |
|
90 | - * |
|
91 | - * @var string |
|
92 | - */ |
|
93 | - protected $lastName; |
|
94 | - |
|
95 | - /** |
|
96 | - * A description of the share request. |
|
97 | - * |
|
98 | - * @var string |
|
99 | - */ |
|
100 | - protected $summary; |
|
101 | - |
|
102 | - /** |
|
103 | - * The Etag for the notification. |
|
104 | - * |
|
105 | - * @var string |
|
106 | - */ |
|
107 | - protected $etag; |
|
108 | - |
|
109 | - /** |
|
110 | - * The list of supported components. |
|
111 | - * |
|
112 | - * @var CalDAV\Xml\Property\SupportedCalendarComponentSet |
|
113 | - */ |
|
114 | - protected $supportedComponents; |
|
115 | - |
|
116 | - /** |
|
117 | - * Creates the Invite notification. |
|
118 | - * |
|
119 | - * This constructor receives an array with the following elements: |
|
120 | - * |
|
121 | - * * id - A unique id |
|
122 | - * * etag - The etag |
|
123 | - * * dtStamp - A DateTime object with a timestamp for the notification. |
|
124 | - * * type - The type of notification, see SharingPlugin::STATUS_* |
|
125 | - * constants for details. |
|
126 | - * * readOnly - This must be set to true, if this is an invite for |
|
127 | - * read-only access to a calendar. |
|
128 | - * * hostUrl - A url to the shared calendar. |
|
129 | - * * organizer - Url to the sharer principal. |
|
130 | - * * commonName - The real name of the sharer (optional). |
|
131 | - * * firstName - The first name of the sharer (optional). |
|
132 | - * * lastName - The last name of the sharer (optional). |
|
133 | - * * summary - Description of the share, can be the same as the |
|
134 | - * calendar, but may also be modified (optional). |
|
135 | - * * supportedComponents - An instance of |
|
136 | - * Sabre\CalDAV\Property\SupportedCalendarComponentSet. |
|
137 | - * This allows the client to determine which components |
|
138 | - * will be supported in the shared calendar. This is |
|
139 | - * also optional. |
|
140 | - * |
|
141 | - * @param array $values All the options |
|
142 | - */ |
|
143 | - public function __construct(array $values) |
|
144 | - { |
|
145 | - $required = [ |
|
146 | - 'id', |
|
147 | - 'etag', |
|
148 | - 'href', |
|
149 | - 'dtStamp', |
|
150 | - 'type', |
|
151 | - 'readOnly', |
|
152 | - 'hostUrl', |
|
153 | - 'organizer', |
|
154 | - ]; |
|
155 | - foreach ($required as $item) { |
|
156 | - if (!isset($values[$item])) { |
|
157 | - throw new \InvalidArgumentException($item.' is a required constructor option'); |
|
158 | - } |
|
159 | - } |
|
160 | - |
|
161 | - foreach ($values as $key => $value) { |
|
162 | - if (!property_exists($this, $key)) { |
|
163 | - throw new \InvalidArgumentException('Unknown option: '.$key); |
|
164 | - } |
|
165 | - $this->$key = $value; |
|
166 | - } |
|
167 | - } |
|
168 | - |
|
169 | - /** |
|
170 | - * The xmlSerialize method is called during xml writing. |
|
171 | - * |
|
172 | - * Use the $writer argument to write its own xml serialization. |
|
173 | - * |
|
174 | - * An important note: do _not_ create a parent element. Any element |
|
175 | - * implementing XmlSerializable should only ever write what's considered |
|
176 | - * its 'inner xml'. |
|
177 | - * |
|
178 | - * The parent of the current element is responsible for writing a |
|
179 | - * containing element. |
|
180 | - * |
|
181 | - * This allows serializers to be re-used for different element names. |
|
182 | - * |
|
183 | - * If you are opening new elements, you must also close them again. |
|
184 | - */ |
|
185 | - public function xmlSerialize(Writer $writer) |
|
186 | - { |
|
187 | - $writer->writeElement('{'.CalDAV\Plugin::NS_CALENDARSERVER.'}invite-notification'); |
|
188 | - } |
|
189 | - |
|
190 | - /** |
|
191 | - * This method serializes the entire notification, as it is used in the |
|
192 | - * response body. |
|
193 | - */ |
|
194 | - public function xmlSerializeFull(Writer $writer) |
|
195 | - { |
|
196 | - $cs = '{'.CalDAV\Plugin::NS_CALENDARSERVER.'}'; |
|
197 | - |
|
198 | - $this->dtStamp->setTimezone(new \DateTimeZone('GMT')); |
|
199 | - $writer->writeElement($cs.'dtstamp', $this->dtStamp->format('Ymd\\THis\\Z')); |
|
200 | - |
|
201 | - $writer->startElement($cs.'invite-notification'); |
|
202 | - |
|
203 | - $writer->writeElement($cs.'uid', $this->id); |
|
204 | - $writer->writeElement('{DAV:}href', $this->href); |
|
205 | - |
|
206 | - switch ($this->type) { |
|
207 | - case DAV\Sharing\Plugin::INVITE_ACCEPTED: |
|
208 | - $writer->writeElement($cs.'invite-accepted'); |
|
209 | - break; |
|
210 | - case DAV\Sharing\Plugin::INVITE_NORESPONSE: |
|
211 | - $writer->writeElement($cs.'invite-noresponse'); |
|
212 | - break; |
|
213 | - } |
|
214 | - |
|
215 | - $writer->writeElement($cs.'hosturl', [ |
|
216 | - '{DAV:}href' => $writer->contextUri.$this->hostUrl, |
|
217 | - ]); |
|
218 | - |
|
219 | - if ($this->summary) { |
|
220 | - $writer->writeElement($cs.'summary', $this->summary); |
|
221 | - } |
|
222 | - |
|
223 | - $writer->startElement($cs.'access'); |
|
224 | - if ($this->readOnly) { |
|
225 | - $writer->writeElement($cs.'read'); |
|
226 | - } else { |
|
227 | - $writer->writeElement($cs.'read-write'); |
|
228 | - } |
|
229 | - $writer->endElement(); // access |
|
230 | - |
|
231 | - $writer->startElement($cs.'organizer'); |
|
232 | - // If the organizer contains a 'mailto:' part, it means it should be |
|
233 | - // treated as absolute. |
|
234 | - if ('mailto:' === strtolower(substr($this->organizer, 0, 7))) { |
|
235 | - $writer->writeElement('{DAV:}href', $this->organizer); |
|
236 | - } else { |
|
237 | - $writer->writeElement('{DAV:}href', $writer->contextUri.$this->organizer); |
|
238 | - } |
|
239 | - if ($this->commonName) { |
|
240 | - $writer->writeElement($cs.'common-name', $this->commonName); |
|
241 | - } |
|
242 | - if ($this->firstName) { |
|
243 | - $writer->writeElement($cs.'first-name', $this->firstName); |
|
244 | - } |
|
245 | - if ($this->lastName) { |
|
246 | - $writer->writeElement($cs.'last-name', $this->lastName); |
|
247 | - } |
|
248 | - $writer->endElement(); // organizer |
|
249 | - |
|
250 | - if ($this->commonName) { |
|
251 | - $writer->writeElement($cs.'organizer-cn', $this->commonName); |
|
252 | - } |
|
253 | - if ($this->firstName) { |
|
254 | - $writer->writeElement($cs.'organizer-first', $this->firstName); |
|
255 | - } |
|
256 | - if ($this->lastName) { |
|
257 | - $writer->writeElement($cs.'organizer-last', $this->lastName); |
|
258 | - } |
|
259 | - if ($this->supportedComponents) { |
|
260 | - $writer->writeElement('{'.CalDAV\Plugin::NS_CALDAV.'}supported-calendar-component-set', $this->supportedComponents); |
|
261 | - } |
|
262 | - |
|
263 | - $writer->endElement(); // invite-notification |
|
264 | - } |
|
265 | - |
|
266 | - /** |
|
267 | - * Returns a unique id for this notification. |
|
268 | - * |
|
269 | - * This is just the base url. This should generally be some kind of unique |
|
270 | - * id. |
|
271 | - * |
|
272 | - * @return string |
|
273 | - */ |
|
274 | - public function getId() |
|
275 | - { |
|
276 | - return $this->id; |
|
277 | - } |
|
278 | - |
|
279 | - /** |
|
280 | - * Returns the ETag for this notification. |
|
281 | - * |
|
282 | - * The ETag must be surrounded by literal double-quotes. |
|
283 | - * |
|
284 | - * @return string |
|
285 | - */ |
|
286 | - public function getETag() |
|
287 | - { |
|
288 | - return $this->etag; |
|
289 | - } |
|
24 | + /** |
|
25 | + * A unique id for the message. |
|
26 | + * |
|
27 | + * @var string |
|
28 | + */ |
|
29 | + protected $id; |
|
30 | + |
|
31 | + /** |
|
32 | + * Timestamp of the notification. |
|
33 | + * |
|
34 | + * @var \DateTime |
|
35 | + */ |
|
36 | + protected $dtStamp; |
|
37 | + |
|
38 | + /** |
|
39 | + * A url to the recipient of the notification. This can be an email |
|
40 | + * address (mailto:), or a principal url. |
|
41 | + * |
|
42 | + * @var string |
|
43 | + */ |
|
44 | + protected $href; |
|
45 | + |
|
46 | + /** |
|
47 | + * The type of message, see the SharingPlugin::STATUS_* constants. |
|
48 | + * |
|
49 | + * @var int |
|
50 | + */ |
|
51 | + protected $type; |
|
52 | + |
|
53 | + /** |
|
54 | + * True if access to a calendar is read-only. |
|
55 | + * |
|
56 | + * @var bool |
|
57 | + */ |
|
58 | + protected $readOnly; |
|
59 | + |
|
60 | + /** |
|
61 | + * A url to the shared calendar. |
|
62 | + * |
|
63 | + * @var string |
|
64 | + */ |
|
65 | + protected $hostUrl; |
|
66 | + |
|
67 | + /** |
|
68 | + * Url to the sharer of the calendar. |
|
69 | + * |
|
70 | + * @var string |
|
71 | + */ |
|
72 | + protected $organizer; |
|
73 | + |
|
74 | + /** |
|
75 | + * The name of the sharer. |
|
76 | + * |
|
77 | + * @var string |
|
78 | + */ |
|
79 | + protected $commonName; |
|
80 | + |
|
81 | + /** |
|
82 | + * The name of the sharer. |
|
83 | + * |
|
84 | + * @var string |
|
85 | + */ |
|
86 | + protected $firstName; |
|
87 | + |
|
88 | + /** |
|
89 | + * The name of the sharer. |
|
90 | + * |
|
91 | + * @var string |
|
92 | + */ |
|
93 | + protected $lastName; |
|
94 | + |
|
95 | + /** |
|
96 | + * A description of the share request. |
|
97 | + * |
|
98 | + * @var string |
|
99 | + */ |
|
100 | + protected $summary; |
|
101 | + |
|
102 | + /** |
|
103 | + * The Etag for the notification. |
|
104 | + * |
|
105 | + * @var string |
|
106 | + */ |
|
107 | + protected $etag; |
|
108 | + |
|
109 | + /** |
|
110 | + * The list of supported components. |
|
111 | + * |
|
112 | + * @var CalDAV\Xml\Property\SupportedCalendarComponentSet |
|
113 | + */ |
|
114 | + protected $supportedComponents; |
|
115 | + |
|
116 | + /** |
|
117 | + * Creates the Invite notification. |
|
118 | + * |
|
119 | + * This constructor receives an array with the following elements: |
|
120 | + * |
|
121 | + * * id - A unique id |
|
122 | + * * etag - The etag |
|
123 | + * * dtStamp - A DateTime object with a timestamp for the notification. |
|
124 | + * * type - The type of notification, see SharingPlugin::STATUS_* |
|
125 | + * constants for details. |
|
126 | + * * readOnly - This must be set to true, if this is an invite for |
|
127 | + * read-only access to a calendar. |
|
128 | + * * hostUrl - A url to the shared calendar. |
|
129 | + * * organizer - Url to the sharer principal. |
|
130 | + * * commonName - The real name of the sharer (optional). |
|
131 | + * * firstName - The first name of the sharer (optional). |
|
132 | + * * lastName - The last name of the sharer (optional). |
|
133 | + * * summary - Description of the share, can be the same as the |
|
134 | + * calendar, but may also be modified (optional). |
|
135 | + * * supportedComponents - An instance of |
|
136 | + * Sabre\CalDAV\Property\SupportedCalendarComponentSet. |
|
137 | + * This allows the client to determine which components |
|
138 | + * will be supported in the shared calendar. This is |
|
139 | + * also optional. |
|
140 | + * |
|
141 | + * @param array $values All the options |
|
142 | + */ |
|
143 | + public function __construct(array $values) |
|
144 | + { |
|
145 | + $required = [ |
|
146 | + 'id', |
|
147 | + 'etag', |
|
148 | + 'href', |
|
149 | + 'dtStamp', |
|
150 | + 'type', |
|
151 | + 'readOnly', |
|
152 | + 'hostUrl', |
|
153 | + 'organizer', |
|
154 | + ]; |
|
155 | + foreach ($required as $item) { |
|
156 | + if (!isset($values[$item])) { |
|
157 | + throw new \InvalidArgumentException($item.' is a required constructor option'); |
|
158 | + } |
|
159 | + } |
|
160 | + |
|
161 | + foreach ($values as $key => $value) { |
|
162 | + if (!property_exists($this, $key)) { |
|
163 | + throw new \InvalidArgumentException('Unknown option: '.$key); |
|
164 | + } |
|
165 | + $this->$key = $value; |
|
166 | + } |
|
167 | + } |
|
168 | + |
|
169 | + /** |
|
170 | + * The xmlSerialize method is called during xml writing. |
|
171 | + * |
|
172 | + * Use the $writer argument to write its own xml serialization. |
|
173 | + * |
|
174 | + * An important note: do _not_ create a parent element. Any element |
|
175 | + * implementing XmlSerializable should only ever write what's considered |
|
176 | + * its 'inner xml'. |
|
177 | + * |
|
178 | + * The parent of the current element is responsible for writing a |
|
179 | + * containing element. |
|
180 | + * |
|
181 | + * This allows serializers to be re-used for different element names. |
|
182 | + * |
|
183 | + * If you are opening new elements, you must also close them again. |
|
184 | + */ |
|
185 | + public function xmlSerialize(Writer $writer) |
|
186 | + { |
|
187 | + $writer->writeElement('{'.CalDAV\Plugin::NS_CALENDARSERVER.'}invite-notification'); |
|
188 | + } |
|
189 | + |
|
190 | + /** |
|
191 | + * This method serializes the entire notification, as it is used in the |
|
192 | + * response body. |
|
193 | + */ |
|
194 | + public function xmlSerializeFull(Writer $writer) |
|
195 | + { |
|
196 | + $cs = '{'.CalDAV\Plugin::NS_CALENDARSERVER.'}'; |
|
197 | + |
|
198 | + $this->dtStamp->setTimezone(new \DateTimeZone('GMT')); |
|
199 | + $writer->writeElement($cs.'dtstamp', $this->dtStamp->format('Ymd\\THis\\Z')); |
|
200 | + |
|
201 | + $writer->startElement($cs.'invite-notification'); |
|
202 | + |
|
203 | + $writer->writeElement($cs.'uid', $this->id); |
|
204 | + $writer->writeElement('{DAV:}href', $this->href); |
|
205 | + |
|
206 | + switch ($this->type) { |
|
207 | + case DAV\Sharing\Plugin::INVITE_ACCEPTED: |
|
208 | + $writer->writeElement($cs.'invite-accepted'); |
|
209 | + break; |
|
210 | + case DAV\Sharing\Plugin::INVITE_NORESPONSE: |
|
211 | + $writer->writeElement($cs.'invite-noresponse'); |
|
212 | + break; |
|
213 | + } |
|
214 | + |
|
215 | + $writer->writeElement($cs.'hosturl', [ |
|
216 | + '{DAV:}href' => $writer->contextUri.$this->hostUrl, |
|
217 | + ]); |
|
218 | + |
|
219 | + if ($this->summary) { |
|
220 | + $writer->writeElement($cs.'summary', $this->summary); |
|
221 | + } |
|
222 | + |
|
223 | + $writer->startElement($cs.'access'); |
|
224 | + if ($this->readOnly) { |
|
225 | + $writer->writeElement($cs.'read'); |
|
226 | + } else { |
|
227 | + $writer->writeElement($cs.'read-write'); |
|
228 | + } |
|
229 | + $writer->endElement(); // access |
|
230 | + |
|
231 | + $writer->startElement($cs.'organizer'); |
|
232 | + // If the organizer contains a 'mailto:' part, it means it should be |
|
233 | + // treated as absolute. |
|
234 | + if ('mailto:' === strtolower(substr($this->organizer, 0, 7))) { |
|
235 | + $writer->writeElement('{DAV:}href', $this->organizer); |
|
236 | + } else { |
|
237 | + $writer->writeElement('{DAV:}href', $writer->contextUri.$this->organizer); |
|
238 | + } |
|
239 | + if ($this->commonName) { |
|
240 | + $writer->writeElement($cs.'common-name', $this->commonName); |
|
241 | + } |
|
242 | + if ($this->firstName) { |
|
243 | + $writer->writeElement($cs.'first-name', $this->firstName); |
|
244 | + } |
|
245 | + if ($this->lastName) { |
|
246 | + $writer->writeElement($cs.'last-name', $this->lastName); |
|
247 | + } |
|
248 | + $writer->endElement(); // organizer |
|
249 | + |
|
250 | + if ($this->commonName) { |
|
251 | + $writer->writeElement($cs.'organizer-cn', $this->commonName); |
|
252 | + } |
|
253 | + if ($this->firstName) { |
|
254 | + $writer->writeElement($cs.'organizer-first', $this->firstName); |
|
255 | + } |
|
256 | + if ($this->lastName) { |
|
257 | + $writer->writeElement($cs.'organizer-last', $this->lastName); |
|
258 | + } |
|
259 | + if ($this->supportedComponents) { |
|
260 | + $writer->writeElement('{'.CalDAV\Plugin::NS_CALDAV.'}supported-calendar-component-set', $this->supportedComponents); |
|
261 | + } |
|
262 | + |
|
263 | + $writer->endElement(); // invite-notification |
|
264 | + } |
|
265 | + |
|
266 | + /** |
|
267 | + * Returns a unique id for this notification. |
|
268 | + * |
|
269 | + * This is just the base url. This should generally be some kind of unique |
|
270 | + * id. |
|
271 | + * |
|
272 | + * @return string |
|
273 | + */ |
|
274 | + public function getId() |
|
275 | + { |
|
276 | + return $this->id; |
|
277 | + } |
|
278 | + |
|
279 | + /** |
|
280 | + * Returns the ETag for this notification. |
|
281 | + * |
|
282 | + * The ETag must be surrounded by literal double-quotes. |
|
283 | + * |
|
284 | + * @return string |
|
285 | + */ |
|
286 | + public function getETag() |
|
287 | + { |
|
288 | + return $this->etag; |
|
289 | + } |
|
290 | 290 | } |
@@ -19,153 +19,153 @@ |
||
19 | 19 | */ |
20 | 20 | class SystemStatus implements NotificationInterface |
21 | 21 | { |
22 | - const TYPE_LOW = 1; |
|
23 | - const TYPE_MEDIUM = 2; |
|
24 | - const TYPE_HIGH = 3; |
|
25 | - |
|
26 | - /** |
|
27 | - * A unique id. |
|
28 | - * |
|
29 | - * @var string |
|
30 | - */ |
|
31 | - protected $id; |
|
32 | - |
|
33 | - /** |
|
34 | - * The type of alert. This should be one of the TYPE_ constants. |
|
35 | - * |
|
36 | - * @var int |
|
37 | - */ |
|
38 | - protected $type; |
|
39 | - |
|
40 | - /** |
|
41 | - * A human-readable description of the problem. |
|
42 | - * |
|
43 | - * @var string |
|
44 | - */ |
|
45 | - protected $description; |
|
46 | - |
|
47 | - /** |
|
48 | - * A url to a website with more information for the user. |
|
49 | - * |
|
50 | - * @var string |
|
51 | - */ |
|
52 | - protected $href; |
|
53 | - |
|
54 | - /** |
|
55 | - * Notification Etag. |
|
56 | - * |
|
57 | - * @var string |
|
58 | - */ |
|
59 | - protected $etag; |
|
60 | - |
|
61 | - /** |
|
62 | - * Creates the notification. |
|
63 | - * |
|
64 | - * Some kind of unique id should be provided. This is used to generate a |
|
65 | - * url. |
|
66 | - * |
|
67 | - * @param string $id |
|
68 | - * @param string $etag |
|
69 | - * @param int $type |
|
70 | - * @param string $description |
|
71 | - * @param string $href |
|
72 | - */ |
|
73 | - public function __construct($id, $etag, $type = self::TYPE_HIGH, $description = null, $href = null) |
|
74 | - { |
|
75 | - $this->id = $id; |
|
76 | - $this->type = $type; |
|
77 | - $this->description = $description; |
|
78 | - $this->href = $href; |
|
79 | - $this->etag = $etag; |
|
80 | - } |
|
81 | - |
|
82 | - /** |
|
83 | - * The serialize method is called during xml writing. |
|
84 | - * |
|
85 | - * It should use the $writer argument to encode this object into XML. |
|
86 | - * |
|
87 | - * Important note: it is not needed to create the parent element. The |
|
88 | - * parent element is already created, and we only have to worry about |
|
89 | - * attributes, child elements and text (if any). |
|
90 | - * |
|
91 | - * Important note 2: If you are writing any new elements, you are also |
|
92 | - * responsible for closing them. |
|
93 | - */ |
|
94 | - public function xmlSerialize(Writer $writer) |
|
95 | - { |
|
96 | - switch ($this->type) { |
|
97 | - case self::TYPE_LOW: |
|
98 | - $type = 'low'; |
|
99 | - break; |
|
100 | - case self::TYPE_MEDIUM: |
|
101 | - $type = 'medium'; |
|
102 | - break; |
|
103 | - default: |
|
104 | - case self::TYPE_HIGH: |
|
105 | - $type = 'high'; |
|
106 | - break; |
|
107 | - } |
|
108 | - |
|
109 | - $writer->startElement('{'.Plugin::NS_CALENDARSERVER.'}systemstatus'); |
|
110 | - $writer->writeAttribute('type', $type); |
|
111 | - $writer->endElement(); |
|
112 | - } |
|
113 | - |
|
114 | - /** |
|
115 | - * This method serializes the entire notification, as it is used in the |
|
116 | - * response body. |
|
117 | - */ |
|
118 | - public function xmlSerializeFull(Writer $writer) |
|
119 | - { |
|
120 | - $cs = '{'.Plugin::NS_CALENDARSERVER.'}'; |
|
121 | - switch ($this->type) { |
|
122 | - case self::TYPE_LOW: |
|
123 | - $type = 'low'; |
|
124 | - break; |
|
125 | - case self::TYPE_MEDIUM: |
|
126 | - $type = 'medium'; |
|
127 | - break; |
|
128 | - default: |
|
129 | - case self::TYPE_HIGH: |
|
130 | - $type = 'high'; |
|
131 | - break; |
|
132 | - } |
|
133 | - |
|
134 | - $writer->startElement($cs.'systemstatus'); |
|
135 | - $writer->writeAttribute('type', $type); |
|
136 | - |
|
137 | - if ($this->description) { |
|
138 | - $writer->writeElement($cs.'description', $this->description); |
|
139 | - } |
|
140 | - if ($this->href) { |
|
141 | - $writer->writeElement('{DAV:}href', $this->href); |
|
142 | - } |
|
143 | - |
|
144 | - $writer->endElement(); // systemstatus |
|
145 | - } |
|
146 | - |
|
147 | - /** |
|
148 | - * Returns a unique id for this notification. |
|
149 | - * |
|
150 | - * This is just the base url. This should generally be some kind of unique |
|
151 | - * id. |
|
152 | - * |
|
153 | - * @return string |
|
154 | - */ |
|
155 | - public function getId() |
|
156 | - { |
|
157 | - return $this->id; |
|
158 | - } |
|
159 | - |
|
160 | - /* |
|
22 | + const TYPE_LOW = 1; |
|
23 | + const TYPE_MEDIUM = 2; |
|
24 | + const TYPE_HIGH = 3; |
|
25 | + |
|
26 | + /** |
|
27 | + * A unique id. |
|
28 | + * |
|
29 | + * @var string |
|
30 | + */ |
|
31 | + protected $id; |
|
32 | + |
|
33 | + /** |
|
34 | + * The type of alert. This should be one of the TYPE_ constants. |
|
35 | + * |
|
36 | + * @var int |
|
37 | + */ |
|
38 | + protected $type; |
|
39 | + |
|
40 | + /** |
|
41 | + * A human-readable description of the problem. |
|
42 | + * |
|
43 | + * @var string |
|
44 | + */ |
|
45 | + protected $description; |
|
46 | + |
|
47 | + /** |
|
48 | + * A url to a website with more information for the user. |
|
49 | + * |
|
50 | + * @var string |
|
51 | + */ |
|
52 | + protected $href; |
|
53 | + |
|
54 | + /** |
|
55 | + * Notification Etag. |
|
56 | + * |
|
57 | + * @var string |
|
58 | + */ |
|
59 | + protected $etag; |
|
60 | + |
|
61 | + /** |
|
62 | + * Creates the notification. |
|
63 | + * |
|
64 | + * Some kind of unique id should be provided. This is used to generate a |
|
65 | + * url. |
|
66 | + * |
|
67 | + * @param string $id |
|
68 | + * @param string $etag |
|
69 | + * @param int $type |
|
70 | + * @param string $description |
|
71 | + * @param string $href |
|
72 | + */ |
|
73 | + public function __construct($id, $etag, $type = self::TYPE_HIGH, $description = null, $href = null) |
|
74 | + { |
|
75 | + $this->id = $id; |
|
76 | + $this->type = $type; |
|
77 | + $this->description = $description; |
|
78 | + $this->href = $href; |
|
79 | + $this->etag = $etag; |
|
80 | + } |
|
81 | + |
|
82 | + /** |
|
83 | + * The serialize method is called during xml writing. |
|
84 | + * |
|
85 | + * It should use the $writer argument to encode this object into XML. |
|
86 | + * |
|
87 | + * Important note: it is not needed to create the parent element. The |
|
88 | + * parent element is already created, and we only have to worry about |
|
89 | + * attributes, child elements and text (if any). |
|
90 | + * |
|
91 | + * Important note 2: If you are writing any new elements, you are also |
|
92 | + * responsible for closing them. |
|
93 | + */ |
|
94 | + public function xmlSerialize(Writer $writer) |
|
95 | + { |
|
96 | + switch ($this->type) { |
|
97 | + case self::TYPE_LOW: |
|
98 | + $type = 'low'; |
|
99 | + break; |
|
100 | + case self::TYPE_MEDIUM: |
|
101 | + $type = 'medium'; |
|
102 | + break; |
|
103 | + default: |
|
104 | + case self::TYPE_HIGH: |
|
105 | + $type = 'high'; |
|
106 | + break; |
|
107 | + } |
|
108 | + |
|
109 | + $writer->startElement('{'.Plugin::NS_CALENDARSERVER.'}systemstatus'); |
|
110 | + $writer->writeAttribute('type', $type); |
|
111 | + $writer->endElement(); |
|
112 | + } |
|
113 | + |
|
114 | + /** |
|
115 | + * This method serializes the entire notification, as it is used in the |
|
116 | + * response body. |
|
117 | + */ |
|
118 | + public function xmlSerializeFull(Writer $writer) |
|
119 | + { |
|
120 | + $cs = '{'.Plugin::NS_CALENDARSERVER.'}'; |
|
121 | + switch ($this->type) { |
|
122 | + case self::TYPE_LOW: |
|
123 | + $type = 'low'; |
|
124 | + break; |
|
125 | + case self::TYPE_MEDIUM: |
|
126 | + $type = 'medium'; |
|
127 | + break; |
|
128 | + default: |
|
129 | + case self::TYPE_HIGH: |
|
130 | + $type = 'high'; |
|
131 | + break; |
|
132 | + } |
|
133 | + |
|
134 | + $writer->startElement($cs.'systemstatus'); |
|
135 | + $writer->writeAttribute('type', $type); |
|
136 | + |
|
137 | + if ($this->description) { |
|
138 | + $writer->writeElement($cs.'description', $this->description); |
|
139 | + } |
|
140 | + if ($this->href) { |
|
141 | + $writer->writeElement('{DAV:}href', $this->href); |
|
142 | + } |
|
143 | + |
|
144 | + $writer->endElement(); // systemstatus |
|
145 | + } |
|
146 | + |
|
147 | + /** |
|
148 | + * Returns a unique id for this notification. |
|
149 | + * |
|
150 | + * This is just the base url. This should generally be some kind of unique |
|
151 | + * id. |
|
152 | + * |
|
153 | + * @return string |
|
154 | + */ |
|
155 | + public function getId() |
|
156 | + { |
|
157 | + return $this->id; |
|
158 | + } |
|
159 | + |
|
160 | + /* |
|
161 | 161 | * Returns the ETag for this notification. |
162 | 162 | * |
163 | 163 | * The ETag must be surrounded by literal double-quotes. |
164 | 164 | * |
165 | 165 | * @return string |
166 | 166 | */ |
167 | - public function getETag() |
|
168 | - { |
|
169 | - return $this->etag; |
|
170 | - } |
|
167 | + public function getETag() |
|
168 | + { |
|
169 | + return $this->etag; |
|
170 | + } |
|
171 | 171 | } |
@@ -18,182 +18,182 @@ |
||
18 | 18 | */ |
19 | 19 | class InviteReply implements NotificationInterface |
20 | 20 | { |
21 | - /** |
|
22 | - * A unique id for the message. |
|
23 | - * |
|
24 | - * @var string |
|
25 | - */ |
|
26 | - protected $id; |
|
27 | - |
|
28 | - /** |
|
29 | - * Timestamp of the notification. |
|
30 | - * |
|
31 | - * @var \DateTime |
|
32 | - */ |
|
33 | - protected $dtStamp; |
|
34 | - |
|
35 | - /** |
|
36 | - * The unique id of the notification this was a reply to. |
|
37 | - * |
|
38 | - * @var string |
|
39 | - */ |
|
40 | - protected $inReplyTo; |
|
41 | - |
|
42 | - /** |
|
43 | - * A url to the recipient of the original (!) notification. |
|
44 | - * |
|
45 | - * @var string |
|
46 | - */ |
|
47 | - protected $href; |
|
48 | - |
|
49 | - /** |
|
50 | - * The type of message, see the SharingPlugin::STATUS_ constants. |
|
51 | - * |
|
52 | - * @var int |
|
53 | - */ |
|
54 | - protected $type; |
|
55 | - |
|
56 | - /** |
|
57 | - * A url to the shared calendar. |
|
58 | - * |
|
59 | - * @var string |
|
60 | - */ |
|
61 | - protected $hostUrl; |
|
62 | - |
|
63 | - /** |
|
64 | - * A description of the share request. |
|
65 | - * |
|
66 | - * @var string |
|
67 | - */ |
|
68 | - protected $summary; |
|
69 | - |
|
70 | - /** |
|
71 | - * Notification Etag. |
|
72 | - * |
|
73 | - * @var string |
|
74 | - */ |
|
75 | - protected $etag; |
|
76 | - |
|
77 | - /** |
|
78 | - * Creates the Invite Reply Notification. |
|
79 | - * |
|
80 | - * This constructor receives an array with the following elements: |
|
81 | - * |
|
82 | - * * id - A unique id |
|
83 | - * * etag - The etag |
|
84 | - * * dtStamp - A DateTime object with a timestamp for the notification. |
|
85 | - * * inReplyTo - This should refer to the 'id' of the notification |
|
86 | - * this is a reply to. |
|
87 | - * * type - The type of notification, see SharingPlugin::STATUS_* |
|
88 | - * constants for details. |
|
89 | - * * hostUrl - A url to the shared calendar. |
|
90 | - * * summary - Description of the share, can be the same as the |
|
91 | - * calendar, but may also be modified (optional). |
|
92 | - */ |
|
93 | - public function __construct(array $values) |
|
94 | - { |
|
95 | - $required = [ |
|
96 | - 'id', |
|
97 | - 'etag', |
|
98 | - 'href', |
|
99 | - 'dtStamp', |
|
100 | - 'inReplyTo', |
|
101 | - 'type', |
|
102 | - 'hostUrl', |
|
103 | - ]; |
|
104 | - foreach ($required as $item) { |
|
105 | - if (!isset($values[$item])) { |
|
106 | - throw new \InvalidArgumentException($item.' is a required constructor option'); |
|
107 | - } |
|
108 | - } |
|
109 | - |
|
110 | - foreach ($values as $key => $value) { |
|
111 | - if (!property_exists($this, $key)) { |
|
112 | - throw new \InvalidArgumentException('Unknown option: '.$key); |
|
113 | - } |
|
114 | - $this->$key = $value; |
|
115 | - } |
|
116 | - } |
|
117 | - |
|
118 | - /** |
|
119 | - * The xmlSerialize method is called during xml writing. |
|
120 | - * |
|
121 | - * Use the $writer argument to write its own xml serialization. |
|
122 | - * |
|
123 | - * An important note: do _not_ create a parent element. Any element |
|
124 | - * implementing XmlSerializable should only ever write what's considered |
|
125 | - * its 'inner xml'. |
|
126 | - * |
|
127 | - * The parent of the current element is responsible for writing a |
|
128 | - * containing element. |
|
129 | - * |
|
130 | - * This allows serializers to be re-used for different element names. |
|
131 | - * |
|
132 | - * If you are opening new elements, you must also close them again. |
|
133 | - */ |
|
134 | - public function xmlSerialize(Writer $writer) |
|
135 | - { |
|
136 | - $writer->writeElement('{'.CalDAV\Plugin::NS_CALENDARSERVER.'}invite-reply'); |
|
137 | - } |
|
138 | - |
|
139 | - /** |
|
140 | - * This method serializes the entire notification, as it is used in the |
|
141 | - * response body. |
|
142 | - */ |
|
143 | - public function xmlSerializeFull(Writer $writer) |
|
144 | - { |
|
145 | - $cs = '{'.CalDAV\Plugin::NS_CALENDARSERVER.'}'; |
|
146 | - |
|
147 | - $this->dtStamp->setTimezone(new \DateTimeZone('GMT')); |
|
148 | - $writer->writeElement($cs.'dtstamp', $this->dtStamp->format('Ymd\\THis\\Z')); |
|
149 | - |
|
150 | - $writer->startElement($cs.'invite-reply'); |
|
151 | - |
|
152 | - $writer->writeElement($cs.'uid', $this->id); |
|
153 | - $writer->writeElement($cs.'in-reply-to', $this->inReplyTo); |
|
154 | - $writer->writeElement('{DAV:}href', $this->href); |
|
155 | - |
|
156 | - switch ($this->type) { |
|
157 | - case DAV\Sharing\Plugin::INVITE_ACCEPTED: |
|
158 | - $writer->writeElement($cs.'invite-accepted'); |
|
159 | - break; |
|
160 | - case DAV\Sharing\Plugin::INVITE_DECLINED: |
|
161 | - $writer->writeElement($cs.'invite-declined'); |
|
162 | - break; |
|
163 | - } |
|
164 | - |
|
165 | - $writer->writeElement($cs.'hosturl', [ |
|
166 | - '{DAV:}href' => $writer->contextUri.$this->hostUrl, |
|
167 | - ]); |
|
168 | - |
|
169 | - if ($this->summary) { |
|
170 | - $writer->writeElement($cs.'summary', $this->summary); |
|
171 | - } |
|
172 | - $writer->endElement(); // invite-reply |
|
173 | - } |
|
174 | - |
|
175 | - /** |
|
176 | - * Returns a unique id for this notification. |
|
177 | - * |
|
178 | - * This is just the base url. This should generally be some kind of unique |
|
179 | - * id. |
|
180 | - * |
|
181 | - * @return string |
|
182 | - */ |
|
183 | - public function getId() |
|
184 | - { |
|
185 | - return $this->id; |
|
186 | - } |
|
187 | - |
|
188 | - /** |
|
189 | - * Returns the ETag for this notification. |
|
190 | - * |
|
191 | - * The ETag must be surrounded by literal double-quotes. |
|
192 | - * |
|
193 | - * @return string |
|
194 | - */ |
|
195 | - public function getETag() |
|
196 | - { |
|
197 | - return $this->etag; |
|
198 | - } |
|
21 | + /** |
|
22 | + * A unique id for the message. |
|
23 | + * |
|
24 | + * @var string |
|
25 | + */ |
|
26 | + protected $id; |
|
27 | + |
|
28 | + /** |
|
29 | + * Timestamp of the notification. |
|
30 | + * |
|
31 | + * @var \DateTime |
|
32 | + */ |
|
33 | + protected $dtStamp; |
|
34 | + |
|
35 | + /** |
|
36 | + * The unique id of the notification this was a reply to. |
|
37 | + * |
|
38 | + * @var string |
|
39 | + */ |
|
40 | + protected $inReplyTo; |
|
41 | + |
|
42 | + /** |
|
43 | + * A url to the recipient of the original (!) notification. |
|
44 | + * |
|
45 | + * @var string |
|
46 | + */ |
|
47 | + protected $href; |
|
48 | + |
|
49 | + /** |
|
50 | + * The type of message, see the SharingPlugin::STATUS_ constants. |
|
51 | + * |
|
52 | + * @var int |
|
53 | + */ |
|
54 | + protected $type; |
|
55 | + |
|
56 | + /** |
|
57 | + * A url to the shared calendar. |
|
58 | + * |
|
59 | + * @var string |
|
60 | + */ |
|
61 | + protected $hostUrl; |
|
62 | + |
|
63 | + /** |
|
64 | + * A description of the share request. |
|
65 | + * |
|
66 | + * @var string |
|
67 | + */ |
|
68 | + protected $summary; |
|
69 | + |
|
70 | + /** |
|
71 | + * Notification Etag. |
|
72 | + * |
|
73 | + * @var string |
|
74 | + */ |
|
75 | + protected $etag; |
|
76 | + |
|
77 | + /** |
|
78 | + * Creates the Invite Reply Notification. |
|
79 | + * |
|
80 | + * This constructor receives an array with the following elements: |
|
81 | + * |
|
82 | + * * id - A unique id |
|
83 | + * * etag - The etag |
|
84 | + * * dtStamp - A DateTime object with a timestamp for the notification. |
|
85 | + * * inReplyTo - This should refer to the 'id' of the notification |
|
86 | + * this is a reply to. |
|
87 | + * * type - The type of notification, see SharingPlugin::STATUS_* |
|
88 | + * constants for details. |
|
89 | + * * hostUrl - A url to the shared calendar. |
|
90 | + * * summary - Description of the share, can be the same as the |
|
91 | + * calendar, but may also be modified (optional). |
|
92 | + */ |
|
93 | + public function __construct(array $values) |
|
94 | + { |
|
95 | + $required = [ |
|
96 | + 'id', |
|
97 | + 'etag', |
|
98 | + 'href', |
|
99 | + 'dtStamp', |
|
100 | + 'inReplyTo', |
|
101 | + 'type', |
|
102 | + 'hostUrl', |
|
103 | + ]; |
|
104 | + foreach ($required as $item) { |
|
105 | + if (!isset($values[$item])) { |
|
106 | + throw new \InvalidArgumentException($item.' is a required constructor option'); |
|
107 | + } |
|
108 | + } |
|
109 | + |
|
110 | + foreach ($values as $key => $value) { |
|
111 | + if (!property_exists($this, $key)) { |
|
112 | + throw new \InvalidArgumentException('Unknown option: '.$key); |
|
113 | + } |
|
114 | + $this->$key = $value; |
|
115 | + } |
|
116 | + } |
|
117 | + |
|
118 | + /** |
|
119 | + * The xmlSerialize method is called during xml writing. |
|
120 | + * |
|
121 | + * Use the $writer argument to write its own xml serialization. |
|
122 | + * |
|
123 | + * An important note: do _not_ create a parent element. Any element |
|
124 | + * implementing XmlSerializable should only ever write what's considered |
|
125 | + * its 'inner xml'. |
|
126 | + * |
|
127 | + * The parent of the current element is responsible for writing a |
|
128 | + * containing element. |
|
129 | + * |
|
130 | + * This allows serializers to be re-used for different element names. |
|
131 | + * |
|
132 | + * If you are opening new elements, you must also close them again. |
|
133 | + */ |
|
134 | + public function xmlSerialize(Writer $writer) |
|
135 | + { |
|
136 | + $writer->writeElement('{'.CalDAV\Plugin::NS_CALENDARSERVER.'}invite-reply'); |
|
137 | + } |
|
138 | + |
|
139 | + /** |
|
140 | + * This method serializes the entire notification, as it is used in the |
|
141 | + * response body. |
|
142 | + */ |
|
143 | + public function xmlSerializeFull(Writer $writer) |
|
144 | + { |
|
145 | + $cs = '{'.CalDAV\Plugin::NS_CALENDARSERVER.'}'; |
|
146 | + |
|
147 | + $this->dtStamp->setTimezone(new \DateTimeZone('GMT')); |
|
148 | + $writer->writeElement($cs.'dtstamp', $this->dtStamp->format('Ymd\\THis\\Z')); |
|
149 | + |
|
150 | + $writer->startElement($cs.'invite-reply'); |
|
151 | + |
|
152 | + $writer->writeElement($cs.'uid', $this->id); |
|
153 | + $writer->writeElement($cs.'in-reply-to', $this->inReplyTo); |
|
154 | + $writer->writeElement('{DAV:}href', $this->href); |
|
155 | + |
|
156 | + switch ($this->type) { |
|
157 | + case DAV\Sharing\Plugin::INVITE_ACCEPTED: |
|
158 | + $writer->writeElement($cs.'invite-accepted'); |
|
159 | + break; |
|
160 | + case DAV\Sharing\Plugin::INVITE_DECLINED: |
|
161 | + $writer->writeElement($cs.'invite-declined'); |
|
162 | + break; |
|
163 | + } |
|
164 | + |
|
165 | + $writer->writeElement($cs.'hosturl', [ |
|
166 | + '{DAV:}href' => $writer->contextUri.$this->hostUrl, |
|
167 | + ]); |
|
168 | + |
|
169 | + if ($this->summary) { |
|
170 | + $writer->writeElement($cs.'summary', $this->summary); |
|
171 | + } |
|
172 | + $writer->endElement(); // invite-reply |
|
173 | + } |
|
174 | + |
|
175 | + /** |
|
176 | + * Returns a unique id for this notification. |
|
177 | + * |
|
178 | + * This is just the base url. This should generally be some kind of unique |
|
179 | + * id. |
|
180 | + * |
|
181 | + * @return string |
|
182 | + */ |
|
183 | + public function getId() |
|
184 | + { |
|
185 | + return $this->id; |
|
186 | + } |
|
187 | + |
|
188 | + /** |
|
189 | + * Returns the ETag for this notification. |
|
190 | + * |
|
191 | + * The ETag must be surrounded by literal double-quotes. |
|
192 | + * |
|
193 | + * @return string |
|
194 | + */ |
|
195 | + public function getETag() |
|
196 | + { |
|
197 | + return $this->etag; |
|
198 | + } |
|
199 | 199 | } |
@@ -16,28 +16,28 @@ |
||
16 | 16 | */ |
17 | 17 | interface NotificationInterface extends XmlSerializable |
18 | 18 | { |
19 | - /** |
|
20 | - * This method serializes the entire notification, as it is used in the |
|
21 | - * response body. |
|
22 | - */ |
|
23 | - public function xmlSerializeFull(Writer $writer); |
|
19 | + /** |
|
20 | + * This method serializes the entire notification, as it is used in the |
|
21 | + * response body. |
|
22 | + */ |
|
23 | + public function xmlSerializeFull(Writer $writer); |
|
24 | 24 | |
25 | - /** |
|
26 | - * Returns a unique id for this notification. |
|
27 | - * |
|
28 | - * This is just the base url. This should generally be some kind of unique |
|
29 | - * id. |
|
30 | - * |
|
31 | - * @return string |
|
32 | - */ |
|
33 | - public function getId(); |
|
25 | + /** |
|
26 | + * Returns a unique id for this notification. |
|
27 | + * |
|
28 | + * This is just the base url. This should generally be some kind of unique |
|
29 | + * id. |
|
30 | + * |
|
31 | + * @return string |
|
32 | + */ |
|
33 | + public function getId(); |
|
34 | 34 | |
35 | - /** |
|
36 | - * Returns the ETag for this notification. |
|
37 | - * |
|
38 | - * The ETag must be surrounded by literal double-quotes. |
|
39 | - * |
|
40 | - * @return string |
|
41 | - */ |
|
42 | - public function getETag(); |
|
35 | + /** |
|
36 | + * Returns the ETag for this notification. |
|
37 | + * |
|
38 | + * The ETag must be surrounded by literal double-quotes. |
|
39 | + * |
|
40 | + * @return string |
|
41 | + */ |
|
42 | + public function getETag(); |
|
43 | 43 | } |
@@ -25,121 +25,121 @@ |
||
25 | 25 | */ |
26 | 26 | class InviteReply implements XmlDeserializable |
27 | 27 | { |
28 | - /** |
|
29 | - * The sharee calendar user address. |
|
30 | - * |
|
31 | - * This is the address that the original invite was set to |
|
32 | - * |
|
33 | - * @var string |
|
34 | - */ |
|
35 | - public $href; |
|
28 | + /** |
|
29 | + * The sharee calendar user address. |
|
30 | + * |
|
31 | + * This is the address that the original invite was set to |
|
32 | + * |
|
33 | + * @var string |
|
34 | + */ |
|
35 | + public $href; |
|
36 | 36 | |
37 | - /** |
|
38 | - * The uri to the calendar that was being shared. |
|
39 | - * |
|
40 | - * @var string |
|
41 | - */ |
|
42 | - public $calendarUri; |
|
37 | + /** |
|
38 | + * The uri to the calendar that was being shared. |
|
39 | + * |
|
40 | + * @var string |
|
41 | + */ |
|
42 | + public $calendarUri; |
|
43 | 43 | |
44 | - /** |
|
45 | - * The id of the invite message that's being responded to. |
|
46 | - * |
|
47 | - * @var string |
|
48 | - */ |
|
49 | - public $inReplyTo; |
|
44 | + /** |
|
45 | + * The id of the invite message that's being responded to. |
|
46 | + * |
|
47 | + * @var string |
|
48 | + */ |
|
49 | + public $inReplyTo; |
|
50 | 50 | |
51 | - /** |
|
52 | - * An optional message. |
|
53 | - * |
|
54 | - * @var string |
|
55 | - */ |
|
56 | - public $summary; |
|
51 | + /** |
|
52 | + * An optional message. |
|
53 | + * |
|
54 | + * @var string |
|
55 | + */ |
|
56 | + public $summary; |
|
57 | 57 | |
58 | - /** |
|
59 | - * Either SharingPlugin::STATUS_ACCEPTED or SharingPlugin::STATUS_DECLINED. |
|
60 | - * |
|
61 | - * @var int |
|
62 | - */ |
|
63 | - public $status; |
|
58 | + /** |
|
59 | + * Either SharingPlugin::STATUS_ACCEPTED or SharingPlugin::STATUS_DECLINED. |
|
60 | + * |
|
61 | + * @var int |
|
62 | + */ |
|
63 | + public $status; |
|
64 | 64 | |
65 | - /** |
|
66 | - * Constructor. |
|
67 | - * |
|
68 | - * @param string $href |
|
69 | - * @param string $calendarUri |
|
70 | - * @param string $inReplyTo |
|
71 | - * @param string $summary |
|
72 | - * @param int $status |
|
73 | - */ |
|
74 | - public function __construct($href, $calendarUri, $inReplyTo, $summary, $status) |
|
75 | - { |
|
76 | - $this->href = $href; |
|
77 | - $this->calendarUri = $calendarUri; |
|
78 | - $this->inReplyTo = $inReplyTo; |
|
79 | - $this->summary = $summary; |
|
80 | - $this->status = $status; |
|
81 | - } |
|
65 | + /** |
|
66 | + * Constructor. |
|
67 | + * |
|
68 | + * @param string $href |
|
69 | + * @param string $calendarUri |
|
70 | + * @param string $inReplyTo |
|
71 | + * @param string $summary |
|
72 | + * @param int $status |
|
73 | + */ |
|
74 | + public function __construct($href, $calendarUri, $inReplyTo, $summary, $status) |
|
75 | + { |
|
76 | + $this->href = $href; |
|
77 | + $this->calendarUri = $calendarUri; |
|
78 | + $this->inReplyTo = $inReplyTo; |
|
79 | + $this->summary = $summary; |
|
80 | + $this->status = $status; |
|
81 | + } |
|
82 | 82 | |
83 | - /** |
|
84 | - * The deserialize method is called during xml parsing. |
|
85 | - * |
|
86 | - * This method is called statically, this is because in theory this method |
|
87 | - * may be used as a type of constructor, or factory method. |
|
88 | - * |
|
89 | - * Often you want to return an instance of the current class, but you are |
|
90 | - * free to return other data as well. |
|
91 | - * |
|
92 | - * You are responsible for advancing the reader to the next element. Not |
|
93 | - * doing anything will result in a never-ending loop. |
|
94 | - * |
|
95 | - * If you just want to skip parsing for this element altogether, you can |
|
96 | - * just call $reader->next(); |
|
97 | - * |
|
98 | - * $reader->parseInnerTree() will parse the entire sub-tree, and advance to |
|
99 | - * the next element. |
|
100 | - * |
|
101 | - * @return mixed |
|
102 | - */ |
|
103 | - public static function xmlDeserialize(Reader $reader) |
|
104 | - { |
|
105 | - $elems = KeyValue::xmlDeserialize($reader); |
|
83 | + /** |
|
84 | + * The deserialize method is called during xml parsing. |
|
85 | + * |
|
86 | + * This method is called statically, this is because in theory this method |
|
87 | + * may be used as a type of constructor, or factory method. |
|
88 | + * |
|
89 | + * Often you want to return an instance of the current class, but you are |
|
90 | + * free to return other data as well. |
|
91 | + * |
|
92 | + * You are responsible for advancing the reader to the next element. Not |
|
93 | + * doing anything will result in a never-ending loop. |
|
94 | + * |
|
95 | + * If you just want to skip parsing for this element altogether, you can |
|
96 | + * just call $reader->next(); |
|
97 | + * |
|
98 | + * $reader->parseInnerTree() will parse the entire sub-tree, and advance to |
|
99 | + * the next element. |
|
100 | + * |
|
101 | + * @return mixed |
|
102 | + */ |
|
103 | + public static function xmlDeserialize(Reader $reader) |
|
104 | + { |
|
105 | + $elems = KeyValue::xmlDeserialize($reader); |
|
106 | 106 | |
107 | - $href = null; |
|
108 | - $calendarUri = null; |
|
109 | - $inReplyTo = null; |
|
110 | - $summary = null; |
|
111 | - $status = null; |
|
107 | + $href = null; |
|
108 | + $calendarUri = null; |
|
109 | + $inReplyTo = null; |
|
110 | + $summary = null; |
|
111 | + $status = null; |
|
112 | 112 | |
113 | - foreach ($elems as $name => $value) { |
|
114 | - switch ($name) { |
|
115 | - case '{'.Plugin::NS_CALENDARSERVER.'}hosturl': |
|
116 | - foreach ($value as $bla) { |
|
117 | - if ('{DAV:}href' === $bla['name']) { |
|
118 | - $calendarUri = $bla['value']; |
|
119 | - } |
|
120 | - } |
|
121 | - break; |
|
122 | - case '{'.Plugin::NS_CALENDARSERVER.'}invite-accepted': |
|
123 | - $status = DAV\Sharing\Plugin::INVITE_ACCEPTED; |
|
124 | - break; |
|
125 | - case '{'.Plugin::NS_CALENDARSERVER.'}invite-declined': |
|
126 | - $status = DAV\Sharing\Plugin::INVITE_DECLINED; |
|
127 | - break; |
|
128 | - case '{'.Plugin::NS_CALENDARSERVER.'}in-reply-to': |
|
129 | - $inReplyTo = $value; |
|
130 | - break; |
|
131 | - case '{'.Plugin::NS_CALENDARSERVER.'}summary': |
|
132 | - $summary = $value; |
|
133 | - break; |
|
134 | - case '{DAV:}href': |
|
135 | - $href = $value; |
|
136 | - break; |
|
137 | - } |
|
138 | - } |
|
139 | - if (is_null($calendarUri)) { |
|
140 | - throw new BadRequest('The {http://calendarserver.org/ns/}hosturl/{DAV:}href element must exist'); |
|
141 | - } |
|
113 | + foreach ($elems as $name => $value) { |
|
114 | + switch ($name) { |
|
115 | + case '{'.Plugin::NS_CALENDARSERVER.'}hosturl': |
|
116 | + foreach ($value as $bla) { |
|
117 | + if ('{DAV:}href' === $bla['name']) { |
|
118 | + $calendarUri = $bla['value']; |
|
119 | + } |
|
120 | + } |
|
121 | + break; |
|
122 | + case '{'.Plugin::NS_CALENDARSERVER.'}invite-accepted': |
|
123 | + $status = DAV\Sharing\Plugin::INVITE_ACCEPTED; |
|
124 | + break; |
|
125 | + case '{'.Plugin::NS_CALENDARSERVER.'}invite-declined': |
|
126 | + $status = DAV\Sharing\Plugin::INVITE_DECLINED; |
|
127 | + break; |
|
128 | + case '{'.Plugin::NS_CALENDARSERVER.'}in-reply-to': |
|
129 | + $inReplyTo = $value; |
|
130 | + break; |
|
131 | + case '{'.Plugin::NS_CALENDARSERVER.'}summary': |
|
132 | + $summary = $value; |
|
133 | + break; |
|
134 | + case '{DAV:}href': |
|
135 | + $href = $value; |
|
136 | + break; |
|
137 | + } |
|
138 | + } |
|
139 | + if (is_null($calendarUri)) { |
|
140 | + throw new BadRequest('The {http://calendarserver.org/ns/}hosturl/{DAV:}href element must exist'); |
|
141 | + } |
|
142 | 142 | |
143 | - return new self($href, $calendarUri, $inReplyTo, $summary, $status); |
|
144 | - } |
|
143 | + return new self($href, $calendarUri, $inReplyTo, $summary, $status); |
|
144 | + } |
|
145 | 145 | } |
@@ -23,115 +23,115 @@ |
||
23 | 23 | */ |
24 | 24 | class CalendarQueryReport implements XmlDeserializable |
25 | 25 | { |
26 | - /** |
|
27 | - * An array with requested properties. |
|
28 | - * |
|
29 | - * @var array |
|
30 | - */ |
|
31 | - public $properties; |
|
26 | + /** |
|
27 | + * An array with requested properties. |
|
28 | + * |
|
29 | + * @var array |
|
30 | + */ |
|
31 | + public $properties; |
|
32 | 32 | |
33 | - /** |
|
34 | - * List of property/component filters. |
|
35 | - * |
|
36 | - * @var array |
|
37 | - */ |
|
38 | - public $filters; |
|
33 | + /** |
|
34 | + * List of property/component filters. |
|
35 | + * |
|
36 | + * @var array |
|
37 | + */ |
|
38 | + public $filters; |
|
39 | 39 | |
40 | - /** |
|
41 | - * If the calendar data must be expanded, this will contain an array with 2 |
|
42 | - * elements: start and end. |
|
43 | - * |
|
44 | - * Each may be a DateTime or null. |
|
45 | - * |
|
46 | - * @var array|null |
|
47 | - */ |
|
48 | - public $expand = null; |
|
40 | + /** |
|
41 | + * If the calendar data must be expanded, this will contain an array with 2 |
|
42 | + * elements: start and end. |
|
43 | + * |
|
44 | + * Each may be a DateTime or null. |
|
45 | + * |
|
46 | + * @var array|null |
|
47 | + */ |
|
48 | + public $expand = null; |
|
49 | 49 | |
50 | - /** |
|
51 | - * The mimetype of the content that should be returend. Usually |
|
52 | - * text/calendar. |
|
53 | - * |
|
54 | - * @var string |
|
55 | - */ |
|
56 | - public $contentType = null; |
|
50 | + /** |
|
51 | + * The mimetype of the content that should be returend. Usually |
|
52 | + * text/calendar. |
|
53 | + * |
|
54 | + * @var string |
|
55 | + */ |
|
56 | + public $contentType = null; |
|
57 | 57 | |
58 | - /** |
|
59 | - * The version of calendar-data that should be returned. Usually '2.0', |
|
60 | - * referring to iCalendar 2.0. |
|
61 | - * |
|
62 | - * @var string |
|
63 | - */ |
|
64 | - public $version = null; |
|
58 | + /** |
|
59 | + * The version of calendar-data that should be returned. Usually '2.0', |
|
60 | + * referring to iCalendar 2.0. |
|
61 | + * |
|
62 | + * @var string |
|
63 | + */ |
|
64 | + public $version = null; |
|
65 | 65 | |
66 | - /** |
|
67 | - * The deserialize method is called during xml parsing. |
|
68 | - * |
|
69 | - * This method is called statically, this is because in theory this method |
|
70 | - * may be used as a type of constructor, or factory method. |
|
71 | - * |
|
72 | - * Often you want to return an instance of the current class, but you are |
|
73 | - * free to return other data as well. |
|
74 | - * |
|
75 | - * You are responsible for advancing the reader to the next element. Not |
|
76 | - * doing anything will result in a never-ending loop. |
|
77 | - * |
|
78 | - * If you just want to skip parsing for this element altogether, you can |
|
79 | - * just call $reader->next(); |
|
80 | - * |
|
81 | - * $reader->parseInnerTree() will parse the entire sub-tree, and advance to |
|
82 | - * the next element. |
|
83 | - * |
|
84 | - * @return mixed |
|
85 | - */ |
|
86 | - public static function xmlDeserialize(Reader $reader) |
|
87 | - { |
|
88 | - $elems = $reader->parseInnerTree([ |
|
89 | - '{urn:ietf:params:xml:ns:caldav}comp-filter' => 'Sabre\\CalDAV\\Xml\\Filter\\CompFilter', |
|
90 | - '{urn:ietf:params:xml:ns:caldav}prop-filter' => 'Sabre\\CalDAV\\Xml\\Filter\\PropFilter', |
|
91 | - '{urn:ietf:params:xml:ns:caldav}param-filter' => 'Sabre\\CalDAV\\Xml\\Filter\\ParamFilter', |
|
92 | - '{urn:ietf:params:xml:ns:caldav}calendar-data' => 'Sabre\\CalDAV\\Xml\\Filter\\CalendarData', |
|
93 | - '{DAV:}prop' => 'Sabre\\Xml\\Element\\KeyValue', |
|
94 | - ]); |
|
66 | + /** |
|
67 | + * The deserialize method is called during xml parsing. |
|
68 | + * |
|
69 | + * This method is called statically, this is because in theory this method |
|
70 | + * may be used as a type of constructor, or factory method. |
|
71 | + * |
|
72 | + * Often you want to return an instance of the current class, but you are |
|
73 | + * free to return other data as well. |
|
74 | + * |
|
75 | + * You are responsible for advancing the reader to the next element. Not |
|
76 | + * doing anything will result in a never-ending loop. |
|
77 | + * |
|
78 | + * If you just want to skip parsing for this element altogether, you can |
|
79 | + * just call $reader->next(); |
|
80 | + * |
|
81 | + * $reader->parseInnerTree() will parse the entire sub-tree, and advance to |
|
82 | + * the next element. |
|
83 | + * |
|
84 | + * @return mixed |
|
85 | + */ |
|
86 | + public static function xmlDeserialize(Reader $reader) |
|
87 | + { |
|
88 | + $elems = $reader->parseInnerTree([ |
|
89 | + '{urn:ietf:params:xml:ns:caldav}comp-filter' => 'Sabre\\CalDAV\\Xml\\Filter\\CompFilter', |
|
90 | + '{urn:ietf:params:xml:ns:caldav}prop-filter' => 'Sabre\\CalDAV\\Xml\\Filter\\PropFilter', |
|
91 | + '{urn:ietf:params:xml:ns:caldav}param-filter' => 'Sabre\\CalDAV\\Xml\\Filter\\ParamFilter', |
|
92 | + '{urn:ietf:params:xml:ns:caldav}calendar-data' => 'Sabre\\CalDAV\\Xml\\Filter\\CalendarData', |
|
93 | + '{DAV:}prop' => 'Sabre\\Xml\\Element\\KeyValue', |
|
94 | + ]); |
|
95 | 95 | |
96 | - $newProps = [ |
|
97 | - 'filters' => null, |
|
98 | - 'properties' => [], |
|
99 | - ]; |
|
96 | + $newProps = [ |
|
97 | + 'filters' => null, |
|
98 | + 'properties' => [], |
|
99 | + ]; |
|
100 | 100 | |
101 | - if (!is_array($elems)) { |
|
102 | - $elems = []; |
|
103 | - } |
|
101 | + if (!is_array($elems)) { |
|
102 | + $elems = []; |
|
103 | + } |
|
104 | 104 | |
105 | - foreach ($elems as $elem) { |
|
106 | - switch ($elem['name']) { |
|
107 | - case '{DAV:}prop': |
|
108 | - $newProps['properties'] = array_keys($elem['value']); |
|
109 | - if (isset($elem['value']['{'.Plugin::NS_CALDAV.'}calendar-data'])) { |
|
110 | - $newProps += $elem['value']['{'.Plugin::NS_CALDAV.'}calendar-data']; |
|
111 | - } |
|
112 | - break; |
|
113 | - case '{'.Plugin::NS_CALDAV.'}filter': |
|
114 | - foreach ($elem['value'] as $subElem) { |
|
115 | - if ($subElem['name'] === '{'.Plugin::NS_CALDAV.'}comp-filter') { |
|
116 | - if (!is_null($newProps['filters'])) { |
|
117 | - throw new BadRequest('Only one top-level comp-filter may be defined'); |
|
118 | - } |
|
119 | - $newProps['filters'] = $subElem['value']; |
|
120 | - } |
|
121 | - } |
|
122 | - break; |
|
123 | - } |
|
124 | - } |
|
105 | + foreach ($elems as $elem) { |
|
106 | + switch ($elem['name']) { |
|
107 | + case '{DAV:}prop': |
|
108 | + $newProps['properties'] = array_keys($elem['value']); |
|
109 | + if (isset($elem['value']['{'.Plugin::NS_CALDAV.'}calendar-data'])) { |
|
110 | + $newProps += $elem['value']['{'.Plugin::NS_CALDAV.'}calendar-data']; |
|
111 | + } |
|
112 | + break; |
|
113 | + case '{'.Plugin::NS_CALDAV.'}filter': |
|
114 | + foreach ($elem['value'] as $subElem) { |
|
115 | + if ($subElem['name'] === '{'.Plugin::NS_CALDAV.'}comp-filter') { |
|
116 | + if (!is_null($newProps['filters'])) { |
|
117 | + throw new BadRequest('Only one top-level comp-filter may be defined'); |
|
118 | + } |
|
119 | + $newProps['filters'] = $subElem['value']; |
|
120 | + } |
|
121 | + } |
|
122 | + break; |
|
123 | + } |
|
124 | + } |
|
125 | 125 | |
126 | - if (is_null($newProps['filters'])) { |
|
127 | - throw new BadRequest('The {'.Plugin::NS_CALDAV.'}filter element is required for this request'); |
|
128 | - } |
|
126 | + if (is_null($newProps['filters'])) { |
|
127 | + throw new BadRequest('The {'.Plugin::NS_CALDAV.'}filter element is required for this request'); |
|
128 | + } |
|
129 | 129 | |
130 | - $obj = new self(); |
|
131 | - foreach ($newProps as $key => $value) { |
|
132 | - $obj->$key = $value; |
|
133 | - } |
|
130 | + $obj = new self(); |
|
131 | + foreach ($newProps as $key => $value) { |
|
132 | + $obj->$key = $value; |
|
133 | + } |
|
134 | 134 | |
135 | - return $obj; |
|
136 | - } |
|
135 | + return $obj; |
|
136 | + } |
|
137 | 137 | } |