@@ -33,478 +33,478 @@ |
||
33 | 33 | * @since 11.0.0 |
34 | 34 | */ |
35 | 35 | class Definitions { |
36 | - /** |
|
37 | - * @var array |
|
38 | - * @since 11.0.0 |
|
39 | - */ |
|
40 | - public $definitions = [ |
|
41 | - 'addressbook' => [ |
|
42 | - 'author' => 'Nextcloud', |
|
43 | - 'app' => 'dav', |
|
44 | - 'since' => '11.0.0', |
|
45 | - 'parameters' => [ |
|
46 | - 'id' => [ |
|
47 | - 'since' => '11.0.0', |
|
48 | - 'required' => true, |
|
49 | - 'description' => 'The id used to identify the addressbook on the instance', |
|
50 | - 'example' => '42', |
|
51 | - ], |
|
52 | - 'name' => [ |
|
53 | - 'since' => '11.0.0', |
|
54 | - 'required' => true, |
|
55 | - 'description' => 'The display name of the addressbook which should be used in the visual representation', |
|
56 | - 'example' => 'Contacts', |
|
57 | - ], |
|
58 | - ], |
|
59 | - ], |
|
60 | - 'addressbook-contact' => [ |
|
61 | - 'author' => 'Nextcloud', |
|
62 | - 'app' => 'dav', |
|
63 | - 'since' => '11.0.0', |
|
64 | - 'parameters' => [ |
|
65 | - 'id' => [ |
|
66 | - 'since' => '11.0.0', |
|
67 | - 'required' => true, |
|
68 | - 'description' => 'The id used to identify the contact on the instance', |
|
69 | - 'example' => '42', |
|
70 | - ], |
|
71 | - 'name' => [ |
|
72 | - 'since' => '11.0.0', |
|
73 | - 'required' => true, |
|
74 | - 'description' => 'The display name of the contact which should be used in the visual representation', |
|
75 | - 'example' => 'John Doe', |
|
76 | - ], |
|
77 | - ], |
|
78 | - ], |
|
79 | - 'announcement' => [ |
|
80 | - 'author' => 'Joas Schilling', |
|
81 | - 'app' => 'announcementcenter', |
|
82 | - 'since' => '11.0.0', |
|
83 | - 'parameters' => [ |
|
84 | - 'id' => [ |
|
85 | - 'since' => '11.0.0', |
|
86 | - 'required' => true, 'description' => 'The id used to identify the announcement on the instance', |
|
87 | - 'example' => '42', |
|
88 | - ], |
|
89 | - 'name' => [ |
|
90 | - 'since' => '11.0.0', |
|
91 | - 'required' => true, |
|
92 | - 'description' => 'The announcement subject which should be used in the visual representation', |
|
93 | - 'example' => 'file.txt', |
|
94 | - ], |
|
95 | - 'link' => [ |
|
96 | - 'since' => '11.0.0', |
|
97 | - 'required' => false, |
|
98 | - 'description' => 'The full URL to the file', |
|
99 | - 'example' => 'http://localhost/index.php/apps/announcements/#23', |
|
100 | - ], |
|
101 | - ], |
|
102 | - ], |
|
103 | - 'app' => [ |
|
104 | - 'author' => 'Nextcloud', |
|
105 | - 'app' => 'updatenotification', |
|
106 | - 'since' => '11.0.0', |
|
107 | - 'parameters' => [ |
|
108 | - 'id' => [ |
|
109 | - 'since' => '11.0.0', |
|
110 | - 'required' => true, 'description' => 'The app id', |
|
111 | - 'example' => 'updatenotification', |
|
112 | - ], |
|
113 | - 'name' => [ |
|
114 | - 'since' => '11.0.0', |
|
115 | - 'required' => true, |
|
116 | - 'description' => 'The name of the app which should be used in the visual representation', |
|
117 | - 'example' => 'Update notification', |
|
118 | - ], |
|
119 | - ], |
|
120 | - ], |
|
121 | - 'calendar' => [ |
|
122 | - 'author' => 'Nextcloud', |
|
123 | - 'app' => 'dav', |
|
124 | - 'since' => '11.0.0', |
|
125 | - 'parameters' => [ |
|
126 | - 'id' => [ |
|
127 | - 'since' => '11.0.0', |
|
128 | - 'required' => true, |
|
129 | - 'description' => 'The id used to identify the calendar on the instance', |
|
130 | - 'example' => '42', |
|
131 | - ], |
|
132 | - 'name' => [ |
|
133 | - 'since' => '11.0.0', |
|
134 | - 'required' => true, |
|
135 | - 'description' => 'The display name of the calendar which should be used in the visual representation', |
|
136 | - 'example' => 'Personal', |
|
137 | - ], |
|
138 | - ], |
|
139 | - ], |
|
140 | - 'calendar-event' => [ |
|
141 | - 'author' => 'Nextcloud', |
|
142 | - 'app' => 'dav', |
|
143 | - 'since' => '11.0.0', |
|
144 | - 'parameters' => [ |
|
145 | - 'id' => [ |
|
146 | - 'since' => '11.0.0', |
|
147 | - 'required' => true, |
|
148 | - 'description' => 'The id used to identify the event on the instance', |
|
149 | - 'example' => '42', |
|
150 | - ], |
|
151 | - 'name' => [ |
|
152 | - 'since' => '11.0.0', |
|
153 | - 'required' => true, |
|
154 | - 'description' => 'The display name of the event which should be used in the visual representation', |
|
155 | - 'example' => 'Workout', |
|
156 | - ], |
|
157 | - 'link' => [ |
|
158 | - 'since' => '19.0.0', |
|
159 | - 'required' => false, |
|
160 | - 'description' => 'A link to the page displaying the calendar', |
|
161 | - 'example' => 'http://localhost/index.php/apps/calendar/dayGridMonth/2020-01-20/edit/sidebar/base64string/1579046400' |
|
162 | - ] |
|
163 | - ], |
|
164 | - ], |
|
165 | - 'call' => [ |
|
166 | - 'author' => 'Nextcloud', |
|
167 | - 'app' => 'spreed', |
|
168 | - 'since' => '11.0.2', |
|
169 | - 'parameters' => [ |
|
170 | - 'id' => [ |
|
171 | - 'since' => '11.0.2', |
|
172 | - 'required' => true, |
|
173 | - 'description' => 'The id used to identify the call on the instance', |
|
174 | - 'example' => '42', |
|
175 | - ], |
|
176 | - 'name' => [ |
|
177 | - 'since' => '11.0.2', |
|
178 | - 'required' => true, |
|
179 | - 'description' => 'The display name of the call which should be used in the visual representation', |
|
180 | - 'example' => 'Company call', |
|
181 | - ], |
|
182 | - 'call-type' => [ |
|
183 | - 'since' => '11.0.2', |
|
184 | - 'required' => true, |
|
185 | - 'description' => 'The type of the call: one2one, group or public', |
|
186 | - 'example' => 'one2one', |
|
187 | - ], |
|
188 | - ], |
|
189 | - ], |
|
190 | - 'circle' => [ |
|
191 | - 'author' => 'Maxence Lange', |
|
192 | - 'app' => 'circles', |
|
193 | - 'since' => '12.0.0', |
|
194 | - 'parameters' => [ |
|
195 | - 'id' => [ |
|
196 | - 'since' => '12.0.0', |
|
197 | - 'required' => true, |
|
198 | - 'description' => 'The id used to identify the circle on the instance', |
|
199 | - 'example' => '42', |
|
200 | - ], |
|
201 | - 'name' => [ |
|
202 | - 'since' => '12.0.0', |
|
203 | - 'required' => true, |
|
204 | - 'description' => 'The display name of the circle which should be used in the visual representation', |
|
205 | - 'example' => 'My friends', |
|
206 | - ], |
|
207 | - 'link' => [ |
|
208 | - 'since' => '12.0.0', |
|
209 | - 'required' => true, |
|
210 | - 'description' => 'The full URL to the circle', |
|
211 | - 'example' => 'http://localhost/index.php/apps/circles/#42', |
|
212 | - ], |
|
213 | - ], |
|
214 | - ], |
|
215 | - 'email' => [ |
|
216 | - 'author' => 'Nextcloud', |
|
217 | - 'app' => 'sharebymail', |
|
218 | - 'since' => '11.0.0', |
|
219 | - 'parameters' => [ |
|
220 | - 'id' => [ |
|
221 | - 'since' => '11.0.0', |
|
222 | - 'required' => true, |
|
223 | - 'description' => 'The mail-address used to identify the event on the instance', |
|
224 | - 'example' => 'test@localhost', |
|
225 | - ], |
|
226 | - 'name' => [ |
|
227 | - 'since' => '11.0.0', |
|
228 | - 'required' => true, |
|
229 | - 'description' => 'The display name of a matching contact or the email (fallback) which should be used in the visual representation', |
|
230 | - 'example' => 'Foo Bar', |
|
231 | - ], |
|
232 | - ], |
|
233 | - ], |
|
234 | - 'file' => [ |
|
235 | - 'author' => 'Nextcloud', |
|
236 | - 'app' => 'dav', |
|
237 | - 'since' => '11.0.0', |
|
238 | - 'parameters' => [ |
|
239 | - 'id' => [ |
|
240 | - 'since' => '11.0.0', |
|
241 | - 'required' => true, |
|
242 | - 'description' => 'The id used to identify the file on the instance', |
|
243 | - 'example' => '42', |
|
244 | - ], |
|
245 | - 'name' => [ |
|
246 | - 'since' => '11.0.0', |
|
247 | - 'required' => true, |
|
248 | - 'description' => 'The file name which should be used in the visual representation', |
|
249 | - 'example' => 'file.txt', |
|
250 | - ], |
|
251 | - 'path' => [ |
|
252 | - 'since' => '11.0.0', |
|
253 | - 'required' => true, |
|
254 | - 'description' => 'The full path of the file for the user, should not start with a slash', |
|
255 | - 'example' => 'path/to/file.txt', |
|
256 | - ], |
|
257 | - 'link' => [ |
|
258 | - 'since' => '11.0.0', |
|
259 | - 'required' => false, |
|
260 | - 'description' => 'The full URL to the file', |
|
261 | - 'example' => 'http://localhost/index.php/f/42', |
|
262 | - ], |
|
263 | - 'mimetype' => [ |
|
264 | - 'since' => '16.0.0', |
|
265 | - 'required' => false, |
|
266 | - 'description' => 'The mimetype of the file/folder to allow clients to show a placeholder', |
|
267 | - 'example' => 'text/plain', |
|
268 | - ], |
|
269 | - 'preview-available' => [ |
|
270 | - 'since' => '16.0.0', |
|
271 | - 'required' => false, |
|
272 | - 'description' => 'Whether or not a preview is available. If `no` the mimetype icon should be used', |
|
273 | - 'example' => 'yes', |
|
274 | - ], |
|
275 | - ], |
|
276 | - ], |
|
277 | - 'guest' => [ |
|
278 | - 'author' => 'Nextcloud', |
|
279 | - 'app' => 'spreed', |
|
280 | - 'since' => '17.0.0', |
|
281 | - 'parameters' => [ |
|
282 | - 'id' => [ |
|
283 | - 'since' => '17.0.0', |
|
284 | - 'required' => true, |
|
285 | - 'description' => 'The id used to identify the guest user', |
|
286 | - 'example' => '42', |
|
287 | - ], |
|
288 | - 'name' => [ |
|
289 | - 'since' => '17.0.0', |
|
290 | - 'required' => true, |
|
291 | - 'description' => 'Potential displayname of the guest user', |
|
292 | - 'example' => 'Foobar Cats', |
|
293 | - ], |
|
294 | - ], |
|
295 | - ], |
|
296 | - 'highlight' => [ |
|
297 | - 'author' => 'Nextcloud', |
|
298 | - 'app' => 'core', |
|
299 | - 'since' => '13.0.0', |
|
300 | - 'parameters' => [ |
|
301 | - 'id' => [ |
|
302 | - 'since' => '13.0.0', |
|
303 | - 'required' => true, |
|
304 | - 'description' => 'The id used to identify the highlighted object on the instance', |
|
305 | - 'example' => '42', |
|
306 | - ], |
|
307 | - 'name' => [ |
|
308 | - 'since' => '13.0.0', |
|
309 | - 'required' => true, |
|
310 | - 'description' => 'The string that should be highlighted.', |
|
311 | - 'example' => 'Hello World', |
|
312 | - ], |
|
313 | - 'link' => [ |
|
314 | - 'since' => '13.0.0', |
|
315 | - 'required' => false, |
|
316 | - 'description' => 'The full URL that should be opened when clicking the highlighted text.', |
|
317 | - 'example' => 'http://localhost/index.php/f/42', |
|
318 | - ], |
|
319 | - ], |
|
320 | - ], |
|
321 | - 'open-graph' => [ |
|
322 | - 'author' => 'Maxence Lange', |
|
323 | - 'app' => 'mood', |
|
324 | - 'since' => '12.0.0', |
|
325 | - 'parameters' => [ |
|
326 | - 'id' => [ |
|
327 | - 'since' => '12.0.0', |
|
328 | - 'required' => true, |
|
329 | - 'description' => 'The id used to identify the open graph data on the instance', |
|
330 | - 'example' => '42', |
|
331 | - ], |
|
332 | - 'name' => [ |
|
333 | - 'since' => '12.0.0', |
|
334 | - 'required' => true, |
|
335 | - 'description' => 'The open graph title of the website', |
|
336 | - 'example' => 'This is a website', |
|
337 | - ], |
|
338 | - 'description' => [ |
|
339 | - 'since' => '12.0.0', |
|
340 | - 'required' => false, |
|
341 | - 'description' => 'The open graph description from the website', |
|
342 | - 'example' => 'This is the description of the website', |
|
343 | - ], |
|
344 | - 'thumb' => [ |
|
345 | - 'since' => '12.0.0', |
|
346 | - 'required' => false, |
|
347 | - 'description' => 'The full URL of the open graph thumbnail', |
|
348 | - 'example' => 'http://localhost/index.php/apps/mood/data/image?url=https%3A%2F%2Fthumb.example.com%2Fimage.png', |
|
349 | - ], |
|
350 | - 'website' => [ |
|
351 | - 'since' => '12.0.0', |
|
352 | - 'required' => false, |
|
353 | - 'description' => 'The name of the described website', |
|
354 | - 'example' => 'Nextcloud - App Store', |
|
355 | - ], |
|
356 | - 'link' => [ |
|
357 | - 'since' => '12.0.0', |
|
358 | - 'required' => false, |
|
359 | - 'description' => 'The full link to the website', |
|
360 | - 'example' => 'https://apps.nextcloud.com/apps/mood', |
|
361 | - ], |
|
362 | - ], |
|
363 | - ], |
|
364 | - 'pending-federated-share' => [ |
|
365 | - 'author' => 'Nextcloud', |
|
366 | - 'app' => 'dav', |
|
367 | - 'since' => '11.0.0', |
|
368 | - 'parameters' => [ |
|
369 | - 'id' => [ |
|
370 | - 'since' => '11.0.0', |
|
371 | - 'required' => true, |
|
372 | - 'description' => 'The id used to identify the federated share on the instance', |
|
373 | - 'example' => '42', |
|
374 | - ], |
|
375 | - 'name' => [ |
|
376 | - 'since' => '11.0.0', |
|
377 | - 'required' => true, |
|
378 | - 'description' => 'The name of the shared item which should be used in the visual representation', |
|
379 | - 'example' => 'file.txt', |
|
380 | - ], |
|
381 | - ], |
|
382 | - ], |
|
383 | - 'systemtag' => [ |
|
384 | - 'author' => 'Nextcloud', |
|
385 | - 'app' => 'core', |
|
386 | - 'since' => '11.0.0', |
|
387 | - 'parameters' => [ |
|
388 | - 'id' => [ |
|
389 | - 'since' => '11.0.0', |
|
390 | - 'required' => true, |
|
391 | - 'description' => 'The id used to identify the systemtag on the instance', |
|
392 | - 'example' => '23', |
|
393 | - ], |
|
394 | - 'name' => [ |
|
395 | - 'since' => '11.0.0', |
|
396 | - 'required' => true, |
|
397 | - 'description' => 'The display name of the systemtag which should be used in the visual representation', |
|
398 | - 'example' => 'Project 1', |
|
399 | - ], |
|
400 | - 'visibility' => [ |
|
401 | - 'since' => '11.0.0', |
|
402 | - 'required' => true, |
|
403 | - 'description' => 'If the user can see the systemtag', |
|
404 | - 'example' => '1', |
|
405 | - ], |
|
406 | - 'assignable' => [ |
|
407 | - 'since' => '11.0.0', |
|
408 | - 'required' => true, |
|
409 | - 'description' => 'If the user can assign the systemtag', |
|
410 | - 'example' => '0', |
|
411 | - ], |
|
412 | - ], |
|
413 | - ], |
|
414 | - 'talk-attachment' => [ |
|
415 | - 'author' => 'Nextcloud', |
|
416 | - 'app' => 'talk', |
|
417 | - 'since' => '18.0.0', |
|
418 | - 'parameters' => [ |
|
419 | - 'id' => [ |
|
420 | - 'since' => '18.0.0', |
|
421 | - 'required' => true, |
|
422 | - 'description' => 'The id used to identify the attachment on the instance', |
|
423 | - 'example' => '12345', |
|
424 | - ], |
|
425 | - 'name' => [ |
|
426 | - 'since' => '18.0.0', |
|
427 | - 'required' => true, |
|
428 | - 'description' => 'The name of the attachment', |
|
429 | - 'example' => 'John Doe', |
|
430 | - ], |
|
431 | - 'conversation' => [ |
|
432 | - 'since' => '18.0.0', |
|
433 | - 'required' => true, |
|
434 | - 'description' => 'The token of the conversation', |
|
435 | - 'example' => 'a1b2c3d4', |
|
436 | - ], |
|
437 | - 'mimetype' => [ |
|
438 | - 'since' => '18.0.0', |
|
439 | - 'required' => false, |
|
440 | - 'description' => 'The mimetype of the file/folder to allow clients to show a placeholder', |
|
441 | - 'example' => 'text/plain', |
|
442 | - ], |
|
443 | - 'preview-available' => [ |
|
444 | - 'since' => '18.0.0', |
|
445 | - 'required' => false, |
|
446 | - 'description' => 'Whether or not a preview is available. If `no` the mimetype icon should be used', |
|
447 | - 'example' => 'yes', |
|
448 | - ], |
|
449 | - ], |
|
450 | - ], |
|
451 | - 'user' => [ |
|
452 | - 'author' => 'Nextcloud', |
|
453 | - 'app' => 'core', |
|
454 | - 'since' => '11.0.0', |
|
455 | - 'parameters' => [ |
|
456 | - 'id' => [ |
|
457 | - 'since' => '11.0.0', |
|
458 | - 'required' => true, |
|
459 | - 'description' => 'The id used to identify the user on the instance', |
|
460 | - 'example' => 'johndoe', |
|
461 | - ], |
|
462 | - 'name' => [ |
|
463 | - 'since' => '11.0.0', |
|
464 | - 'required' => true, |
|
465 | - 'description' => 'The display name of the user which should be used in the visual representation', |
|
466 | - 'example' => 'John Doe', |
|
467 | - ], |
|
468 | - 'server' => [ |
|
469 | - 'since' => '11.0.0', |
|
470 | - 'required' => false, |
|
471 | - 'description' => 'The URL of the instance the user lives on', |
|
472 | - 'example' => 'localhost', |
|
473 | - ], |
|
474 | - ], |
|
475 | - ], |
|
476 | - 'user-group' => [ |
|
477 | - 'author' => 'Nextcloud', |
|
478 | - 'app' => 'core', |
|
479 | - 'since' => '11.0.0', |
|
480 | - 'parameters' => [ |
|
481 | - 'id' => [ |
|
482 | - 'since' => '11.0.0', |
|
483 | - 'required' => true, |
|
484 | - 'description' => 'The id used to identify the group on the instance', |
|
485 | - 'example' => 'supportteam', |
|
486 | - ], |
|
487 | - 'name' => [ |
|
488 | - 'since' => '11.0.0', |
|
489 | - 'required' => true, |
|
490 | - 'description' => 'The display name of the group which should be used in the visual representation', |
|
491 | - 'example' => 'Support Team', |
|
492 | - ], |
|
493 | - ], |
|
494 | - ], |
|
495 | - ]; |
|
36 | + /** |
|
37 | + * @var array |
|
38 | + * @since 11.0.0 |
|
39 | + */ |
|
40 | + public $definitions = [ |
|
41 | + 'addressbook' => [ |
|
42 | + 'author' => 'Nextcloud', |
|
43 | + 'app' => 'dav', |
|
44 | + 'since' => '11.0.0', |
|
45 | + 'parameters' => [ |
|
46 | + 'id' => [ |
|
47 | + 'since' => '11.0.0', |
|
48 | + 'required' => true, |
|
49 | + 'description' => 'The id used to identify the addressbook on the instance', |
|
50 | + 'example' => '42', |
|
51 | + ], |
|
52 | + 'name' => [ |
|
53 | + 'since' => '11.0.0', |
|
54 | + 'required' => true, |
|
55 | + 'description' => 'The display name of the addressbook which should be used in the visual representation', |
|
56 | + 'example' => 'Contacts', |
|
57 | + ], |
|
58 | + ], |
|
59 | + ], |
|
60 | + 'addressbook-contact' => [ |
|
61 | + 'author' => 'Nextcloud', |
|
62 | + 'app' => 'dav', |
|
63 | + 'since' => '11.0.0', |
|
64 | + 'parameters' => [ |
|
65 | + 'id' => [ |
|
66 | + 'since' => '11.0.0', |
|
67 | + 'required' => true, |
|
68 | + 'description' => 'The id used to identify the contact on the instance', |
|
69 | + 'example' => '42', |
|
70 | + ], |
|
71 | + 'name' => [ |
|
72 | + 'since' => '11.0.0', |
|
73 | + 'required' => true, |
|
74 | + 'description' => 'The display name of the contact which should be used in the visual representation', |
|
75 | + 'example' => 'John Doe', |
|
76 | + ], |
|
77 | + ], |
|
78 | + ], |
|
79 | + 'announcement' => [ |
|
80 | + 'author' => 'Joas Schilling', |
|
81 | + 'app' => 'announcementcenter', |
|
82 | + 'since' => '11.0.0', |
|
83 | + 'parameters' => [ |
|
84 | + 'id' => [ |
|
85 | + 'since' => '11.0.0', |
|
86 | + 'required' => true, 'description' => 'The id used to identify the announcement on the instance', |
|
87 | + 'example' => '42', |
|
88 | + ], |
|
89 | + 'name' => [ |
|
90 | + 'since' => '11.0.0', |
|
91 | + 'required' => true, |
|
92 | + 'description' => 'The announcement subject which should be used in the visual representation', |
|
93 | + 'example' => 'file.txt', |
|
94 | + ], |
|
95 | + 'link' => [ |
|
96 | + 'since' => '11.0.0', |
|
97 | + 'required' => false, |
|
98 | + 'description' => 'The full URL to the file', |
|
99 | + 'example' => 'http://localhost/index.php/apps/announcements/#23', |
|
100 | + ], |
|
101 | + ], |
|
102 | + ], |
|
103 | + 'app' => [ |
|
104 | + 'author' => 'Nextcloud', |
|
105 | + 'app' => 'updatenotification', |
|
106 | + 'since' => '11.0.0', |
|
107 | + 'parameters' => [ |
|
108 | + 'id' => [ |
|
109 | + 'since' => '11.0.0', |
|
110 | + 'required' => true, 'description' => 'The app id', |
|
111 | + 'example' => 'updatenotification', |
|
112 | + ], |
|
113 | + 'name' => [ |
|
114 | + 'since' => '11.0.0', |
|
115 | + 'required' => true, |
|
116 | + 'description' => 'The name of the app which should be used in the visual representation', |
|
117 | + 'example' => 'Update notification', |
|
118 | + ], |
|
119 | + ], |
|
120 | + ], |
|
121 | + 'calendar' => [ |
|
122 | + 'author' => 'Nextcloud', |
|
123 | + 'app' => 'dav', |
|
124 | + 'since' => '11.0.0', |
|
125 | + 'parameters' => [ |
|
126 | + 'id' => [ |
|
127 | + 'since' => '11.0.0', |
|
128 | + 'required' => true, |
|
129 | + 'description' => 'The id used to identify the calendar on the instance', |
|
130 | + 'example' => '42', |
|
131 | + ], |
|
132 | + 'name' => [ |
|
133 | + 'since' => '11.0.0', |
|
134 | + 'required' => true, |
|
135 | + 'description' => 'The display name of the calendar which should be used in the visual representation', |
|
136 | + 'example' => 'Personal', |
|
137 | + ], |
|
138 | + ], |
|
139 | + ], |
|
140 | + 'calendar-event' => [ |
|
141 | + 'author' => 'Nextcloud', |
|
142 | + 'app' => 'dav', |
|
143 | + 'since' => '11.0.0', |
|
144 | + 'parameters' => [ |
|
145 | + 'id' => [ |
|
146 | + 'since' => '11.0.0', |
|
147 | + 'required' => true, |
|
148 | + 'description' => 'The id used to identify the event on the instance', |
|
149 | + 'example' => '42', |
|
150 | + ], |
|
151 | + 'name' => [ |
|
152 | + 'since' => '11.0.0', |
|
153 | + 'required' => true, |
|
154 | + 'description' => 'The display name of the event which should be used in the visual representation', |
|
155 | + 'example' => 'Workout', |
|
156 | + ], |
|
157 | + 'link' => [ |
|
158 | + 'since' => '19.0.0', |
|
159 | + 'required' => false, |
|
160 | + 'description' => 'A link to the page displaying the calendar', |
|
161 | + 'example' => 'http://localhost/index.php/apps/calendar/dayGridMonth/2020-01-20/edit/sidebar/base64string/1579046400' |
|
162 | + ] |
|
163 | + ], |
|
164 | + ], |
|
165 | + 'call' => [ |
|
166 | + 'author' => 'Nextcloud', |
|
167 | + 'app' => 'spreed', |
|
168 | + 'since' => '11.0.2', |
|
169 | + 'parameters' => [ |
|
170 | + 'id' => [ |
|
171 | + 'since' => '11.0.2', |
|
172 | + 'required' => true, |
|
173 | + 'description' => 'The id used to identify the call on the instance', |
|
174 | + 'example' => '42', |
|
175 | + ], |
|
176 | + 'name' => [ |
|
177 | + 'since' => '11.0.2', |
|
178 | + 'required' => true, |
|
179 | + 'description' => 'The display name of the call which should be used in the visual representation', |
|
180 | + 'example' => 'Company call', |
|
181 | + ], |
|
182 | + 'call-type' => [ |
|
183 | + 'since' => '11.0.2', |
|
184 | + 'required' => true, |
|
185 | + 'description' => 'The type of the call: one2one, group or public', |
|
186 | + 'example' => 'one2one', |
|
187 | + ], |
|
188 | + ], |
|
189 | + ], |
|
190 | + 'circle' => [ |
|
191 | + 'author' => 'Maxence Lange', |
|
192 | + 'app' => 'circles', |
|
193 | + 'since' => '12.0.0', |
|
194 | + 'parameters' => [ |
|
195 | + 'id' => [ |
|
196 | + 'since' => '12.0.0', |
|
197 | + 'required' => true, |
|
198 | + 'description' => 'The id used to identify the circle on the instance', |
|
199 | + 'example' => '42', |
|
200 | + ], |
|
201 | + 'name' => [ |
|
202 | + 'since' => '12.0.0', |
|
203 | + 'required' => true, |
|
204 | + 'description' => 'The display name of the circle which should be used in the visual representation', |
|
205 | + 'example' => 'My friends', |
|
206 | + ], |
|
207 | + 'link' => [ |
|
208 | + 'since' => '12.0.0', |
|
209 | + 'required' => true, |
|
210 | + 'description' => 'The full URL to the circle', |
|
211 | + 'example' => 'http://localhost/index.php/apps/circles/#42', |
|
212 | + ], |
|
213 | + ], |
|
214 | + ], |
|
215 | + 'email' => [ |
|
216 | + 'author' => 'Nextcloud', |
|
217 | + 'app' => 'sharebymail', |
|
218 | + 'since' => '11.0.0', |
|
219 | + 'parameters' => [ |
|
220 | + 'id' => [ |
|
221 | + 'since' => '11.0.0', |
|
222 | + 'required' => true, |
|
223 | + 'description' => 'The mail-address used to identify the event on the instance', |
|
224 | + 'example' => 'test@localhost', |
|
225 | + ], |
|
226 | + 'name' => [ |
|
227 | + 'since' => '11.0.0', |
|
228 | + 'required' => true, |
|
229 | + 'description' => 'The display name of a matching contact or the email (fallback) which should be used in the visual representation', |
|
230 | + 'example' => 'Foo Bar', |
|
231 | + ], |
|
232 | + ], |
|
233 | + ], |
|
234 | + 'file' => [ |
|
235 | + 'author' => 'Nextcloud', |
|
236 | + 'app' => 'dav', |
|
237 | + 'since' => '11.0.0', |
|
238 | + 'parameters' => [ |
|
239 | + 'id' => [ |
|
240 | + 'since' => '11.0.0', |
|
241 | + 'required' => true, |
|
242 | + 'description' => 'The id used to identify the file on the instance', |
|
243 | + 'example' => '42', |
|
244 | + ], |
|
245 | + 'name' => [ |
|
246 | + 'since' => '11.0.0', |
|
247 | + 'required' => true, |
|
248 | + 'description' => 'The file name which should be used in the visual representation', |
|
249 | + 'example' => 'file.txt', |
|
250 | + ], |
|
251 | + 'path' => [ |
|
252 | + 'since' => '11.0.0', |
|
253 | + 'required' => true, |
|
254 | + 'description' => 'The full path of the file for the user, should not start with a slash', |
|
255 | + 'example' => 'path/to/file.txt', |
|
256 | + ], |
|
257 | + 'link' => [ |
|
258 | + 'since' => '11.0.0', |
|
259 | + 'required' => false, |
|
260 | + 'description' => 'The full URL to the file', |
|
261 | + 'example' => 'http://localhost/index.php/f/42', |
|
262 | + ], |
|
263 | + 'mimetype' => [ |
|
264 | + 'since' => '16.0.0', |
|
265 | + 'required' => false, |
|
266 | + 'description' => 'The mimetype of the file/folder to allow clients to show a placeholder', |
|
267 | + 'example' => 'text/plain', |
|
268 | + ], |
|
269 | + 'preview-available' => [ |
|
270 | + 'since' => '16.0.0', |
|
271 | + 'required' => false, |
|
272 | + 'description' => 'Whether or not a preview is available. If `no` the mimetype icon should be used', |
|
273 | + 'example' => 'yes', |
|
274 | + ], |
|
275 | + ], |
|
276 | + ], |
|
277 | + 'guest' => [ |
|
278 | + 'author' => 'Nextcloud', |
|
279 | + 'app' => 'spreed', |
|
280 | + 'since' => '17.0.0', |
|
281 | + 'parameters' => [ |
|
282 | + 'id' => [ |
|
283 | + 'since' => '17.0.0', |
|
284 | + 'required' => true, |
|
285 | + 'description' => 'The id used to identify the guest user', |
|
286 | + 'example' => '42', |
|
287 | + ], |
|
288 | + 'name' => [ |
|
289 | + 'since' => '17.0.0', |
|
290 | + 'required' => true, |
|
291 | + 'description' => 'Potential displayname of the guest user', |
|
292 | + 'example' => 'Foobar Cats', |
|
293 | + ], |
|
294 | + ], |
|
295 | + ], |
|
296 | + 'highlight' => [ |
|
297 | + 'author' => 'Nextcloud', |
|
298 | + 'app' => 'core', |
|
299 | + 'since' => '13.0.0', |
|
300 | + 'parameters' => [ |
|
301 | + 'id' => [ |
|
302 | + 'since' => '13.0.0', |
|
303 | + 'required' => true, |
|
304 | + 'description' => 'The id used to identify the highlighted object on the instance', |
|
305 | + 'example' => '42', |
|
306 | + ], |
|
307 | + 'name' => [ |
|
308 | + 'since' => '13.0.0', |
|
309 | + 'required' => true, |
|
310 | + 'description' => 'The string that should be highlighted.', |
|
311 | + 'example' => 'Hello World', |
|
312 | + ], |
|
313 | + 'link' => [ |
|
314 | + 'since' => '13.0.0', |
|
315 | + 'required' => false, |
|
316 | + 'description' => 'The full URL that should be opened when clicking the highlighted text.', |
|
317 | + 'example' => 'http://localhost/index.php/f/42', |
|
318 | + ], |
|
319 | + ], |
|
320 | + ], |
|
321 | + 'open-graph' => [ |
|
322 | + 'author' => 'Maxence Lange', |
|
323 | + 'app' => 'mood', |
|
324 | + 'since' => '12.0.0', |
|
325 | + 'parameters' => [ |
|
326 | + 'id' => [ |
|
327 | + 'since' => '12.0.0', |
|
328 | + 'required' => true, |
|
329 | + 'description' => 'The id used to identify the open graph data on the instance', |
|
330 | + 'example' => '42', |
|
331 | + ], |
|
332 | + 'name' => [ |
|
333 | + 'since' => '12.0.0', |
|
334 | + 'required' => true, |
|
335 | + 'description' => 'The open graph title of the website', |
|
336 | + 'example' => 'This is a website', |
|
337 | + ], |
|
338 | + 'description' => [ |
|
339 | + 'since' => '12.0.0', |
|
340 | + 'required' => false, |
|
341 | + 'description' => 'The open graph description from the website', |
|
342 | + 'example' => 'This is the description of the website', |
|
343 | + ], |
|
344 | + 'thumb' => [ |
|
345 | + 'since' => '12.0.0', |
|
346 | + 'required' => false, |
|
347 | + 'description' => 'The full URL of the open graph thumbnail', |
|
348 | + 'example' => 'http://localhost/index.php/apps/mood/data/image?url=https%3A%2F%2Fthumb.example.com%2Fimage.png', |
|
349 | + ], |
|
350 | + 'website' => [ |
|
351 | + 'since' => '12.0.0', |
|
352 | + 'required' => false, |
|
353 | + 'description' => 'The name of the described website', |
|
354 | + 'example' => 'Nextcloud - App Store', |
|
355 | + ], |
|
356 | + 'link' => [ |
|
357 | + 'since' => '12.0.0', |
|
358 | + 'required' => false, |
|
359 | + 'description' => 'The full link to the website', |
|
360 | + 'example' => 'https://apps.nextcloud.com/apps/mood', |
|
361 | + ], |
|
362 | + ], |
|
363 | + ], |
|
364 | + 'pending-federated-share' => [ |
|
365 | + 'author' => 'Nextcloud', |
|
366 | + 'app' => 'dav', |
|
367 | + 'since' => '11.0.0', |
|
368 | + 'parameters' => [ |
|
369 | + 'id' => [ |
|
370 | + 'since' => '11.0.0', |
|
371 | + 'required' => true, |
|
372 | + 'description' => 'The id used to identify the federated share on the instance', |
|
373 | + 'example' => '42', |
|
374 | + ], |
|
375 | + 'name' => [ |
|
376 | + 'since' => '11.0.0', |
|
377 | + 'required' => true, |
|
378 | + 'description' => 'The name of the shared item which should be used in the visual representation', |
|
379 | + 'example' => 'file.txt', |
|
380 | + ], |
|
381 | + ], |
|
382 | + ], |
|
383 | + 'systemtag' => [ |
|
384 | + 'author' => 'Nextcloud', |
|
385 | + 'app' => 'core', |
|
386 | + 'since' => '11.0.0', |
|
387 | + 'parameters' => [ |
|
388 | + 'id' => [ |
|
389 | + 'since' => '11.0.0', |
|
390 | + 'required' => true, |
|
391 | + 'description' => 'The id used to identify the systemtag on the instance', |
|
392 | + 'example' => '23', |
|
393 | + ], |
|
394 | + 'name' => [ |
|
395 | + 'since' => '11.0.0', |
|
396 | + 'required' => true, |
|
397 | + 'description' => 'The display name of the systemtag which should be used in the visual representation', |
|
398 | + 'example' => 'Project 1', |
|
399 | + ], |
|
400 | + 'visibility' => [ |
|
401 | + 'since' => '11.0.0', |
|
402 | + 'required' => true, |
|
403 | + 'description' => 'If the user can see the systemtag', |
|
404 | + 'example' => '1', |
|
405 | + ], |
|
406 | + 'assignable' => [ |
|
407 | + 'since' => '11.0.0', |
|
408 | + 'required' => true, |
|
409 | + 'description' => 'If the user can assign the systemtag', |
|
410 | + 'example' => '0', |
|
411 | + ], |
|
412 | + ], |
|
413 | + ], |
|
414 | + 'talk-attachment' => [ |
|
415 | + 'author' => 'Nextcloud', |
|
416 | + 'app' => 'talk', |
|
417 | + 'since' => '18.0.0', |
|
418 | + 'parameters' => [ |
|
419 | + 'id' => [ |
|
420 | + 'since' => '18.0.0', |
|
421 | + 'required' => true, |
|
422 | + 'description' => 'The id used to identify the attachment on the instance', |
|
423 | + 'example' => '12345', |
|
424 | + ], |
|
425 | + 'name' => [ |
|
426 | + 'since' => '18.0.0', |
|
427 | + 'required' => true, |
|
428 | + 'description' => 'The name of the attachment', |
|
429 | + 'example' => 'John Doe', |
|
430 | + ], |
|
431 | + 'conversation' => [ |
|
432 | + 'since' => '18.0.0', |
|
433 | + 'required' => true, |
|
434 | + 'description' => 'The token of the conversation', |
|
435 | + 'example' => 'a1b2c3d4', |
|
436 | + ], |
|
437 | + 'mimetype' => [ |
|
438 | + 'since' => '18.0.0', |
|
439 | + 'required' => false, |
|
440 | + 'description' => 'The mimetype of the file/folder to allow clients to show a placeholder', |
|
441 | + 'example' => 'text/plain', |
|
442 | + ], |
|
443 | + 'preview-available' => [ |
|
444 | + 'since' => '18.0.0', |
|
445 | + 'required' => false, |
|
446 | + 'description' => 'Whether or not a preview is available. If `no` the mimetype icon should be used', |
|
447 | + 'example' => 'yes', |
|
448 | + ], |
|
449 | + ], |
|
450 | + ], |
|
451 | + 'user' => [ |
|
452 | + 'author' => 'Nextcloud', |
|
453 | + 'app' => 'core', |
|
454 | + 'since' => '11.0.0', |
|
455 | + 'parameters' => [ |
|
456 | + 'id' => [ |
|
457 | + 'since' => '11.0.0', |
|
458 | + 'required' => true, |
|
459 | + 'description' => 'The id used to identify the user on the instance', |
|
460 | + 'example' => 'johndoe', |
|
461 | + ], |
|
462 | + 'name' => [ |
|
463 | + 'since' => '11.0.0', |
|
464 | + 'required' => true, |
|
465 | + 'description' => 'The display name of the user which should be used in the visual representation', |
|
466 | + 'example' => 'John Doe', |
|
467 | + ], |
|
468 | + 'server' => [ |
|
469 | + 'since' => '11.0.0', |
|
470 | + 'required' => false, |
|
471 | + 'description' => 'The URL of the instance the user lives on', |
|
472 | + 'example' => 'localhost', |
|
473 | + ], |
|
474 | + ], |
|
475 | + ], |
|
476 | + 'user-group' => [ |
|
477 | + 'author' => 'Nextcloud', |
|
478 | + 'app' => 'core', |
|
479 | + 'since' => '11.0.0', |
|
480 | + 'parameters' => [ |
|
481 | + 'id' => [ |
|
482 | + 'since' => '11.0.0', |
|
483 | + 'required' => true, |
|
484 | + 'description' => 'The id used to identify the group on the instance', |
|
485 | + 'example' => 'supportteam', |
|
486 | + ], |
|
487 | + 'name' => [ |
|
488 | + 'since' => '11.0.0', |
|
489 | + 'required' => true, |
|
490 | + 'description' => 'The display name of the group which should be used in the visual representation', |
|
491 | + 'example' => 'Support Team', |
|
492 | + ], |
|
493 | + ], |
|
494 | + ], |
|
495 | + ]; |
|
496 | 496 | |
497 | - /** |
|
498 | - * @param string $type |
|
499 | - * @return array |
|
500 | - * @throws InvalidObjectExeption |
|
501 | - * @since 11.0.0 |
|
502 | - */ |
|
503 | - public function getDefinition($type) { |
|
504 | - if (isset($this->definitions[$type])) { |
|
505 | - return $this->definitions[$type]; |
|
506 | - } |
|
497 | + /** |
|
498 | + * @param string $type |
|
499 | + * @return array |
|
500 | + * @throws InvalidObjectExeption |
|
501 | + * @since 11.0.0 |
|
502 | + */ |
|
503 | + public function getDefinition($type) { |
|
504 | + if (isset($this->definitions[$type])) { |
|
505 | + return $this->definitions[$type]; |
|
506 | + } |
|
507 | 507 | |
508 | - throw new InvalidObjectExeption('Object type is undefined'); |
|
509 | - } |
|
508 | + throw new InvalidObjectExeption('Object type is undefined'); |
|
509 | + } |
|
510 | 510 | } |
@@ -37,228 +37,228 @@ |
||
37 | 37 | use OCP\L10N\IFactory; |
38 | 38 | |
39 | 39 | class Calendar extends Base { |
40 | - public const SUBJECT_ADD = 'calendar_add'; |
|
41 | - public const SUBJECT_UPDATE = 'calendar_update'; |
|
42 | - public const SUBJECT_DELETE = 'calendar_delete'; |
|
43 | - public const SUBJECT_PUBLISH = 'calendar_publish'; |
|
44 | - public const SUBJECT_UNPUBLISH = 'calendar_unpublish'; |
|
45 | - public const SUBJECT_SHARE_USER = 'calendar_user_share'; |
|
46 | - public const SUBJECT_SHARE_GROUP = 'calendar_group_share'; |
|
47 | - public const SUBJECT_UNSHARE_USER = 'calendar_user_unshare'; |
|
48 | - public const SUBJECT_UNSHARE_GROUP = 'calendar_group_unshare'; |
|
40 | + public const SUBJECT_ADD = 'calendar_add'; |
|
41 | + public const SUBJECT_UPDATE = 'calendar_update'; |
|
42 | + public const SUBJECT_DELETE = 'calendar_delete'; |
|
43 | + public const SUBJECT_PUBLISH = 'calendar_publish'; |
|
44 | + public const SUBJECT_UNPUBLISH = 'calendar_unpublish'; |
|
45 | + public const SUBJECT_SHARE_USER = 'calendar_user_share'; |
|
46 | + public const SUBJECT_SHARE_GROUP = 'calendar_group_share'; |
|
47 | + public const SUBJECT_UNSHARE_USER = 'calendar_user_unshare'; |
|
48 | + public const SUBJECT_UNSHARE_GROUP = 'calendar_group_unshare'; |
|
49 | 49 | |
50 | - /** @var IFactory */ |
|
51 | - protected $languageFactory; |
|
50 | + /** @var IFactory */ |
|
51 | + protected $languageFactory; |
|
52 | 52 | |
53 | - /** @var IL10N */ |
|
54 | - protected $l; |
|
53 | + /** @var IL10N */ |
|
54 | + protected $l; |
|
55 | 55 | |
56 | - /** @var IManager */ |
|
57 | - protected $activityManager; |
|
56 | + /** @var IManager */ |
|
57 | + protected $activityManager; |
|
58 | 58 | |
59 | - /** @var IEventMerger */ |
|
60 | - protected $eventMerger; |
|
59 | + /** @var IEventMerger */ |
|
60 | + protected $eventMerger; |
|
61 | 61 | |
62 | - /** |
|
63 | - * @param IFactory $languageFactory |
|
64 | - * @param IURLGenerator $url |
|
65 | - * @param IManager $activityManager |
|
66 | - * @param IUserManager $userManager |
|
67 | - * @param IGroupManager $groupManager |
|
68 | - * @param IEventMerger $eventMerger |
|
69 | - */ |
|
70 | - public function __construct(IFactory $languageFactory, IURLGenerator $url, IManager $activityManager, IUserManager $userManager, IGroupManager $groupManager, IEventMerger $eventMerger) { |
|
71 | - parent::__construct($userManager, $groupManager, $url); |
|
72 | - $this->languageFactory = $languageFactory; |
|
73 | - $this->activityManager = $activityManager; |
|
74 | - $this->eventMerger = $eventMerger; |
|
75 | - } |
|
62 | + /** |
|
63 | + * @param IFactory $languageFactory |
|
64 | + * @param IURLGenerator $url |
|
65 | + * @param IManager $activityManager |
|
66 | + * @param IUserManager $userManager |
|
67 | + * @param IGroupManager $groupManager |
|
68 | + * @param IEventMerger $eventMerger |
|
69 | + */ |
|
70 | + public function __construct(IFactory $languageFactory, IURLGenerator $url, IManager $activityManager, IUserManager $userManager, IGroupManager $groupManager, IEventMerger $eventMerger) { |
|
71 | + parent::__construct($userManager, $groupManager, $url); |
|
72 | + $this->languageFactory = $languageFactory; |
|
73 | + $this->activityManager = $activityManager; |
|
74 | + $this->eventMerger = $eventMerger; |
|
75 | + } |
|
76 | 76 | |
77 | - /** |
|
78 | - * @param string $language |
|
79 | - * @param IEvent $event |
|
80 | - * @param IEvent|null $previousEvent |
|
81 | - * @return IEvent |
|
82 | - * @throws \InvalidArgumentException |
|
83 | - * @since 11.0.0 |
|
84 | - */ |
|
85 | - public function parse($language, IEvent $event, IEvent $previousEvent = null) { |
|
86 | - if ($event->getApp() !== 'dav' || $event->getType() !== 'calendar') { |
|
87 | - throw new \InvalidArgumentException(); |
|
88 | - } |
|
77 | + /** |
|
78 | + * @param string $language |
|
79 | + * @param IEvent $event |
|
80 | + * @param IEvent|null $previousEvent |
|
81 | + * @return IEvent |
|
82 | + * @throws \InvalidArgumentException |
|
83 | + * @since 11.0.0 |
|
84 | + */ |
|
85 | + public function parse($language, IEvent $event, IEvent $previousEvent = null) { |
|
86 | + if ($event->getApp() !== 'dav' || $event->getType() !== 'calendar') { |
|
87 | + throw new \InvalidArgumentException(); |
|
88 | + } |
|
89 | 89 | |
90 | - $this->l = $this->languageFactory->get('dav', $language); |
|
90 | + $this->l = $this->languageFactory->get('dav', $language); |
|
91 | 91 | |
92 | - if ($this->activityManager->getRequirePNG()) { |
|
93 | - $event->setIcon($this->url->getAbsoluteURL($this->url->imagePath('core', 'places/calendar-dark.png'))); |
|
94 | - } else { |
|
95 | - $event->setIcon($this->url->getAbsoluteURL($this->url->imagePath('core', 'places/calendar.svg'))); |
|
96 | - } |
|
92 | + if ($this->activityManager->getRequirePNG()) { |
|
93 | + $event->setIcon($this->url->getAbsoluteURL($this->url->imagePath('core', 'places/calendar-dark.png'))); |
|
94 | + } else { |
|
95 | + $event->setIcon($this->url->getAbsoluteURL($this->url->imagePath('core', 'places/calendar.svg'))); |
|
96 | + } |
|
97 | 97 | |
98 | - if ($event->getSubject() === self::SUBJECT_ADD) { |
|
99 | - $subject = $this->l->t('{actor} created calendar {calendar}'); |
|
100 | - } elseif ($event->getSubject() === self::SUBJECT_ADD . '_self') { |
|
101 | - $subject = $this->l->t('You created calendar {calendar}'); |
|
102 | - } elseif ($event->getSubject() === self::SUBJECT_DELETE) { |
|
103 | - $subject = $this->l->t('{actor} deleted calendar {calendar}'); |
|
104 | - } elseif ($event->getSubject() === self::SUBJECT_DELETE . '_self') { |
|
105 | - $subject = $this->l->t('You deleted calendar {calendar}'); |
|
106 | - } elseif ($event->getSubject() === self::SUBJECT_UPDATE) { |
|
107 | - $subject = $this->l->t('{actor} updated calendar {calendar}'); |
|
108 | - } elseif ($event->getSubject() === self::SUBJECT_UPDATE . '_self') { |
|
109 | - $subject = $this->l->t('You updated calendar {calendar}'); |
|
110 | - } elseif ($event->getSubject() === self::SUBJECT_PUBLISH . '_self') { |
|
111 | - $subject = $this->l->t('You shared calendar {calendar} as public link'); |
|
112 | - } elseif ($event->getSubject() === self::SUBJECT_UNPUBLISH . '_self') { |
|
113 | - $subject = $this->l->t('You removed public link for calendar {calendar}'); |
|
114 | - } elseif ($event->getSubject() === self::SUBJECT_SHARE_USER) { |
|
115 | - $subject = $this->l->t('{actor} shared calendar {calendar} with you'); |
|
116 | - } elseif ($event->getSubject() === self::SUBJECT_SHARE_USER . '_you') { |
|
117 | - $subject = $this->l->t('You shared calendar {calendar} with {user}'); |
|
118 | - } elseif ($event->getSubject() === self::SUBJECT_SHARE_USER . '_by') { |
|
119 | - $subject = $this->l->t('{actor} shared calendar {calendar} with {user}'); |
|
120 | - } elseif ($event->getSubject() === self::SUBJECT_UNSHARE_USER) { |
|
121 | - $subject = $this->l->t('{actor} unshared calendar {calendar} from you'); |
|
122 | - } elseif ($event->getSubject() === self::SUBJECT_UNSHARE_USER . '_you') { |
|
123 | - $subject = $this->l->t('You unshared calendar {calendar} from {user}'); |
|
124 | - } elseif ($event->getSubject() === self::SUBJECT_UNSHARE_USER . '_by') { |
|
125 | - $subject = $this->l->t('{actor} unshared calendar {calendar} from {user}'); |
|
126 | - } elseif ($event->getSubject() === self::SUBJECT_UNSHARE_USER . '_self') { |
|
127 | - $subject = $this->l->t('{actor} unshared calendar {calendar} from themselves'); |
|
128 | - } elseif ($event->getSubject() === self::SUBJECT_SHARE_GROUP . '_you') { |
|
129 | - $subject = $this->l->t('You shared calendar {calendar} with group {group}'); |
|
130 | - } elseif ($event->getSubject() === self::SUBJECT_SHARE_GROUP . '_by') { |
|
131 | - $subject = $this->l->t('{actor} shared calendar {calendar} with group {group}'); |
|
132 | - } elseif ($event->getSubject() === self::SUBJECT_UNSHARE_GROUP . '_you') { |
|
133 | - $subject = $this->l->t('You unshared calendar {calendar} from group {group}'); |
|
134 | - } elseif ($event->getSubject() === self::SUBJECT_UNSHARE_GROUP . '_by') { |
|
135 | - $subject = $this->l->t('{actor} unshared calendar {calendar} from group {group}'); |
|
136 | - } else { |
|
137 | - throw new \InvalidArgumentException(); |
|
138 | - } |
|
98 | + if ($event->getSubject() === self::SUBJECT_ADD) { |
|
99 | + $subject = $this->l->t('{actor} created calendar {calendar}'); |
|
100 | + } elseif ($event->getSubject() === self::SUBJECT_ADD . '_self') { |
|
101 | + $subject = $this->l->t('You created calendar {calendar}'); |
|
102 | + } elseif ($event->getSubject() === self::SUBJECT_DELETE) { |
|
103 | + $subject = $this->l->t('{actor} deleted calendar {calendar}'); |
|
104 | + } elseif ($event->getSubject() === self::SUBJECT_DELETE . '_self') { |
|
105 | + $subject = $this->l->t('You deleted calendar {calendar}'); |
|
106 | + } elseif ($event->getSubject() === self::SUBJECT_UPDATE) { |
|
107 | + $subject = $this->l->t('{actor} updated calendar {calendar}'); |
|
108 | + } elseif ($event->getSubject() === self::SUBJECT_UPDATE . '_self') { |
|
109 | + $subject = $this->l->t('You updated calendar {calendar}'); |
|
110 | + } elseif ($event->getSubject() === self::SUBJECT_PUBLISH . '_self') { |
|
111 | + $subject = $this->l->t('You shared calendar {calendar} as public link'); |
|
112 | + } elseif ($event->getSubject() === self::SUBJECT_UNPUBLISH . '_self') { |
|
113 | + $subject = $this->l->t('You removed public link for calendar {calendar}'); |
|
114 | + } elseif ($event->getSubject() === self::SUBJECT_SHARE_USER) { |
|
115 | + $subject = $this->l->t('{actor} shared calendar {calendar} with you'); |
|
116 | + } elseif ($event->getSubject() === self::SUBJECT_SHARE_USER . '_you') { |
|
117 | + $subject = $this->l->t('You shared calendar {calendar} with {user}'); |
|
118 | + } elseif ($event->getSubject() === self::SUBJECT_SHARE_USER . '_by') { |
|
119 | + $subject = $this->l->t('{actor} shared calendar {calendar} with {user}'); |
|
120 | + } elseif ($event->getSubject() === self::SUBJECT_UNSHARE_USER) { |
|
121 | + $subject = $this->l->t('{actor} unshared calendar {calendar} from you'); |
|
122 | + } elseif ($event->getSubject() === self::SUBJECT_UNSHARE_USER . '_you') { |
|
123 | + $subject = $this->l->t('You unshared calendar {calendar} from {user}'); |
|
124 | + } elseif ($event->getSubject() === self::SUBJECT_UNSHARE_USER . '_by') { |
|
125 | + $subject = $this->l->t('{actor} unshared calendar {calendar} from {user}'); |
|
126 | + } elseif ($event->getSubject() === self::SUBJECT_UNSHARE_USER . '_self') { |
|
127 | + $subject = $this->l->t('{actor} unshared calendar {calendar} from themselves'); |
|
128 | + } elseif ($event->getSubject() === self::SUBJECT_SHARE_GROUP . '_you') { |
|
129 | + $subject = $this->l->t('You shared calendar {calendar} with group {group}'); |
|
130 | + } elseif ($event->getSubject() === self::SUBJECT_SHARE_GROUP . '_by') { |
|
131 | + $subject = $this->l->t('{actor} shared calendar {calendar} with group {group}'); |
|
132 | + } elseif ($event->getSubject() === self::SUBJECT_UNSHARE_GROUP . '_you') { |
|
133 | + $subject = $this->l->t('You unshared calendar {calendar} from group {group}'); |
|
134 | + } elseif ($event->getSubject() === self::SUBJECT_UNSHARE_GROUP . '_by') { |
|
135 | + $subject = $this->l->t('{actor} unshared calendar {calendar} from group {group}'); |
|
136 | + } else { |
|
137 | + throw new \InvalidArgumentException(); |
|
138 | + } |
|
139 | 139 | |
140 | - $parsedParameters = $this->getParameters($event); |
|
141 | - $this->setSubjects($event, $subject, $parsedParameters); |
|
140 | + $parsedParameters = $this->getParameters($event); |
|
141 | + $this->setSubjects($event, $subject, $parsedParameters); |
|
142 | 142 | |
143 | - $event = $this->eventMerger->mergeEvents('calendar', $event, $previousEvent); |
|
143 | + $event = $this->eventMerger->mergeEvents('calendar', $event, $previousEvent); |
|
144 | 144 | |
145 | - if ($event->getChildEvent() === null) { |
|
146 | - if (isset($parsedParameters['user'])) { |
|
147 | - // Couldn't group by calendar, maybe we can group by users |
|
148 | - $event = $this->eventMerger->mergeEvents('user', $event, $previousEvent); |
|
149 | - } elseif (isset($parsedParameters['group'])) { |
|
150 | - // Couldn't group by calendar, maybe we can group by groups |
|
151 | - $event = $this->eventMerger->mergeEvents('group', $event, $previousEvent); |
|
152 | - } |
|
153 | - } |
|
145 | + if ($event->getChildEvent() === null) { |
|
146 | + if (isset($parsedParameters['user'])) { |
|
147 | + // Couldn't group by calendar, maybe we can group by users |
|
148 | + $event = $this->eventMerger->mergeEvents('user', $event, $previousEvent); |
|
149 | + } elseif (isset($parsedParameters['group'])) { |
|
150 | + // Couldn't group by calendar, maybe we can group by groups |
|
151 | + $event = $this->eventMerger->mergeEvents('group', $event, $previousEvent); |
|
152 | + } |
|
153 | + } |
|
154 | 154 | |
155 | - return $event; |
|
156 | - } |
|
155 | + return $event; |
|
156 | + } |
|
157 | 157 | |
158 | - /** |
|
159 | - * @param IEvent $event |
|
160 | - * @return array |
|
161 | - */ |
|
162 | - protected function getParameters(IEvent $event) { |
|
163 | - $subject = $event->getSubject(); |
|
164 | - $parameters = $event->getSubjectParameters(); |
|
158 | + /** |
|
159 | + * @param IEvent $event |
|
160 | + * @return array |
|
161 | + */ |
|
162 | + protected function getParameters(IEvent $event) { |
|
163 | + $subject = $event->getSubject(); |
|
164 | + $parameters = $event->getSubjectParameters(); |
|
165 | 165 | |
166 | - // Nextcloud 13+ |
|
167 | - if (isset($parameters['calendar'])) { |
|
168 | - switch ($subject) { |
|
169 | - case self::SUBJECT_ADD: |
|
170 | - case self::SUBJECT_ADD . '_self': |
|
171 | - case self::SUBJECT_DELETE: |
|
172 | - case self::SUBJECT_DELETE . '_self': |
|
173 | - case self::SUBJECT_UPDATE: |
|
174 | - case self::SUBJECT_UPDATE . '_self': |
|
175 | - case self::SUBJECT_PUBLISH . '_self': |
|
176 | - case self::SUBJECT_UNPUBLISH . '_self': |
|
177 | - case self::SUBJECT_SHARE_USER: |
|
178 | - case self::SUBJECT_UNSHARE_USER: |
|
179 | - case self::SUBJECT_UNSHARE_USER . '_self': |
|
180 | - return [ |
|
181 | - 'actor' => $this->generateUserParameter($parameters['actor']), |
|
182 | - 'calendar' => $this->generateCalendarParameter($parameters['calendar'], $this->l), |
|
183 | - ]; |
|
184 | - case self::SUBJECT_SHARE_USER . '_you': |
|
185 | - case self::SUBJECT_UNSHARE_USER . '_you': |
|
186 | - return [ |
|
187 | - 'calendar' => $this->generateCalendarParameter($parameters['calendar'], $this->l), |
|
188 | - 'user' => $this->generateUserParameter($parameters['user']), |
|
189 | - ]; |
|
190 | - case self::SUBJECT_SHARE_USER . '_by': |
|
191 | - case self::SUBJECT_UNSHARE_USER . '_by': |
|
192 | - return [ |
|
193 | - 'actor' => $this->generateUserParameter($parameters['actor']), |
|
194 | - 'calendar' => $this->generateCalendarParameter($parameters['calendar'], $this->l), |
|
195 | - 'user' => $this->generateUserParameter($parameters['user']), |
|
196 | - ]; |
|
197 | - case self::SUBJECT_SHARE_GROUP . '_you': |
|
198 | - case self::SUBJECT_UNSHARE_GROUP . '_you': |
|
199 | - return [ |
|
200 | - 'calendar' => $this->generateCalendarParameter($parameters['calendar'], $this->l), |
|
201 | - 'group' => $this->generateGroupParameter($parameters['group']), |
|
202 | - ]; |
|
203 | - case self::SUBJECT_SHARE_GROUP . '_by': |
|
204 | - case self::SUBJECT_UNSHARE_GROUP . '_by': |
|
205 | - return [ |
|
206 | - 'actor' => $this->generateUserParameter($parameters['actor']), |
|
207 | - 'calendar' => $this->generateCalendarParameter($parameters['calendar'], $this->l), |
|
208 | - 'group' => $this->generateGroupParameter($parameters['group']), |
|
209 | - ]; |
|
210 | - } |
|
211 | - } |
|
166 | + // Nextcloud 13+ |
|
167 | + if (isset($parameters['calendar'])) { |
|
168 | + switch ($subject) { |
|
169 | + case self::SUBJECT_ADD: |
|
170 | + case self::SUBJECT_ADD . '_self': |
|
171 | + case self::SUBJECT_DELETE: |
|
172 | + case self::SUBJECT_DELETE . '_self': |
|
173 | + case self::SUBJECT_UPDATE: |
|
174 | + case self::SUBJECT_UPDATE . '_self': |
|
175 | + case self::SUBJECT_PUBLISH . '_self': |
|
176 | + case self::SUBJECT_UNPUBLISH . '_self': |
|
177 | + case self::SUBJECT_SHARE_USER: |
|
178 | + case self::SUBJECT_UNSHARE_USER: |
|
179 | + case self::SUBJECT_UNSHARE_USER . '_self': |
|
180 | + return [ |
|
181 | + 'actor' => $this->generateUserParameter($parameters['actor']), |
|
182 | + 'calendar' => $this->generateCalendarParameter($parameters['calendar'], $this->l), |
|
183 | + ]; |
|
184 | + case self::SUBJECT_SHARE_USER . '_you': |
|
185 | + case self::SUBJECT_UNSHARE_USER . '_you': |
|
186 | + return [ |
|
187 | + 'calendar' => $this->generateCalendarParameter($parameters['calendar'], $this->l), |
|
188 | + 'user' => $this->generateUserParameter($parameters['user']), |
|
189 | + ]; |
|
190 | + case self::SUBJECT_SHARE_USER . '_by': |
|
191 | + case self::SUBJECT_UNSHARE_USER . '_by': |
|
192 | + return [ |
|
193 | + 'actor' => $this->generateUserParameter($parameters['actor']), |
|
194 | + 'calendar' => $this->generateCalendarParameter($parameters['calendar'], $this->l), |
|
195 | + 'user' => $this->generateUserParameter($parameters['user']), |
|
196 | + ]; |
|
197 | + case self::SUBJECT_SHARE_GROUP . '_you': |
|
198 | + case self::SUBJECT_UNSHARE_GROUP . '_you': |
|
199 | + return [ |
|
200 | + 'calendar' => $this->generateCalendarParameter($parameters['calendar'], $this->l), |
|
201 | + 'group' => $this->generateGroupParameter($parameters['group']), |
|
202 | + ]; |
|
203 | + case self::SUBJECT_SHARE_GROUP . '_by': |
|
204 | + case self::SUBJECT_UNSHARE_GROUP . '_by': |
|
205 | + return [ |
|
206 | + 'actor' => $this->generateUserParameter($parameters['actor']), |
|
207 | + 'calendar' => $this->generateCalendarParameter($parameters['calendar'], $this->l), |
|
208 | + 'group' => $this->generateGroupParameter($parameters['group']), |
|
209 | + ]; |
|
210 | + } |
|
211 | + } |
|
212 | 212 | |
213 | - // Legacy - Do NOT Remove unless necessary |
|
214 | - // Removing this will break parsing of activities that were created on |
|
215 | - // Nextcloud 12, so we should keep this as long as it's acceptable. |
|
216 | - // Otherwise if people upgrade over multiple releases in a short period, |
|
217 | - // they will get the dead entries in their stream. |
|
218 | - switch ($subject) { |
|
219 | - case self::SUBJECT_ADD: |
|
220 | - case self::SUBJECT_ADD . '_self': |
|
221 | - case self::SUBJECT_DELETE: |
|
222 | - case self::SUBJECT_DELETE . '_self': |
|
223 | - case self::SUBJECT_UPDATE: |
|
224 | - case self::SUBJECT_UPDATE . '_self': |
|
225 | - case self::SUBJECT_PUBLISH . '_self': |
|
226 | - case self::SUBJECT_UNPUBLISH . '_self': |
|
227 | - case self::SUBJECT_SHARE_USER: |
|
228 | - case self::SUBJECT_UNSHARE_USER: |
|
229 | - case self::SUBJECT_UNSHARE_USER . '_self': |
|
230 | - return [ |
|
231 | - 'actor' => $this->generateUserParameter($parameters[0]), |
|
232 | - 'calendar' => $this->generateLegacyCalendarParameter((int)$event->getObjectId(), $parameters[1]), |
|
233 | - ]; |
|
234 | - case self::SUBJECT_SHARE_USER . '_you': |
|
235 | - case self::SUBJECT_UNSHARE_USER . '_you': |
|
236 | - return [ |
|
237 | - 'user' => $this->generateUserParameter($parameters[0]), |
|
238 | - 'calendar' => $this->generateLegacyCalendarParameter((int)$event->getObjectId(), $parameters[1]), |
|
239 | - ]; |
|
240 | - case self::SUBJECT_SHARE_USER . '_by': |
|
241 | - case self::SUBJECT_UNSHARE_USER . '_by': |
|
242 | - return [ |
|
243 | - 'user' => $this->generateUserParameter($parameters[0]), |
|
244 | - 'calendar' => $this->generateLegacyCalendarParameter((int)$event->getObjectId(), $parameters[1]), |
|
245 | - 'actor' => $this->generateUserParameter($parameters[2]), |
|
246 | - ]; |
|
247 | - case self::SUBJECT_SHARE_GROUP . '_you': |
|
248 | - case self::SUBJECT_UNSHARE_GROUP . '_you': |
|
249 | - return [ |
|
250 | - 'group' => $this->generateGroupParameter($parameters[0]), |
|
251 | - 'calendar' => $this->generateLegacyCalendarParameter((int)$event->getObjectId(), $parameters[1]), |
|
252 | - ]; |
|
253 | - case self::SUBJECT_SHARE_GROUP . '_by': |
|
254 | - case self::SUBJECT_UNSHARE_GROUP . '_by': |
|
255 | - return [ |
|
256 | - 'group' => $this->generateGroupParameter($parameters[0]), |
|
257 | - 'calendar' => $this->generateLegacyCalendarParameter((int)$event->getObjectId(), $parameters[1]), |
|
258 | - 'actor' => $this->generateUserParameter($parameters[2]), |
|
259 | - ]; |
|
260 | - } |
|
213 | + // Legacy - Do NOT Remove unless necessary |
|
214 | + // Removing this will break parsing of activities that were created on |
|
215 | + // Nextcloud 12, so we should keep this as long as it's acceptable. |
|
216 | + // Otherwise if people upgrade over multiple releases in a short period, |
|
217 | + // they will get the dead entries in their stream. |
|
218 | + switch ($subject) { |
|
219 | + case self::SUBJECT_ADD: |
|
220 | + case self::SUBJECT_ADD . '_self': |
|
221 | + case self::SUBJECT_DELETE: |
|
222 | + case self::SUBJECT_DELETE . '_self': |
|
223 | + case self::SUBJECT_UPDATE: |
|
224 | + case self::SUBJECT_UPDATE . '_self': |
|
225 | + case self::SUBJECT_PUBLISH . '_self': |
|
226 | + case self::SUBJECT_UNPUBLISH . '_self': |
|
227 | + case self::SUBJECT_SHARE_USER: |
|
228 | + case self::SUBJECT_UNSHARE_USER: |
|
229 | + case self::SUBJECT_UNSHARE_USER . '_self': |
|
230 | + return [ |
|
231 | + 'actor' => $this->generateUserParameter($parameters[0]), |
|
232 | + 'calendar' => $this->generateLegacyCalendarParameter((int)$event->getObjectId(), $parameters[1]), |
|
233 | + ]; |
|
234 | + case self::SUBJECT_SHARE_USER . '_you': |
|
235 | + case self::SUBJECT_UNSHARE_USER . '_you': |
|
236 | + return [ |
|
237 | + 'user' => $this->generateUserParameter($parameters[0]), |
|
238 | + 'calendar' => $this->generateLegacyCalendarParameter((int)$event->getObjectId(), $parameters[1]), |
|
239 | + ]; |
|
240 | + case self::SUBJECT_SHARE_USER . '_by': |
|
241 | + case self::SUBJECT_UNSHARE_USER . '_by': |
|
242 | + return [ |
|
243 | + 'user' => $this->generateUserParameter($parameters[0]), |
|
244 | + 'calendar' => $this->generateLegacyCalendarParameter((int)$event->getObjectId(), $parameters[1]), |
|
245 | + 'actor' => $this->generateUserParameter($parameters[2]), |
|
246 | + ]; |
|
247 | + case self::SUBJECT_SHARE_GROUP . '_you': |
|
248 | + case self::SUBJECT_UNSHARE_GROUP . '_you': |
|
249 | + return [ |
|
250 | + 'group' => $this->generateGroupParameter($parameters[0]), |
|
251 | + 'calendar' => $this->generateLegacyCalendarParameter((int)$event->getObjectId(), $parameters[1]), |
|
252 | + ]; |
|
253 | + case self::SUBJECT_SHARE_GROUP . '_by': |
|
254 | + case self::SUBJECT_UNSHARE_GROUP . '_by': |
|
255 | + return [ |
|
256 | + 'group' => $this->generateGroupParameter($parameters[0]), |
|
257 | + 'calendar' => $this->generateLegacyCalendarParameter((int)$event->getObjectId(), $parameters[1]), |
|
258 | + 'actor' => $this->generateUserParameter($parameters[2]), |
|
259 | + ]; |
|
260 | + } |
|
261 | 261 | |
262 | - throw new \InvalidArgumentException(); |
|
263 | - } |
|
262 | + throw new \InvalidArgumentException(); |
|
263 | + } |
|
264 | 264 | } |
@@ -36,136 +36,136 @@ |
||
36 | 36 | |
37 | 37 | abstract class Base implements IProvider { |
38 | 38 | |
39 | - /** @var IUserManager */ |
|
40 | - protected $userManager; |
|
41 | - |
|
42 | - /** @var string[] */ |
|
43 | - protected $userDisplayNames = []; |
|
44 | - |
|
45 | - /** @var IGroupManager */ |
|
46 | - protected $groupManager; |
|
47 | - |
|
48 | - /** @var string[] */ |
|
49 | - protected $groupDisplayNames = []; |
|
50 | - |
|
51 | - /** @var IURLGenerator */ |
|
52 | - protected $url; |
|
53 | - |
|
54 | - /** |
|
55 | - * @param IUserManager $userManager |
|
56 | - * @param IGroupManager $groupManager |
|
57 | - * @param IURLGenerator $urlGenerator |
|
58 | - */ |
|
59 | - public function __construct(IUserManager $userManager, IGroupManager $groupManager, IURLGenerator $urlGenerator) { |
|
60 | - $this->userManager = $userManager; |
|
61 | - $this->groupManager = $groupManager; |
|
62 | - $this->url = $urlGenerator; |
|
63 | - } |
|
64 | - |
|
65 | - /** |
|
66 | - * @param IEvent $event |
|
67 | - * @param string $subject |
|
68 | - * @param array $parameters |
|
69 | - */ |
|
70 | - protected function setSubjects(IEvent $event, $subject, array $parameters) { |
|
71 | - $placeholders = $replacements = []; |
|
72 | - foreach ($parameters as $placeholder => $parameter) { |
|
73 | - $placeholders[] = '{' . $placeholder . '}'; |
|
74 | - $replacements[] = $parameter['name']; |
|
75 | - } |
|
76 | - |
|
77 | - $event->setParsedSubject(str_replace($placeholders, $replacements, $subject)) |
|
78 | - ->setRichSubject($subject, $parameters); |
|
79 | - } |
|
80 | - |
|
81 | - /** |
|
82 | - * @param array $data |
|
83 | - * @param IL10N $l |
|
84 | - * @return array |
|
85 | - */ |
|
86 | - protected function generateCalendarParameter($data, IL10N $l) { |
|
87 | - if ($data['uri'] === CalDavBackend::PERSONAL_CALENDAR_URI && |
|
88 | - $data['name'] === CalDavBackend::PERSONAL_CALENDAR_NAME) { |
|
89 | - return [ |
|
90 | - 'type' => 'calendar', |
|
91 | - 'id' => $data['id'], |
|
92 | - 'name' => $l->t('Personal'), |
|
93 | - ]; |
|
94 | - } |
|
95 | - |
|
96 | - return [ |
|
97 | - 'type' => 'calendar', |
|
98 | - 'id' => $data['id'], |
|
99 | - 'name' => $data['name'], |
|
100 | - ]; |
|
101 | - } |
|
102 | - |
|
103 | - /** |
|
104 | - * @param int $id |
|
105 | - * @param string $name |
|
106 | - * @return array |
|
107 | - */ |
|
108 | - protected function generateLegacyCalendarParameter($id, $name) { |
|
109 | - return [ |
|
110 | - 'type' => 'calendar', |
|
111 | - 'id' => $id, |
|
112 | - 'name' => $name, |
|
113 | - ]; |
|
114 | - } |
|
115 | - |
|
116 | - /** |
|
117 | - * @param string $uid |
|
118 | - * @return array |
|
119 | - */ |
|
120 | - protected function generateUserParameter($uid) { |
|
121 | - if (!isset($this->userDisplayNames[$uid])) { |
|
122 | - $this->userDisplayNames[$uid] = $this->getUserDisplayName($uid); |
|
123 | - } |
|
124 | - |
|
125 | - return [ |
|
126 | - 'type' => 'user', |
|
127 | - 'id' => $uid, |
|
128 | - 'name' => $this->userDisplayNames[$uid], |
|
129 | - ]; |
|
130 | - } |
|
131 | - |
|
132 | - /** |
|
133 | - * @param string $uid |
|
134 | - * @return string |
|
135 | - */ |
|
136 | - protected function getUserDisplayName($uid) { |
|
137 | - $user = $this->userManager->get($uid); |
|
138 | - if ($user instanceof IUser) { |
|
139 | - return $user->getDisplayName(); |
|
140 | - } |
|
141 | - return $uid; |
|
142 | - } |
|
143 | - |
|
144 | - /** |
|
145 | - * @param string $gid |
|
146 | - * @return array |
|
147 | - */ |
|
148 | - protected function generateGroupParameter($gid) { |
|
149 | - if (!isset($this->groupDisplayNames[$gid])) { |
|
150 | - $this->groupDisplayNames[$gid] = $this->getGroupDisplayName($gid); |
|
151 | - } |
|
152 | - |
|
153 | - return [ |
|
154 | - 'type' => 'user-group', |
|
155 | - 'id' => $gid, |
|
156 | - 'name' => $this->groupDisplayNames[$gid], |
|
157 | - ]; |
|
158 | - } |
|
159 | - |
|
160 | - /** |
|
161 | - * @param string $gid |
|
162 | - * @return string |
|
163 | - */ |
|
164 | - protected function getGroupDisplayName($gid) { |
|
165 | - $group = $this->groupManager->get($gid); |
|
166 | - if ($group instanceof IGroup) { |
|
167 | - return $group->getDisplayName(); |
|
168 | - } |
|
169 | - return $gid; |
|
170 | - } |
|
39 | + /** @var IUserManager */ |
|
40 | + protected $userManager; |
|
41 | + |
|
42 | + /** @var string[] */ |
|
43 | + protected $userDisplayNames = []; |
|
44 | + |
|
45 | + /** @var IGroupManager */ |
|
46 | + protected $groupManager; |
|
47 | + |
|
48 | + /** @var string[] */ |
|
49 | + protected $groupDisplayNames = []; |
|
50 | + |
|
51 | + /** @var IURLGenerator */ |
|
52 | + protected $url; |
|
53 | + |
|
54 | + /** |
|
55 | + * @param IUserManager $userManager |
|
56 | + * @param IGroupManager $groupManager |
|
57 | + * @param IURLGenerator $urlGenerator |
|
58 | + */ |
|
59 | + public function __construct(IUserManager $userManager, IGroupManager $groupManager, IURLGenerator $urlGenerator) { |
|
60 | + $this->userManager = $userManager; |
|
61 | + $this->groupManager = $groupManager; |
|
62 | + $this->url = $urlGenerator; |
|
63 | + } |
|
64 | + |
|
65 | + /** |
|
66 | + * @param IEvent $event |
|
67 | + * @param string $subject |
|
68 | + * @param array $parameters |
|
69 | + */ |
|
70 | + protected function setSubjects(IEvent $event, $subject, array $parameters) { |
|
71 | + $placeholders = $replacements = []; |
|
72 | + foreach ($parameters as $placeholder => $parameter) { |
|
73 | + $placeholders[] = '{' . $placeholder . '}'; |
|
74 | + $replacements[] = $parameter['name']; |
|
75 | + } |
|
76 | + |
|
77 | + $event->setParsedSubject(str_replace($placeholders, $replacements, $subject)) |
|
78 | + ->setRichSubject($subject, $parameters); |
|
79 | + } |
|
80 | + |
|
81 | + /** |
|
82 | + * @param array $data |
|
83 | + * @param IL10N $l |
|
84 | + * @return array |
|
85 | + */ |
|
86 | + protected function generateCalendarParameter($data, IL10N $l) { |
|
87 | + if ($data['uri'] === CalDavBackend::PERSONAL_CALENDAR_URI && |
|
88 | + $data['name'] === CalDavBackend::PERSONAL_CALENDAR_NAME) { |
|
89 | + return [ |
|
90 | + 'type' => 'calendar', |
|
91 | + 'id' => $data['id'], |
|
92 | + 'name' => $l->t('Personal'), |
|
93 | + ]; |
|
94 | + } |
|
95 | + |
|
96 | + return [ |
|
97 | + 'type' => 'calendar', |
|
98 | + 'id' => $data['id'], |
|
99 | + 'name' => $data['name'], |
|
100 | + ]; |
|
101 | + } |
|
102 | + |
|
103 | + /** |
|
104 | + * @param int $id |
|
105 | + * @param string $name |
|
106 | + * @return array |
|
107 | + */ |
|
108 | + protected function generateLegacyCalendarParameter($id, $name) { |
|
109 | + return [ |
|
110 | + 'type' => 'calendar', |
|
111 | + 'id' => $id, |
|
112 | + 'name' => $name, |
|
113 | + ]; |
|
114 | + } |
|
115 | + |
|
116 | + /** |
|
117 | + * @param string $uid |
|
118 | + * @return array |
|
119 | + */ |
|
120 | + protected function generateUserParameter($uid) { |
|
121 | + if (!isset($this->userDisplayNames[$uid])) { |
|
122 | + $this->userDisplayNames[$uid] = $this->getUserDisplayName($uid); |
|
123 | + } |
|
124 | + |
|
125 | + return [ |
|
126 | + 'type' => 'user', |
|
127 | + 'id' => $uid, |
|
128 | + 'name' => $this->userDisplayNames[$uid], |
|
129 | + ]; |
|
130 | + } |
|
131 | + |
|
132 | + /** |
|
133 | + * @param string $uid |
|
134 | + * @return string |
|
135 | + */ |
|
136 | + protected function getUserDisplayName($uid) { |
|
137 | + $user = $this->userManager->get($uid); |
|
138 | + if ($user instanceof IUser) { |
|
139 | + return $user->getDisplayName(); |
|
140 | + } |
|
141 | + return $uid; |
|
142 | + } |
|
143 | + |
|
144 | + /** |
|
145 | + * @param string $gid |
|
146 | + * @return array |
|
147 | + */ |
|
148 | + protected function generateGroupParameter($gid) { |
|
149 | + if (!isset($this->groupDisplayNames[$gid])) { |
|
150 | + $this->groupDisplayNames[$gid] = $this->getGroupDisplayName($gid); |
|
151 | + } |
|
152 | + |
|
153 | + return [ |
|
154 | + 'type' => 'user-group', |
|
155 | + 'id' => $gid, |
|
156 | + 'name' => $this->groupDisplayNames[$gid], |
|
157 | + ]; |
|
158 | + } |
|
159 | + |
|
160 | + /** |
|
161 | + * @param string $gid |
|
162 | + * @return string |
|
163 | + */ |
|
164 | + protected function getGroupDisplayName($gid) { |
|
165 | + $group = $this->groupManager->get($gid); |
|
166 | + if ($group instanceof IGroup) { |
|
167 | + return $group->getDisplayName(); |
|
168 | + } |
|
169 | + return $gid; |
|
170 | + } |
|
171 | 171 | } |
@@ -38,183 +38,183 @@ |
||
38 | 38 | use OCP\L10N\IFactory; |
39 | 39 | |
40 | 40 | class Event extends Base { |
41 | - public const SUBJECT_OBJECT_ADD = 'object_add'; |
|
42 | - public const SUBJECT_OBJECT_UPDATE = 'object_update'; |
|
43 | - public const SUBJECT_OBJECT_DELETE = 'object_delete'; |
|
44 | - |
|
45 | - /** @var IFactory */ |
|
46 | - protected $languageFactory; |
|
47 | - |
|
48 | - /** @var IL10N */ |
|
49 | - protected $l; |
|
50 | - |
|
51 | - /** @var IManager */ |
|
52 | - protected $activityManager; |
|
53 | - |
|
54 | - /** @var IEventMerger */ |
|
55 | - protected $eventMerger; |
|
56 | - |
|
57 | - /** @var IAppManager */ |
|
58 | - protected $appManager; |
|
59 | - |
|
60 | - /** |
|
61 | - * @param IFactory $languageFactory |
|
62 | - * @param IURLGenerator $url |
|
63 | - * @param IManager $activityManager |
|
64 | - * @param IUserManager $userManager |
|
65 | - * @param IGroupManager $groupManager |
|
66 | - * @param IEventMerger $eventMerger |
|
67 | - * @param IAppManager $appManager |
|
68 | - */ |
|
69 | - public function __construct(IFactory $languageFactory, IURLGenerator $url, IManager $activityManager, IUserManager $userManager, IGroupManager $groupManager, IEventMerger $eventMerger, IAppManager $appManager) { |
|
70 | - parent::__construct($userManager, $groupManager, $url); |
|
71 | - $this->languageFactory = $languageFactory; |
|
72 | - $this->activityManager = $activityManager; |
|
73 | - $this->eventMerger = $eventMerger; |
|
74 | - $this->appManager = $appManager; |
|
75 | - } |
|
76 | - |
|
77 | - /** |
|
78 | - * @param array $eventData |
|
79 | - * @return array |
|
80 | - */ |
|
81 | - protected function generateObjectParameter(array $eventData) { |
|
82 | - if (!isset($eventData['id']) || !isset($eventData['name'])) { |
|
83 | - throw new \InvalidArgumentException(); |
|
84 | - } |
|
85 | - |
|
86 | - $params = [ |
|
87 | - 'type' => 'calendar-event', |
|
88 | - 'id' => $eventData['id'], |
|
89 | - 'name' => $eventData['name'], |
|
90 | - |
|
91 | - ]; |
|
92 | - if (isset($eventData['link']) && is_array($eventData['link']) && $this->appManager->isEnabledForUser('calendar')) { |
|
93 | - try { |
|
94 | - // The calendar app needs to be manually loaded for the routes to be loaded |
|
95 | - OC_App::loadApp('calendar'); |
|
96 | - $linkData = $eventData['link']; |
|
97 | - $objectId = base64_encode('/remote.php/dav/calendars/' . $linkData['owner'] . '/' . $linkData['calendar_uri'] . '/' . $linkData['object_uri']); |
|
98 | - $link = [ |
|
99 | - 'view' => 'dayGridMonth', |
|
100 | - 'timeRange' => 'now', |
|
101 | - 'mode' => 'sidebar', |
|
102 | - 'objectId' => $objectId, |
|
103 | - 'recurrenceId' => 'next' |
|
104 | - ]; |
|
105 | - $params['link'] = $this->url->linkToRouteAbsolute('calendar.view.indexview.timerange.edit', $link); |
|
106 | - } catch (\Exception $error) { |
|
107 | - // Do nothing |
|
108 | - } |
|
109 | - } |
|
110 | - return $params; |
|
111 | - } |
|
112 | - |
|
113 | - /** |
|
114 | - * @param string $language |
|
115 | - * @param IEvent $event |
|
116 | - * @param IEvent|null $previousEvent |
|
117 | - * @return IEvent |
|
118 | - * @throws \InvalidArgumentException |
|
119 | - * @since 11.0.0 |
|
120 | - */ |
|
121 | - public function parse($language, IEvent $event, IEvent $previousEvent = null) { |
|
122 | - if ($event->getApp() !== 'dav' || $event->getType() !== 'calendar_event') { |
|
123 | - throw new \InvalidArgumentException(); |
|
124 | - } |
|
125 | - |
|
126 | - $this->l = $this->languageFactory->get('dav', $language); |
|
127 | - |
|
128 | - if ($this->activityManager->getRequirePNG()) { |
|
129 | - $event->setIcon($this->url->getAbsoluteURL($this->url->imagePath('core', 'places/calendar-dark.png'))); |
|
130 | - } else { |
|
131 | - $event->setIcon($this->url->getAbsoluteURL($this->url->imagePath('core', 'places/calendar.svg'))); |
|
132 | - } |
|
133 | - |
|
134 | - if ($event->getSubject() === self::SUBJECT_OBJECT_ADD . '_event') { |
|
135 | - $subject = $this->l->t('{actor} created event {event} in calendar {calendar}'); |
|
136 | - } elseif ($event->getSubject() === self::SUBJECT_OBJECT_ADD . '_event_self') { |
|
137 | - $subject = $this->l->t('You created event {event} in calendar {calendar}'); |
|
138 | - } elseif ($event->getSubject() === self::SUBJECT_OBJECT_DELETE . '_event') { |
|
139 | - $subject = $this->l->t('{actor} deleted event {event} from calendar {calendar}'); |
|
140 | - } elseif ($event->getSubject() === self::SUBJECT_OBJECT_DELETE . '_event_self') { |
|
141 | - $subject = $this->l->t('You deleted event {event} from calendar {calendar}'); |
|
142 | - } elseif ($event->getSubject() === self::SUBJECT_OBJECT_UPDATE . '_event') { |
|
143 | - $subject = $this->l->t('{actor} updated event {event} in calendar {calendar}'); |
|
144 | - } elseif ($event->getSubject() === self::SUBJECT_OBJECT_UPDATE . '_event_self') { |
|
145 | - $subject = $this->l->t('You updated event {event} in calendar {calendar}'); |
|
146 | - } else { |
|
147 | - throw new \InvalidArgumentException(); |
|
148 | - } |
|
149 | - |
|
150 | - $parsedParameters = $this->getParameters($event); |
|
151 | - $this->setSubjects($event, $subject, $parsedParameters); |
|
152 | - |
|
153 | - $event = $this->eventMerger->mergeEvents('event', $event, $previousEvent); |
|
154 | - |
|
155 | - return $event; |
|
156 | - } |
|
157 | - |
|
158 | - /** |
|
159 | - * @param IEvent $event |
|
160 | - * @return array |
|
161 | - */ |
|
162 | - protected function getParameters(IEvent $event) { |
|
163 | - $subject = $event->getSubject(); |
|
164 | - $parameters = $event->getSubjectParameters(); |
|
165 | - |
|
166 | - // Nextcloud 13+ |
|
167 | - if (isset($parameters['calendar'])) { |
|
168 | - switch ($subject) { |
|
169 | - case self::SUBJECT_OBJECT_ADD . '_event': |
|
170 | - case self::SUBJECT_OBJECT_DELETE . '_event': |
|
171 | - case self::SUBJECT_OBJECT_UPDATE . '_event': |
|
172 | - return [ |
|
173 | - 'actor' => $this->generateUserParameter($parameters['actor']), |
|
174 | - 'calendar' => $this->generateCalendarParameter($parameters['calendar'], $this->l), |
|
175 | - 'event' => $this->generateClassifiedObjectParameter($parameters['object']), |
|
176 | - ]; |
|
177 | - case self::SUBJECT_OBJECT_ADD . '_event_self': |
|
178 | - case self::SUBJECT_OBJECT_DELETE . '_event_self': |
|
179 | - case self::SUBJECT_OBJECT_UPDATE . '_event_self': |
|
180 | - return [ |
|
181 | - 'calendar' => $this->generateCalendarParameter($parameters['calendar'], $this->l), |
|
182 | - 'event' => $this->generateClassifiedObjectParameter($parameters['object']), |
|
183 | - ]; |
|
184 | - } |
|
185 | - } |
|
186 | - |
|
187 | - // Legacy - Do NOT Remove unless necessary |
|
188 | - // Removing this will break parsing of activities that were created on |
|
189 | - // Nextcloud 12, so we should keep this as long as it's acceptable. |
|
190 | - // Otherwise if people upgrade over multiple releases in a short period, |
|
191 | - // they will get the dead entries in their stream. |
|
192 | - switch ($subject) { |
|
193 | - case self::SUBJECT_OBJECT_ADD . '_event': |
|
194 | - case self::SUBJECT_OBJECT_DELETE . '_event': |
|
195 | - case self::SUBJECT_OBJECT_UPDATE . '_event': |
|
196 | - return [ |
|
197 | - 'actor' => $this->generateUserParameter($parameters[0]), |
|
198 | - 'calendar' => $this->generateLegacyCalendarParameter((int)$event->getObjectId(), $parameters[1]), |
|
199 | - 'event' => $this->generateObjectParameter($parameters[2]), |
|
200 | - ]; |
|
201 | - case self::SUBJECT_OBJECT_ADD . '_event_self': |
|
202 | - case self::SUBJECT_OBJECT_DELETE . '_event_self': |
|
203 | - case self::SUBJECT_OBJECT_UPDATE . '_event_self': |
|
204 | - return [ |
|
205 | - 'calendar' => $this->generateLegacyCalendarParameter((int)$event->getObjectId(), $parameters[1]), |
|
206 | - 'event' => $this->generateObjectParameter($parameters[2]), |
|
207 | - ]; |
|
208 | - } |
|
209 | - |
|
210 | - throw new \InvalidArgumentException(); |
|
211 | - } |
|
212 | - |
|
213 | - private function generateClassifiedObjectParameter(array $eventData) { |
|
214 | - $parameter = $this->generateObjectParameter($eventData); |
|
215 | - if (!empty($eventData['classified'])) { |
|
216 | - $parameter['name'] = $this->l->t('Busy'); |
|
217 | - } |
|
218 | - return $parameter; |
|
219 | - } |
|
41 | + public const SUBJECT_OBJECT_ADD = 'object_add'; |
|
42 | + public const SUBJECT_OBJECT_UPDATE = 'object_update'; |
|
43 | + public const SUBJECT_OBJECT_DELETE = 'object_delete'; |
|
44 | + |
|
45 | + /** @var IFactory */ |
|
46 | + protected $languageFactory; |
|
47 | + |
|
48 | + /** @var IL10N */ |
|
49 | + protected $l; |
|
50 | + |
|
51 | + /** @var IManager */ |
|
52 | + protected $activityManager; |
|
53 | + |
|
54 | + /** @var IEventMerger */ |
|
55 | + protected $eventMerger; |
|
56 | + |
|
57 | + /** @var IAppManager */ |
|
58 | + protected $appManager; |
|
59 | + |
|
60 | + /** |
|
61 | + * @param IFactory $languageFactory |
|
62 | + * @param IURLGenerator $url |
|
63 | + * @param IManager $activityManager |
|
64 | + * @param IUserManager $userManager |
|
65 | + * @param IGroupManager $groupManager |
|
66 | + * @param IEventMerger $eventMerger |
|
67 | + * @param IAppManager $appManager |
|
68 | + */ |
|
69 | + public function __construct(IFactory $languageFactory, IURLGenerator $url, IManager $activityManager, IUserManager $userManager, IGroupManager $groupManager, IEventMerger $eventMerger, IAppManager $appManager) { |
|
70 | + parent::__construct($userManager, $groupManager, $url); |
|
71 | + $this->languageFactory = $languageFactory; |
|
72 | + $this->activityManager = $activityManager; |
|
73 | + $this->eventMerger = $eventMerger; |
|
74 | + $this->appManager = $appManager; |
|
75 | + } |
|
76 | + |
|
77 | + /** |
|
78 | + * @param array $eventData |
|
79 | + * @return array |
|
80 | + */ |
|
81 | + protected function generateObjectParameter(array $eventData) { |
|
82 | + if (!isset($eventData['id']) || !isset($eventData['name'])) { |
|
83 | + throw new \InvalidArgumentException(); |
|
84 | + } |
|
85 | + |
|
86 | + $params = [ |
|
87 | + 'type' => 'calendar-event', |
|
88 | + 'id' => $eventData['id'], |
|
89 | + 'name' => $eventData['name'], |
|
90 | + |
|
91 | + ]; |
|
92 | + if (isset($eventData['link']) && is_array($eventData['link']) && $this->appManager->isEnabledForUser('calendar')) { |
|
93 | + try { |
|
94 | + // The calendar app needs to be manually loaded for the routes to be loaded |
|
95 | + OC_App::loadApp('calendar'); |
|
96 | + $linkData = $eventData['link']; |
|
97 | + $objectId = base64_encode('/remote.php/dav/calendars/' . $linkData['owner'] . '/' . $linkData['calendar_uri'] . '/' . $linkData['object_uri']); |
|
98 | + $link = [ |
|
99 | + 'view' => 'dayGridMonth', |
|
100 | + 'timeRange' => 'now', |
|
101 | + 'mode' => 'sidebar', |
|
102 | + 'objectId' => $objectId, |
|
103 | + 'recurrenceId' => 'next' |
|
104 | + ]; |
|
105 | + $params['link'] = $this->url->linkToRouteAbsolute('calendar.view.indexview.timerange.edit', $link); |
|
106 | + } catch (\Exception $error) { |
|
107 | + // Do nothing |
|
108 | + } |
|
109 | + } |
|
110 | + return $params; |
|
111 | + } |
|
112 | + |
|
113 | + /** |
|
114 | + * @param string $language |
|
115 | + * @param IEvent $event |
|
116 | + * @param IEvent|null $previousEvent |
|
117 | + * @return IEvent |
|
118 | + * @throws \InvalidArgumentException |
|
119 | + * @since 11.0.0 |
|
120 | + */ |
|
121 | + public function parse($language, IEvent $event, IEvent $previousEvent = null) { |
|
122 | + if ($event->getApp() !== 'dav' || $event->getType() !== 'calendar_event') { |
|
123 | + throw new \InvalidArgumentException(); |
|
124 | + } |
|
125 | + |
|
126 | + $this->l = $this->languageFactory->get('dav', $language); |
|
127 | + |
|
128 | + if ($this->activityManager->getRequirePNG()) { |
|
129 | + $event->setIcon($this->url->getAbsoluteURL($this->url->imagePath('core', 'places/calendar-dark.png'))); |
|
130 | + } else { |
|
131 | + $event->setIcon($this->url->getAbsoluteURL($this->url->imagePath('core', 'places/calendar.svg'))); |
|
132 | + } |
|
133 | + |
|
134 | + if ($event->getSubject() === self::SUBJECT_OBJECT_ADD . '_event') { |
|
135 | + $subject = $this->l->t('{actor} created event {event} in calendar {calendar}'); |
|
136 | + } elseif ($event->getSubject() === self::SUBJECT_OBJECT_ADD . '_event_self') { |
|
137 | + $subject = $this->l->t('You created event {event} in calendar {calendar}'); |
|
138 | + } elseif ($event->getSubject() === self::SUBJECT_OBJECT_DELETE . '_event') { |
|
139 | + $subject = $this->l->t('{actor} deleted event {event} from calendar {calendar}'); |
|
140 | + } elseif ($event->getSubject() === self::SUBJECT_OBJECT_DELETE . '_event_self') { |
|
141 | + $subject = $this->l->t('You deleted event {event} from calendar {calendar}'); |
|
142 | + } elseif ($event->getSubject() === self::SUBJECT_OBJECT_UPDATE . '_event') { |
|
143 | + $subject = $this->l->t('{actor} updated event {event} in calendar {calendar}'); |
|
144 | + } elseif ($event->getSubject() === self::SUBJECT_OBJECT_UPDATE . '_event_self') { |
|
145 | + $subject = $this->l->t('You updated event {event} in calendar {calendar}'); |
|
146 | + } else { |
|
147 | + throw new \InvalidArgumentException(); |
|
148 | + } |
|
149 | + |
|
150 | + $parsedParameters = $this->getParameters($event); |
|
151 | + $this->setSubjects($event, $subject, $parsedParameters); |
|
152 | + |
|
153 | + $event = $this->eventMerger->mergeEvents('event', $event, $previousEvent); |
|
154 | + |
|
155 | + return $event; |
|
156 | + } |
|
157 | + |
|
158 | + /** |
|
159 | + * @param IEvent $event |
|
160 | + * @return array |
|
161 | + */ |
|
162 | + protected function getParameters(IEvent $event) { |
|
163 | + $subject = $event->getSubject(); |
|
164 | + $parameters = $event->getSubjectParameters(); |
|
165 | + |
|
166 | + // Nextcloud 13+ |
|
167 | + if (isset($parameters['calendar'])) { |
|
168 | + switch ($subject) { |
|
169 | + case self::SUBJECT_OBJECT_ADD . '_event': |
|
170 | + case self::SUBJECT_OBJECT_DELETE . '_event': |
|
171 | + case self::SUBJECT_OBJECT_UPDATE . '_event': |
|
172 | + return [ |
|
173 | + 'actor' => $this->generateUserParameter($parameters['actor']), |
|
174 | + 'calendar' => $this->generateCalendarParameter($parameters['calendar'], $this->l), |
|
175 | + 'event' => $this->generateClassifiedObjectParameter($parameters['object']), |
|
176 | + ]; |
|
177 | + case self::SUBJECT_OBJECT_ADD . '_event_self': |
|
178 | + case self::SUBJECT_OBJECT_DELETE . '_event_self': |
|
179 | + case self::SUBJECT_OBJECT_UPDATE . '_event_self': |
|
180 | + return [ |
|
181 | + 'calendar' => $this->generateCalendarParameter($parameters['calendar'], $this->l), |
|
182 | + 'event' => $this->generateClassifiedObjectParameter($parameters['object']), |
|
183 | + ]; |
|
184 | + } |
|
185 | + } |
|
186 | + |
|
187 | + // Legacy - Do NOT Remove unless necessary |
|
188 | + // Removing this will break parsing of activities that were created on |
|
189 | + // Nextcloud 12, so we should keep this as long as it's acceptable. |
|
190 | + // Otherwise if people upgrade over multiple releases in a short period, |
|
191 | + // they will get the dead entries in their stream. |
|
192 | + switch ($subject) { |
|
193 | + case self::SUBJECT_OBJECT_ADD . '_event': |
|
194 | + case self::SUBJECT_OBJECT_DELETE . '_event': |
|
195 | + case self::SUBJECT_OBJECT_UPDATE . '_event': |
|
196 | + return [ |
|
197 | + 'actor' => $this->generateUserParameter($parameters[0]), |
|
198 | + 'calendar' => $this->generateLegacyCalendarParameter((int)$event->getObjectId(), $parameters[1]), |
|
199 | + 'event' => $this->generateObjectParameter($parameters[2]), |
|
200 | + ]; |
|
201 | + case self::SUBJECT_OBJECT_ADD . '_event_self': |
|
202 | + case self::SUBJECT_OBJECT_DELETE . '_event_self': |
|
203 | + case self::SUBJECT_OBJECT_UPDATE . '_event_self': |
|
204 | + return [ |
|
205 | + 'calendar' => $this->generateLegacyCalendarParameter((int)$event->getObjectId(), $parameters[1]), |
|
206 | + 'event' => $this->generateObjectParameter($parameters[2]), |
|
207 | + ]; |
|
208 | + } |
|
209 | + |
|
210 | + throw new \InvalidArgumentException(); |
|
211 | + } |
|
212 | + |
|
213 | + private function generateClassifiedObjectParameter(array $eventData) { |
|
214 | + $parameter = $this->generateObjectParameter($eventData); |
|
215 | + if (!empty($eventData['classified'])) { |
|
216 | + $parameter['name'] = $this->l->t('Busy'); |
|
217 | + } |
|
218 | + return $parameter; |
|
219 | + } |
|
220 | 220 | } |
@@ -94,7 +94,7 @@ discard block |
||
94 | 94 | // The calendar app needs to be manually loaded for the routes to be loaded |
95 | 95 | OC_App::loadApp('calendar'); |
96 | 96 | $linkData = $eventData['link']; |
97 | - $objectId = base64_encode('/remote.php/dav/calendars/' . $linkData['owner'] . '/' . $linkData['calendar_uri'] . '/' . $linkData['object_uri']); |
|
97 | + $objectId = base64_encode('/remote.php/dav/calendars/'.$linkData['owner'].'/'.$linkData['calendar_uri'].'/'.$linkData['object_uri']); |
|
98 | 98 | $link = [ |
99 | 99 | 'view' => 'dayGridMonth', |
100 | 100 | 'timeRange' => 'now', |
@@ -131,17 +131,17 @@ discard block |
||
131 | 131 | $event->setIcon($this->url->getAbsoluteURL($this->url->imagePath('core', 'places/calendar.svg'))); |
132 | 132 | } |
133 | 133 | |
134 | - if ($event->getSubject() === self::SUBJECT_OBJECT_ADD . '_event') { |
|
134 | + if ($event->getSubject() === self::SUBJECT_OBJECT_ADD.'_event') { |
|
135 | 135 | $subject = $this->l->t('{actor} created event {event} in calendar {calendar}'); |
136 | - } elseif ($event->getSubject() === self::SUBJECT_OBJECT_ADD . '_event_self') { |
|
136 | + } elseif ($event->getSubject() === self::SUBJECT_OBJECT_ADD.'_event_self') { |
|
137 | 137 | $subject = $this->l->t('You created event {event} in calendar {calendar}'); |
138 | - } elseif ($event->getSubject() === self::SUBJECT_OBJECT_DELETE . '_event') { |
|
138 | + } elseif ($event->getSubject() === self::SUBJECT_OBJECT_DELETE.'_event') { |
|
139 | 139 | $subject = $this->l->t('{actor} deleted event {event} from calendar {calendar}'); |
140 | - } elseif ($event->getSubject() === self::SUBJECT_OBJECT_DELETE . '_event_self') { |
|
140 | + } elseif ($event->getSubject() === self::SUBJECT_OBJECT_DELETE.'_event_self') { |
|
141 | 141 | $subject = $this->l->t('You deleted event {event} from calendar {calendar}'); |
142 | - } elseif ($event->getSubject() === self::SUBJECT_OBJECT_UPDATE . '_event') { |
|
142 | + } elseif ($event->getSubject() === self::SUBJECT_OBJECT_UPDATE.'_event') { |
|
143 | 143 | $subject = $this->l->t('{actor} updated event {event} in calendar {calendar}'); |
144 | - } elseif ($event->getSubject() === self::SUBJECT_OBJECT_UPDATE . '_event_self') { |
|
144 | + } elseif ($event->getSubject() === self::SUBJECT_OBJECT_UPDATE.'_event_self') { |
|
145 | 145 | $subject = $this->l->t('You updated event {event} in calendar {calendar}'); |
146 | 146 | } else { |
147 | 147 | throw new \InvalidArgumentException(); |
@@ -166,17 +166,17 @@ discard block |
||
166 | 166 | // Nextcloud 13+ |
167 | 167 | if (isset($parameters['calendar'])) { |
168 | 168 | switch ($subject) { |
169 | - case self::SUBJECT_OBJECT_ADD . '_event': |
|
170 | - case self::SUBJECT_OBJECT_DELETE . '_event': |
|
171 | - case self::SUBJECT_OBJECT_UPDATE . '_event': |
|
169 | + case self::SUBJECT_OBJECT_ADD.'_event': |
|
170 | + case self::SUBJECT_OBJECT_DELETE.'_event': |
|
171 | + case self::SUBJECT_OBJECT_UPDATE.'_event': |
|
172 | 172 | return [ |
173 | 173 | 'actor' => $this->generateUserParameter($parameters['actor']), |
174 | 174 | 'calendar' => $this->generateCalendarParameter($parameters['calendar'], $this->l), |
175 | 175 | 'event' => $this->generateClassifiedObjectParameter($parameters['object']), |
176 | 176 | ]; |
177 | - case self::SUBJECT_OBJECT_ADD . '_event_self': |
|
178 | - case self::SUBJECT_OBJECT_DELETE . '_event_self': |
|
179 | - case self::SUBJECT_OBJECT_UPDATE . '_event_self': |
|
177 | + case self::SUBJECT_OBJECT_ADD.'_event_self': |
|
178 | + case self::SUBJECT_OBJECT_DELETE.'_event_self': |
|
179 | + case self::SUBJECT_OBJECT_UPDATE.'_event_self': |
|
180 | 180 | return [ |
181 | 181 | 'calendar' => $this->generateCalendarParameter($parameters['calendar'], $this->l), |
182 | 182 | 'event' => $this->generateClassifiedObjectParameter($parameters['object']), |
@@ -190,19 +190,19 @@ discard block |
||
190 | 190 | // Otherwise if people upgrade over multiple releases in a short period, |
191 | 191 | // they will get the dead entries in their stream. |
192 | 192 | switch ($subject) { |
193 | - case self::SUBJECT_OBJECT_ADD . '_event': |
|
194 | - case self::SUBJECT_OBJECT_DELETE . '_event': |
|
195 | - case self::SUBJECT_OBJECT_UPDATE . '_event': |
|
193 | + case self::SUBJECT_OBJECT_ADD.'_event': |
|
194 | + case self::SUBJECT_OBJECT_DELETE.'_event': |
|
195 | + case self::SUBJECT_OBJECT_UPDATE.'_event': |
|
196 | 196 | return [ |
197 | 197 | 'actor' => $this->generateUserParameter($parameters[0]), |
198 | - 'calendar' => $this->generateLegacyCalendarParameter((int)$event->getObjectId(), $parameters[1]), |
|
198 | + 'calendar' => $this->generateLegacyCalendarParameter((int) $event->getObjectId(), $parameters[1]), |
|
199 | 199 | 'event' => $this->generateObjectParameter($parameters[2]), |
200 | 200 | ]; |
201 | - case self::SUBJECT_OBJECT_ADD . '_event_self': |
|
202 | - case self::SUBJECT_OBJECT_DELETE . '_event_self': |
|
203 | - case self::SUBJECT_OBJECT_UPDATE . '_event_self': |
|
201 | + case self::SUBJECT_OBJECT_ADD.'_event_self': |
|
202 | + case self::SUBJECT_OBJECT_DELETE.'_event_self': |
|
203 | + case self::SUBJECT_OBJECT_UPDATE.'_event_self': |
|
204 | 204 | return [ |
205 | - 'calendar' => $this->generateLegacyCalendarParameter((int)$event->getObjectId(), $parameters[1]), |
|
205 | + 'calendar' => $this->generateLegacyCalendarParameter((int) $event->getObjectId(), $parameters[1]), |
|
206 | 206 | 'event' => $this->generateObjectParameter($parameters[2]), |
207 | 207 | ]; |
208 | 208 | } |
@@ -45,488 +45,488 @@ |
||
45 | 45 | */ |
46 | 46 | class Backend { |
47 | 47 | |
48 | - /** @var IActivityManager */ |
|
49 | - protected $activityManager; |
|
50 | - |
|
51 | - /** @var IGroupManager */ |
|
52 | - protected $groupManager; |
|
53 | - |
|
54 | - /** @var IUserSession */ |
|
55 | - protected $userSession; |
|
56 | - |
|
57 | - /** @var IAppManager */ |
|
58 | - protected $appManager; |
|
59 | - |
|
60 | - public function __construct(IActivityManager $activityManager, IGroupManager $groupManager, IUserSession $userSession, IAppManager $appManager) { |
|
61 | - $this->activityManager = $activityManager; |
|
62 | - $this->groupManager = $groupManager; |
|
63 | - $this->userSession = $userSession; |
|
64 | - $this->appManager = $appManager; |
|
65 | - } |
|
66 | - |
|
67 | - /** |
|
68 | - * Creates activities when a calendar was creates |
|
69 | - * |
|
70 | - * @param array $calendarData |
|
71 | - */ |
|
72 | - public function onCalendarAdd(array $calendarData) { |
|
73 | - $this->triggerCalendarActivity(Calendar::SUBJECT_ADD, $calendarData); |
|
74 | - } |
|
75 | - |
|
76 | - /** |
|
77 | - * Creates activities when a calendar was updated |
|
78 | - * |
|
79 | - * @param array $calendarData |
|
80 | - * @param array $shares |
|
81 | - * @param array $properties |
|
82 | - */ |
|
83 | - public function onCalendarUpdate(array $calendarData, array $shares, array $properties) { |
|
84 | - $this->triggerCalendarActivity(Calendar::SUBJECT_UPDATE, $calendarData, $shares, $properties); |
|
85 | - } |
|
86 | - |
|
87 | - /** |
|
88 | - * Creates activities when a calendar was deleted |
|
89 | - * |
|
90 | - * @param array $calendarData |
|
91 | - * @param array $shares |
|
92 | - */ |
|
93 | - public function onCalendarDelete(array $calendarData, array $shares) { |
|
94 | - $this->triggerCalendarActivity(Calendar::SUBJECT_DELETE, $calendarData, $shares); |
|
95 | - } |
|
96 | - |
|
97 | - /** |
|
98 | - * Creates activities when a calendar was (un)published |
|
99 | - * |
|
100 | - * @param array $calendarData |
|
101 | - * @param bool $publishStatus |
|
102 | - */ |
|
103 | - public function onCalendarPublication(array $calendarData, $publishStatus) { |
|
104 | - $this->triggerCalendarActivity($publishStatus ? Calendar::SUBJECT_PUBLISH : Calendar::SUBJECT_UNPUBLISH, $calendarData); |
|
105 | - } |
|
106 | - |
|
107 | - /** |
|
108 | - * Creates activities for all related users when a calendar was touched |
|
109 | - * |
|
110 | - * @param string $action |
|
111 | - * @param array $calendarData |
|
112 | - * @param array $shares |
|
113 | - * @param array $changedProperties |
|
114 | - */ |
|
115 | - protected function triggerCalendarActivity($action, array $calendarData, array $shares = [], array $changedProperties = []) { |
|
116 | - if (!isset($calendarData['principaluri'])) { |
|
117 | - return; |
|
118 | - } |
|
119 | - |
|
120 | - $principal = explode('/', $calendarData['principaluri']); |
|
121 | - $owner = array_pop($principal); |
|
122 | - |
|
123 | - $currentUser = $this->userSession->getUser(); |
|
124 | - if ($currentUser instanceof IUser) { |
|
125 | - $currentUser = $currentUser->getUID(); |
|
126 | - } else { |
|
127 | - $currentUser = $owner; |
|
128 | - } |
|
129 | - |
|
130 | - $event = $this->activityManager->generateEvent(); |
|
131 | - $event->setApp('dav') |
|
132 | - ->setObject('calendar', (int) $calendarData['id']) |
|
133 | - ->setType('calendar') |
|
134 | - ->setAuthor($currentUser); |
|
135 | - |
|
136 | - $changedVisibleInformation = array_intersect([ |
|
137 | - '{DAV:}displayname', |
|
138 | - '{http://apple.com/ns/ical/}calendar-color' |
|
139 | - ], array_keys($changedProperties)); |
|
140 | - |
|
141 | - if (empty($shares) || ($action === Calendar::SUBJECT_UPDATE && empty($changedVisibleInformation))) { |
|
142 | - $users = [$owner]; |
|
143 | - } else { |
|
144 | - $users = $this->getUsersForShares($shares); |
|
145 | - $users[] = $owner; |
|
146 | - } |
|
147 | - |
|
148 | - foreach ($users as $user) { |
|
149 | - $event->setAffectedUser($user) |
|
150 | - ->setSubject( |
|
151 | - $user === $currentUser ? $action . '_self' : $action, |
|
152 | - [ |
|
153 | - 'actor' => $currentUser, |
|
154 | - 'calendar' => [ |
|
155 | - 'id' => (int) $calendarData['id'], |
|
156 | - 'uri' => $calendarData['uri'], |
|
157 | - 'name' => $calendarData['{DAV:}displayname'], |
|
158 | - ], |
|
159 | - ] |
|
160 | - ); |
|
161 | - $this->activityManager->publish($event); |
|
162 | - } |
|
163 | - } |
|
164 | - |
|
165 | - /** |
|
166 | - * Creates activities for all related users when a calendar was (un-)shared |
|
167 | - * |
|
168 | - * @param array $calendarData |
|
169 | - * @param array $shares |
|
170 | - * @param array $add |
|
171 | - * @param array $remove |
|
172 | - */ |
|
173 | - public function onCalendarUpdateShares(array $calendarData, array $shares, array $add, array $remove) { |
|
174 | - $principal = explode('/', $calendarData['principaluri']); |
|
175 | - $owner = $principal[2]; |
|
176 | - |
|
177 | - $currentUser = $this->userSession->getUser(); |
|
178 | - if ($currentUser instanceof IUser) { |
|
179 | - $currentUser = $currentUser->getUID(); |
|
180 | - } else { |
|
181 | - $currentUser = $owner; |
|
182 | - } |
|
183 | - |
|
184 | - $event = $this->activityManager->generateEvent(); |
|
185 | - $event->setApp('dav') |
|
186 | - ->setObject('calendar', (int) $calendarData['id']) |
|
187 | - ->setType('calendar') |
|
188 | - ->setAuthor($currentUser); |
|
189 | - |
|
190 | - foreach ($remove as $principal) { |
|
191 | - // principal:principals/users/test |
|
192 | - $parts = explode(':', $principal, 2); |
|
193 | - if ($parts[0] !== 'principal') { |
|
194 | - continue; |
|
195 | - } |
|
196 | - $principal = explode('/', $parts[1]); |
|
197 | - |
|
198 | - if ($principal[1] === 'users') { |
|
199 | - $this->triggerActivityUser( |
|
200 | - $principal[2], |
|
201 | - $event, |
|
202 | - $calendarData, |
|
203 | - Calendar::SUBJECT_UNSHARE_USER, |
|
204 | - Calendar::SUBJECT_DELETE . '_self' |
|
205 | - ); |
|
206 | - |
|
207 | - if ($owner !== $principal[2]) { |
|
208 | - $parameters = [ |
|
209 | - 'actor' => $event->getAuthor(), |
|
210 | - 'calendar' => [ |
|
211 | - 'id' => (int) $calendarData['id'], |
|
212 | - 'uri' => $calendarData['uri'], |
|
213 | - 'name' => $calendarData['{DAV:}displayname'], |
|
214 | - ], |
|
215 | - 'user' => $principal[2], |
|
216 | - ]; |
|
217 | - |
|
218 | - if ($owner === $event->getAuthor()) { |
|
219 | - $subject = Calendar::SUBJECT_UNSHARE_USER . '_you'; |
|
220 | - } elseif ($principal[2] === $event->getAuthor()) { |
|
221 | - $subject = Calendar::SUBJECT_UNSHARE_USER . '_self'; |
|
222 | - } else { |
|
223 | - $event->setAffectedUser($event->getAuthor()) |
|
224 | - ->setSubject(Calendar::SUBJECT_UNSHARE_USER . '_you', $parameters); |
|
225 | - $this->activityManager->publish($event); |
|
226 | - |
|
227 | - $subject = Calendar::SUBJECT_UNSHARE_USER . '_by'; |
|
228 | - } |
|
229 | - |
|
230 | - $event->setAffectedUser($owner) |
|
231 | - ->setSubject($subject, $parameters); |
|
232 | - $this->activityManager->publish($event); |
|
233 | - } |
|
234 | - } elseif ($principal[1] === 'groups') { |
|
235 | - $this->triggerActivityGroup($principal[2], $event, $calendarData, Calendar::SUBJECT_UNSHARE_USER); |
|
236 | - |
|
237 | - $parameters = [ |
|
238 | - 'actor' => $event->getAuthor(), |
|
239 | - 'calendar' => [ |
|
240 | - 'id' => (int) $calendarData['id'], |
|
241 | - 'uri' => $calendarData['uri'], |
|
242 | - 'name' => $calendarData['{DAV:}displayname'], |
|
243 | - ], |
|
244 | - 'group' => $principal[2], |
|
245 | - ]; |
|
246 | - |
|
247 | - if ($owner === $event->getAuthor()) { |
|
248 | - $subject = Calendar::SUBJECT_UNSHARE_GROUP . '_you'; |
|
249 | - } else { |
|
250 | - $event->setAffectedUser($event->getAuthor()) |
|
251 | - ->setSubject(Calendar::SUBJECT_UNSHARE_GROUP . '_you', $parameters); |
|
252 | - $this->activityManager->publish($event); |
|
253 | - |
|
254 | - $subject = Calendar::SUBJECT_UNSHARE_GROUP . '_by'; |
|
255 | - } |
|
256 | - |
|
257 | - $event->setAffectedUser($owner) |
|
258 | - ->setSubject($subject, $parameters); |
|
259 | - $this->activityManager->publish($event); |
|
260 | - } |
|
261 | - } |
|
262 | - |
|
263 | - foreach ($add as $share) { |
|
264 | - if ($this->isAlreadyShared($share['href'], $shares)) { |
|
265 | - continue; |
|
266 | - } |
|
267 | - |
|
268 | - // principal:principals/users/test |
|
269 | - $parts = explode(':', $share['href'], 2); |
|
270 | - if ($parts[0] !== 'principal') { |
|
271 | - continue; |
|
272 | - } |
|
273 | - $principal = explode('/', $parts[1]); |
|
274 | - |
|
275 | - if ($principal[1] === 'users') { |
|
276 | - $this->triggerActivityUser($principal[2], $event, $calendarData, Calendar::SUBJECT_SHARE_USER); |
|
277 | - |
|
278 | - if ($owner !== $principal[2]) { |
|
279 | - $parameters = [ |
|
280 | - 'actor' => $event->getAuthor(), |
|
281 | - 'calendar' => [ |
|
282 | - 'id' => (int) $calendarData['id'], |
|
283 | - 'uri' => $calendarData['uri'], |
|
284 | - 'name' => $calendarData['{DAV:}displayname'], |
|
285 | - ], |
|
286 | - 'user' => $principal[2], |
|
287 | - ]; |
|
288 | - |
|
289 | - if ($owner === $event->getAuthor()) { |
|
290 | - $subject = Calendar::SUBJECT_SHARE_USER . '_you'; |
|
291 | - } else { |
|
292 | - $event->setAffectedUser($event->getAuthor()) |
|
293 | - ->setSubject(Calendar::SUBJECT_SHARE_USER . '_you', $parameters); |
|
294 | - $this->activityManager->publish($event); |
|
295 | - |
|
296 | - $subject = Calendar::SUBJECT_SHARE_USER . '_by'; |
|
297 | - } |
|
298 | - |
|
299 | - $event->setAffectedUser($owner) |
|
300 | - ->setSubject($subject, $parameters); |
|
301 | - $this->activityManager->publish($event); |
|
302 | - } |
|
303 | - } elseif ($principal[1] === 'groups') { |
|
304 | - $this->triggerActivityGroup($principal[2], $event, $calendarData, Calendar::SUBJECT_SHARE_USER); |
|
305 | - |
|
306 | - $parameters = [ |
|
307 | - 'actor' => $event->getAuthor(), |
|
308 | - 'calendar' => [ |
|
309 | - 'id' => (int) $calendarData['id'], |
|
310 | - 'uri' => $calendarData['uri'], |
|
311 | - 'name' => $calendarData['{DAV:}displayname'], |
|
312 | - ], |
|
313 | - 'group' => $principal[2], |
|
314 | - ]; |
|
315 | - |
|
316 | - if ($owner === $event->getAuthor()) { |
|
317 | - $subject = Calendar::SUBJECT_SHARE_GROUP . '_you'; |
|
318 | - } else { |
|
319 | - $event->setAffectedUser($event->getAuthor()) |
|
320 | - ->setSubject(Calendar::SUBJECT_SHARE_GROUP . '_you', $parameters); |
|
321 | - $this->activityManager->publish($event); |
|
322 | - |
|
323 | - $subject = Calendar::SUBJECT_SHARE_GROUP . '_by'; |
|
324 | - } |
|
325 | - |
|
326 | - $event->setAffectedUser($owner) |
|
327 | - ->setSubject($subject, $parameters); |
|
328 | - $this->activityManager->publish($event); |
|
329 | - } |
|
330 | - } |
|
331 | - } |
|
332 | - |
|
333 | - /** |
|
334 | - * Checks if a calendar is already shared with a principal |
|
335 | - * |
|
336 | - * @param string $principal |
|
337 | - * @param array[] $shares |
|
338 | - * @return bool |
|
339 | - */ |
|
340 | - protected function isAlreadyShared($principal, $shares) { |
|
341 | - foreach ($shares as $share) { |
|
342 | - if ($principal === $share['href']) { |
|
343 | - return true; |
|
344 | - } |
|
345 | - } |
|
346 | - |
|
347 | - return false; |
|
348 | - } |
|
349 | - |
|
350 | - /** |
|
351 | - * Creates the given activity for all members of the given group |
|
352 | - * |
|
353 | - * @param string $gid |
|
354 | - * @param IEvent $event |
|
355 | - * @param array $properties |
|
356 | - * @param string $subject |
|
357 | - */ |
|
358 | - protected function triggerActivityGroup($gid, IEvent $event, array $properties, $subject) { |
|
359 | - $group = $this->groupManager->get($gid); |
|
360 | - |
|
361 | - if ($group instanceof IGroup) { |
|
362 | - foreach ($group->getUsers() as $user) { |
|
363 | - // Exclude current user |
|
364 | - if ($user->getUID() !== $event->getAuthor()) { |
|
365 | - $this->triggerActivityUser($user->getUID(), $event, $properties, $subject); |
|
366 | - } |
|
367 | - } |
|
368 | - } |
|
369 | - } |
|
370 | - |
|
371 | - /** |
|
372 | - * Creates the given activity for the given user |
|
373 | - * |
|
374 | - * @param string $user |
|
375 | - * @param IEvent $event |
|
376 | - * @param array $properties |
|
377 | - * @param string $subject |
|
378 | - * @param string $subjectSelf |
|
379 | - */ |
|
380 | - protected function triggerActivityUser($user, IEvent $event, array $properties, $subject, $subjectSelf = '') { |
|
381 | - $event->setAffectedUser($user) |
|
382 | - ->setSubject( |
|
383 | - $user === $event->getAuthor() && $subjectSelf ? $subjectSelf : $subject, |
|
384 | - [ |
|
385 | - 'actor' => $event->getAuthor(), |
|
386 | - 'calendar' => [ |
|
387 | - 'id' => (int) $properties['id'], |
|
388 | - 'uri' => $properties['uri'], |
|
389 | - 'name' => $properties['{DAV:}displayname'], |
|
390 | - ], |
|
391 | - ] |
|
392 | - ); |
|
393 | - |
|
394 | - $this->activityManager->publish($event); |
|
395 | - } |
|
396 | - |
|
397 | - /** |
|
398 | - * Creates activities when a calendar object was created/updated/deleted |
|
399 | - * |
|
400 | - * @param string $action |
|
401 | - * @param array $calendarData |
|
402 | - * @param array $shares |
|
403 | - * @param array $objectData |
|
404 | - */ |
|
405 | - public function onTouchCalendarObject($action, array $calendarData, array $shares, array $objectData) { |
|
406 | - if (!isset($calendarData['principaluri'])) { |
|
407 | - return; |
|
408 | - } |
|
409 | - |
|
410 | - $principal = explode('/', $calendarData['principaluri']); |
|
411 | - $owner = array_pop($principal); |
|
412 | - |
|
413 | - $currentUser = $this->userSession->getUser(); |
|
414 | - if ($currentUser instanceof IUser) { |
|
415 | - $currentUser = $currentUser->getUID(); |
|
416 | - } else { |
|
417 | - $currentUser = $owner; |
|
418 | - } |
|
419 | - |
|
420 | - $classification = $objectData['classification'] ?? CalDavBackend::CLASSIFICATION_PUBLIC; |
|
421 | - $object = $this->getObjectNameAndType($objectData); |
|
422 | - $action = $action . '_' . $object['type']; |
|
423 | - |
|
424 | - if ($object['type'] === 'todo' && strpos($action, Event::SUBJECT_OBJECT_UPDATE) === 0 && $object['status'] === 'COMPLETED') { |
|
425 | - $action .= '_completed'; |
|
426 | - } elseif ($object['type'] === 'todo' && strpos($action, Event::SUBJECT_OBJECT_UPDATE) === 0 && $object['status'] === 'NEEDS-ACTION') { |
|
427 | - $action .= '_needs_action'; |
|
428 | - } |
|
429 | - |
|
430 | - $event = $this->activityManager->generateEvent(); |
|
431 | - $event->setApp('dav') |
|
432 | - ->setObject('calendar', (int) $calendarData['id']) |
|
433 | - ->setType($object['type'] === 'event' ? 'calendar_event' : 'calendar_todo') |
|
434 | - ->setAuthor($currentUser); |
|
435 | - |
|
436 | - $users = $this->getUsersForShares($shares); |
|
437 | - $users[] = $owner; |
|
438 | - |
|
439 | - // Users for share can return the owner itself if the calendar is published |
|
440 | - foreach (array_unique($users) as $user) { |
|
441 | - if ($classification === CalDavBackend::CLASSIFICATION_PRIVATE && $user !== $owner) { |
|
442 | - // Private events are only shown to the owner |
|
443 | - continue; |
|
444 | - } |
|
445 | - |
|
446 | - $params = [ |
|
447 | - 'actor' => $event->getAuthor(), |
|
448 | - 'calendar' => [ |
|
449 | - 'id' => (int) $calendarData['id'], |
|
450 | - 'uri' => $calendarData['uri'], |
|
451 | - 'name' => $calendarData['{DAV:}displayname'], |
|
452 | - ], |
|
453 | - 'object' => [ |
|
454 | - 'id' => $object['id'], |
|
455 | - 'name' => $classification === CalDavBackend::CLASSIFICATION_CONFIDENTIAL && $user !== $owner ? 'Busy' : $object['name'], |
|
456 | - 'classified' => $classification === CalDavBackend::CLASSIFICATION_CONFIDENTIAL && $user !== $owner, |
|
457 | - ], |
|
458 | - ]; |
|
459 | - |
|
460 | - if ($object['type'] === 'event' && strpos($action, Event::SUBJECT_OBJECT_DELETE) === false && $this->appManager->isEnabledForUser('calendar')) { |
|
461 | - $params['object']['link']['object_uri'] = $objectData['uri']; |
|
462 | - $params['object']['link']['calendar_uri'] = $calendarData['uri']; |
|
463 | - $params['object']['link']['owner'] = $owner; |
|
464 | - } |
|
465 | - |
|
466 | - |
|
467 | - $event->setAffectedUser($user) |
|
468 | - ->setSubject( |
|
469 | - $user === $currentUser ? $action . '_self' : $action, |
|
470 | - $params |
|
471 | - ); |
|
472 | - |
|
473 | - $this->activityManager->publish($event); |
|
474 | - } |
|
475 | - } |
|
476 | - |
|
477 | - /** |
|
478 | - * @param array $objectData |
|
479 | - * @return string[]|bool |
|
480 | - */ |
|
481 | - protected function getObjectNameAndType(array $objectData) { |
|
482 | - $vObject = Reader::read($objectData['calendardata']); |
|
483 | - $component = $componentType = null; |
|
484 | - foreach ($vObject->getComponents() as $component) { |
|
485 | - if (in_array($component->name, ['VEVENT', 'VTODO'])) { |
|
486 | - $componentType = $component->name; |
|
487 | - break; |
|
488 | - } |
|
489 | - } |
|
490 | - |
|
491 | - if (!$componentType) { |
|
492 | - // Calendar objects must have a VEVENT or VTODO component |
|
493 | - return false; |
|
494 | - } |
|
495 | - |
|
496 | - if ($componentType === 'VEVENT') { |
|
497 | - return ['id' => (string) $component->UID, 'name' => (string) $component->SUMMARY, 'type' => 'event']; |
|
498 | - } |
|
499 | - return ['id' => (string) $component->UID, 'name' => (string) $component->SUMMARY, 'type' => 'todo', 'status' => (string) $component->STATUS]; |
|
500 | - } |
|
501 | - |
|
502 | - /** |
|
503 | - * Get all users that have access to a given calendar |
|
504 | - * |
|
505 | - * @param array $shares |
|
506 | - * @return string[] |
|
507 | - */ |
|
508 | - protected function getUsersForShares(array $shares) { |
|
509 | - $users = $groups = []; |
|
510 | - foreach ($shares as $share) { |
|
511 | - $principal = explode('/', $share['{http://owncloud.org/ns}principal']); |
|
512 | - if ($principal[1] === 'users') { |
|
513 | - $users[] = $principal[2]; |
|
514 | - } elseif ($principal[1] === 'groups') { |
|
515 | - $groups[] = $principal[2]; |
|
516 | - } |
|
517 | - } |
|
518 | - |
|
519 | - if (!empty($groups)) { |
|
520 | - foreach ($groups as $gid) { |
|
521 | - $group = $this->groupManager->get($gid); |
|
522 | - if ($group instanceof IGroup) { |
|
523 | - foreach ($group->getUsers() as $user) { |
|
524 | - $users[] = $user->getUID(); |
|
525 | - } |
|
526 | - } |
|
527 | - } |
|
528 | - } |
|
529 | - |
|
530 | - return array_unique($users); |
|
531 | - } |
|
48 | + /** @var IActivityManager */ |
|
49 | + protected $activityManager; |
|
50 | + |
|
51 | + /** @var IGroupManager */ |
|
52 | + protected $groupManager; |
|
53 | + |
|
54 | + /** @var IUserSession */ |
|
55 | + protected $userSession; |
|
56 | + |
|
57 | + /** @var IAppManager */ |
|
58 | + protected $appManager; |
|
59 | + |
|
60 | + public function __construct(IActivityManager $activityManager, IGroupManager $groupManager, IUserSession $userSession, IAppManager $appManager) { |
|
61 | + $this->activityManager = $activityManager; |
|
62 | + $this->groupManager = $groupManager; |
|
63 | + $this->userSession = $userSession; |
|
64 | + $this->appManager = $appManager; |
|
65 | + } |
|
66 | + |
|
67 | + /** |
|
68 | + * Creates activities when a calendar was creates |
|
69 | + * |
|
70 | + * @param array $calendarData |
|
71 | + */ |
|
72 | + public function onCalendarAdd(array $calendarData) { |
|
73 | + $this->triggerCalendarActivity(Calendar::SUBJECT_ADD, $calendarData); |
|
74 | + } |
|
75 | + |
|
76 | + /** |
|
77 | + * Creates activities when a calendar was updated |
|
78 | + * |
|
79 | + * @param array $calendarData |
|
80 | + * @param array $shares |
|
81 | + * @param array $properties |
|
82 | + */ |
|
83 | + public function onCalendarUpdate(array $calendarData, array $shares, array $properties) { |
|
84 | + $this->triggerCalendarActivity(Calendar::SUBJECT_UPDATE, $calendarData, $shares, $properties); |
|
85 | + } |
|
86 | + |
|
87 | + /** |
|
88 | + * Creates activities when a calendar was deleted |
|
89 | + * |
|
90 | + * @param array $calendarData |
|
91 | + * @param array $shares |
|
92 | + */ |
|
93 | + public function onCalendarDelete(array $calendarData, array $shares) { |
|
94 | + $this->triggerCalendarActivity(Calendar::SUBJECT_DELETE, $calendarData, $shares); |
|
95 | + } |
|
96 | + |
|
97 | + /** |
|
98 | + * Creates activities when a calendar was (un)published |
|
99 | + * |
|
100 | + * @param array $calendarData |
|
101 | + * @param bool $publishStatus |
|
102 | + */ |
|
103 | + public function onCalendarPublication(array $calendarData, $publishStatus) { |
|
104 | + $this->triggerCalendarActivity($publishStatus ? Calendar::SUBJECT_PUBLISH : Calendar::SUBJECT_UNPUBLISH, $calendarData); |
|
105 | + } |
|
106 | + |
|
107 | + /** |
|
108 | + * Creates activities for all related users when a calendar was touched |
|
109 | + * |
|
110 | + * @param string $action |
|
111 | + * @param array $calendarData |
|
112 | + * @param array $shares |
|
113 | + * @param array $changedProperties |
|
114 | + */ |
|
115 | + protected function triggerCalendarActivity($action, array $calendarData, array $shares = [], array $changedProperties = []) { |
|
116 | + if (!isset($calendarData['principaluri'])) { |
|
117 | + return; |
|
118 | + } |
|
119 | + |
|
120 | + $principal = explode('/', $calendarData['principaluri']); |
|
121 | + $owner = array_pop($principal); |
|
122 | + |
|
123 | + $currentUser = $this->userSession->getUser(); |
|
124 | + if ($currentUser instanceof IUser) { |
|
125 | + $currentUser = $currentUser->getUID(); |
|
126 | + } else { |
|
127 | + $currentUser = $owner; |
|
128 | + } |
|
129 | + |
|
130 | + $event = $this->activityManager->generateEvent(); |
|
131 | + $event->setApp('dav') |
|
132 | + ->setObject('calendar', (int) $calendarData['id']) |
|
133 | + ->setType('calendar') |
|
134 | + ->setAuthor($currentUser); |
|
135 | + |
|
136 | + $changedVisibleInformation = array_intersect([ |
|
137 | + '{DAV:}displayname', |
|
138 | + '{http://apple.com/ns/ical/}calendar-color' |
|
139 | + ], array_keys($changedProperties)); |
|
140 | + |
|
141 | + if (empty($shares) || ($action === Calendar::SUBJECT_UPDATE && empty($changedVisibleInformation))) { |
|
142 | + $users = [$owner]; |
|
143 | + } else { |
|
144 | + $users = $this->getUsersForShares($shares); |
|
145 | + $users[] = $owner; |
|
146 | + } |
|
147 | + |
|
148 | + foreach ($users as $user) { |
|
149 | + $event->setAffectedUser($user) |
|
150 | + ->setSubject( |
|
151 | + $user === $currentUser ? $action . '_self' : $action, |
|
152 | + [ |
|
153 | + 'actor' => $currentUser, |
|
154 | + 'calendar' => [ |
|
155 | + 'id' => (int) $calendarData['id'], |
|
156 | + 'uri' => $calendarData['uri'], |
|
157 | + 'name' => $calendarData['{DAV:}displayname'], |
|
158 | + ], |
|
159 | + ] |
|
160 | + ); |
|
161 | + $this->activityManager->publish($event); |
|
162 | + } |
|
163 | + } |
|
164 | + |
|
165 | + /** |
|
166 | + * Creates activities for all related users when a calendar was (un-)shared |
|
167 | + * |
|
168 | + * @param array $calendarData |
|
169 | + * @param array $shares |
|
170 | + * @param array $add |
|
171 | + * @param array $remove |
|
172 | + */ |
|
173 | + public function onCalendarUpdateShares(array $calendarData, array $shares, array $add, array $remove) { |
|
174 | + $principal = explode('/', $calendarData['principaluri']); |
|
175 | + $owner = $principal[2]; |
|
176 | + |
|
177 | + $currentUser = $this->userSession->getUser(); |
|
178 | + if ($currentUser instanceof IUser) { |
|
179 | + $currentUser = $currentUser->getUID(); |
|
180 | + } else { |
|
181 | + $currentUser = $owner; |
|
182 | + } |
|
183 | + |
|
184 | + $event = $this->activityManager->generateEvent(); |
|
185 | + $event->setApp('dav') |
|
186 | + ->setObject('calendar', (int) $calendarData['id']) |
|
187 | + ->setType('calendar') |
|
188 | + ->setAuthor($currentUser); |
|
189 | + |
|
190 | + foreach ($remove as $principal) { |
|
191 | + // principal:principals/users/test |
|
192 | + $parts = explode(':', $principal, 2); |
|
193 | + if ($parts[0] !== 'principal') { |
|
194 | + continue; |
|
195 | + } |
|
196 | + $principal = explode('/', $parts[1]); |
|
197 | + |
|
198 | + if ($principal[1] === 'users') { |
|
199 | + $this->triggerActivityUser( |
|
200 | + $principal[2], |
|
201 | + $event, |
|
202 | + $calendarData, |
|
203 | + Calendar::SUBJECT_UNSHARE_USER, |
|
204 | + Calendar::SUBJECT_DELETE . '_self' |
|
205 | + ); |
|
206 | + |
|
207 | + if ($owner !== $principal[2]) { |
|
208 | + $parameters = [ |
|
209 | + 'actor' => $event->getAuthor(), |
|
210 | + 'calendar' => [ |
|
211 | + 'id' => (int) $calendarData['id'], |
|
212 | + 'uri' => $calendarData['uri'], |
|
213 | + 'name' => $calendarData['{DAV:}displayname'], |
|
214 | + ], |
|
215 | + 'user' => $principal[2], |
|
216 | + ]; |
|
217 | + |
|
218 | + if ($owner === $event->getAuthor()) { |
|
219 | + $subject = Calendar::SUBJECT_UNSHARE_USER . '_you'; |
|
220 | + } elseif ($principal[2] === $event->getAuthor()) { |
|
221 | + $subject = Calendar::SUBJECT_UNSHARE_USER . '_self'; |
|
222 | + } else { |
|
223 | + $event->setAffectedUser($event->getAuthor()) |
|
224 | + ->setSubject(Calendar::SUBJECT_UNSHARE_USER . '_you', $parameters); |
|
225 | + $this->activityManager->publish($event); |
|
226 | + |
|
227 | + $subject = Calendar::SUBJECT_UNSHARE_USER . '_by'; |
|
228 | + } |
|
229 | + |
|
230 | + $event->setAffectedUser($owner) |
|
231 | + ->setSubject($subject, $parameters); |
|
232 | + $this->activityManager->publish($event); |
|
233 | + } |
|
234 | + } elseif ($principal[1] === 'groups') { |
|
235 | + $this->triggerActivityGroup($principal[2], $event, $calendarData, Calendar::SUBJECT_UNSHARE_USER); |
|
236 | + |
|
237 | + $parameters = [ |
|
238 | + 'actor' => $event->getAuthor(), |
|
239 | + 'calendar' => [ |
|
240 | + 'id' => (int) $calendarData['id'], |
|
241 | + 'uri' => $calendarData['uri'], |
|
242 | + 'name' => $calendarData['{DAV:}displayname'], |
|
243 | + ], |
|
244 | + 'group' => $principal[2], |
|
245 | + ]; |
|
246 | + |
|
247 | + if ($owner === $event->getAuthor()) { |
|
248 | + $subject = Calendar::SUBJECT_UNSHARE_GROUP . '_you'; |
|
249 | + } else { |
|
250 | + $event->setAffectedUser($event->getAuthor()) |
|
251 | + ->setSubject(Calendar::SUBJECT_UNSHARE_GROUP . '_you', $parameters); |
|
252 | + $this->activityManager->publish($event); |
|
253 | + |
|
254 | + $subject = Calendar::SUBJECT_UNSHARE_GROUP . '_by'; |
|
255 | + } |
|
256 | + |
|
257 | + $event->setAffectedUser($owner) |
|
258 | + ->setSubject($subject, $parameters); |
|
259 | + $this->activityManager->publish($event); |
|
260 | + } |
|
261 | + } |
|
262 | + |
|
263 | + foreach ($add as $share) { |
|
264 | + if ($this->isAlreadyShared($share['href'], $shares)) { |
|
265 | + continue; |
|
266 | + } |
|
267 | + |
|
268 | + // principal:principals/users/test |
|
269 | + $parts = explode(':', $share['href'], 2); |
|
270 | + if ($parts[0] !== 'principal') { |
|
271 | + continue; |
|
272 | + } |
|
273 | + $principal = explode('/', $parts[1]); |
|
274 | + |
|
275 | + if ($principal[1] === 'users') { |
|
276 | + $this->triggerActivityUser($principal[2], $event, $calendarData, Calendar::SUBJECT_SHARE_USER); |
|
277 | + |
|
278 | + if ($owner !== $principal[2]) { |
|
279 | + $parameters = [ |
|
280 | + 'actor' => $event->getAuthor(), |
|
281 | + 'calendar' => [ |
|
282 | + 'id' => (int) $calendarData['id'], |
|
283 | + 'uri' => $calendarData['uri'], |
|
284 | + 'name' => $calendarData['{DAV:}displayname'], |
|
285 | + ], |
|
286 | + 'user' => $principal[2], |
|
287 | + ]; |
|
288 | + |
|
289 | + if ($owner === $event->getAuthor()) { |
|
290 | + $subject = Calendar::SUBJECT_SHARE_USER . '_you'; |
|
291 | + } else { |
|
292 | + $event->setAffectedUser($event->getAuthor()) |
|
293 | + ->setSubject(Calendar::SUBJECT_SHARE_USER . '_you', $parameters); |
|
294 | + $this->activityManager->publish($event); |
|
295 | + |
|
296 | + $subject = Calendar::SUBJECT_SHARE_USER . '_by'; |
|
297 | + } |
|
298 | + |
|
299 | + $event->setAffectedUser($owner) |
|
300 | + ->setSubject($subject, $parameters); |
|
301 | + $this->activityManager->publish($event); |
|
302 | + } |
|
303 | + } elseif ($principal[1] === 'groups') { |
|
304 | + $this->triggerActivityGroup($principal[2], $event, $calendarData, Calendar::SUBJECT_SHARE_USER); |
|
305 | + |
|
306 | + $parameters = [ |
|
307 | + 'actor' => $event->getAuthor(), |
|
308 | + 'calendar' => [ |
|
309 | + 'id' => (int) $calendarData['id'], |
|
310 | + 'uri' => $calendarData['uri'], |
|
311 | + 'name' => $calendarData['{DAV:}displayname'], |
|
312 | + ], |
|
313 | + 'group' => $principal[2], |
|
314 | + ]; |
|
315 | + |
|
316 | + if ($owner === $event->getAuthor()) { |
|
317 | + $subject = Calendar::SUBJECT_SHARE_GROUP . '_you'; |
|
318 | + } else { |
|
319 | + $event->setAffectedUser($event->getAuthor()) |
|
320 | + ->setSubject(Calendar::SUBJECT_SHARE_GROUP . '_you', $parameters); |
|
321 | + $this->activityManager->publish($event); |
|
322 | + |
|
323 | + $subject = Calendar::SUBJECT_SHARE_GROUP . '_by'; |
|
324 | + } |
|
325 | + |
|
326 | + $event->setAffectedUser($owner) |
|
327 | + ->setSubject($subject, $parameters); |
|
328 | + $this->activityManager->publish($event); |
|
329 | + } |
|
330 | + } |
|
331 | + } |
|
332 | + |
|
333 | + /** |
|
334 | + * Checks if a calendar is already shared with a principal |
|
335 | + * |
|
336 | + * @param string $principal |
|
337 | + * @param array[] $shares |
|
338 | + * @return bool |
|
339 | + */ |
|
340 | + protected function isAlreadyShared($principal, $shares) { |
|
341 | + foreach ($shares as $share) { |
|
342 | + if ($principal === $share['href']) { |
|
343 | + return true; |
|
344 | + } |
|
345 | + } |
|
346 | + |
|
347 | + return false; |
|
348 | + } |
|
349 | + |
|
350 | + /** |
|
351 | + * Creates the given activity for all members of the given group |
|
352 | + * |
|
353 | + * @param string $gid |
|
354 | + * @param IEvent $event |
|
355 | + * @param array $properties |
|
356 | + * @param string $subject |
|
357 | + */ |
|
358 | + protected function triggerActivityGroup($gid, IEvent $event, array $properties, $subject) { |
|
359 | + $group = $this->groupManager->get($gid); |
|
360 | + |
|
361 | + if ($group instanceof IGroup) { |
|
362 | + foreach ($group->getUsers() as $user) { |
|
363 | + // Exclude current user |
|
364 | + if ($user->getUID() !== $event->getAuthor()) { |
|
365 | + $this->triggerActivityUser($user->getUID(), $event, $properties, $subject); |
|
366 | + } |
|
367 | + } |
|
368 | + } |
|
369 | + } |
|
370 | + |
|
371 | + /** |
|
372 | + * Creates the given activity for the given user |
|
373 | + * |
|
374 | + * @param string $user |
|
375 | + * @param IEvent $event |
|
376 | + * @param array $properties |
|
377 | + * @param string $subject |
|
378 | + * @param string $subjectSelf |
|
379 | + */ |
|
380 | + protected function triggerActivityUser($user, IEvent $event, array $properties, $subject, $subjectSelf = '') { |
|
381 | + $event->setAffectedUser($user) |
|
382 | + ->setSubject( |
|
383 | + $user === $event->getAuthor() && $subjectSelf ? $subjectSelf : $subject, |
|
384 | + [ |
|
385 | + 'actor' => $event->getAuthor(), |
|
386 | + 'calendar' => [ |
|
387 | + 'id' => (int) $properties['id'], |
|
388 | + 'uri' => $properties['uri'], |
|
389 | + 'name' => $properties['{DAV:}displayname'], |
|
390 | + ], |
|
391 | + ] |
|
392 | + ); |
|
393 | + |
|
394 | + $this->activityManager->publish($event); |
|
395 | + } |
|
396 | + |
|
397 | + /** |
|
398 | + * Creates activities when a calendar object was created/updated/deleted |
|
399 | + * |
|
400 | + * @param string $action |
|
401 | + * @param array $calendarData |
|
402 | + * @param array $shares |
|
403 | + * @param array $objectData |
|
404 | + */ |
|
405 | + public function onTouchCalendarObject($action, array $calendarData, array $shares, array $objectData) { |
|
406 | + if (!isset($calendarData['principaluri'])) { |
|
407 | + return; |
|
408 | + } |
|
409 | + |
|
410 | + $principal = explode('/', $calendarData['principaluri']); |
|
411 | + $owner = array_pop($principal); |
|
412 | + |
|
413 | + $currentUser = $this->userSession->getUser(); |
|
414 | + if ($currentUser instanceof IUser) { |
|
415 | + $currentUser = $currentUser->getUID(); |
|
416 | + } else { |
|
417 | + $currentUser = $owner; |
|
418 | + } |
|
419 | + |
|
420 | + $classification = $objectData['classification'] ?? CalDavBackend::CLASSIFICATION_PUBLIC; |
|
421 | + $object = $this->getObjectNameAndType($objectData); |
|
422 | + $action = $action . '_' . $object['type']; |
|
423 | + |
|
424 | + if ($object['type'] === 'todo' && strpos($action, Event::SUBJECT_OBJECT_UPDATE) === 0 && $object['status'] === 'COMPLETED') { |
|
425 | + $action .= '_completed'; |
|
426 | + } elseif ($object['type'] === 'todo' && strpos($action, Event::SUBJECT_OBJECT_UPDATE) === 0 && $object['status'] === 'NEEDS-ACTION') { |
|
427 | + $action .= '_needs_action'; |
|
428 | + } |
|
429 | + |
|
430 | + $event = $this->activityManager->generateEvent(); |
|
431 | + $event->setApp('dav') |
|
432 | + ->setObject('calendar', (int) $calendarData['id']) |
|
433 | + ->setType($object['type'] === 'event' ? 'calendar_event' : 'calendar_todo') |
|
434 | + ->setAuthor($currentUser); |
|
435 | + |
|
436 | + $users = $this->getUsersForShares($shares); |
|
437 | + $users[] = $owner; |
|
438 | + |
|
439 | + // Users for share can return the owner itself if the calendar is published |
|
440 | + foreach (array_unique($users) as $user) { |
|
441 | + if ($classification === CalDavBackend::CLASSIFICATION_PRIVATE && $user !== $owner) { |
|
442 | + // Private events are only shown to the owner |
|
443 | + continue; |
|
444 | + } |
|
445 | + |
|
446 | + $params = [ |
|
447 | + 'actor' => $event->getAuthor(), |
|
448 | + 'calendar' => [ |
|
449 | + 'id' => (int) $calendarData['id'], |
|
450 | + 'uri' => $calendarData['uri'], |
|
451 | + 'name' => $calendarData['{DAV:}displayname'], |
|
452 | + ], |
|
453 | + 'object' => [ |
|
454 | + 'id' => $object['id'], |
|
455 | + 'name' => $classification === CalDavBackend::CLASSIFICATION_CONFIDENTIAL && $user !== $owner ? 'Busy' : $object['name'], |
|
456 | + 'classified' => $classification === CalDavBackend::CLASSIFICATION_CONFIDENTIAL && $user !== $owner, |
|
457 | + ], |
|
458 | + ]; |
|
459 | + |
|
460 | + if ($object['type'] === 'event' && strpos($action, Event::SUBJECT_OBJECT_DELETE) === false && $this->appManager->isEnabledForUser('calendar')) { |
|
461 | + $params['object']['link']['object_uri'] = $objectData['uri']; |
|
462 | + $params['object']['link']['calendar_uri'] = $calendarData['uri']; |
|
463 | + $params['object']['link']['owner'] = $owner; |
|
464 | + } |
|
465 | + |
|
466 | + |
|
467 | + $event->setAffectedUser($user) |
|
468 | + ->setSubject( |
|
469 | + $user === $currentUser ? $action . '_self' : $action, |
|
470 | + $params |
|
471 | + ); |
|
472 | + |
|
473 | + $this->activityManager->publish($event); |
|
474 | + } |
|
475 | + } |
|
476 | + |
|
477 | + /** |
|
478 | + * @param array $objectData |
|
479 | + * @return string[]|bool |
|
480 | + */ |
|
481 | + protected function getObjectNameAndType(array $objectData) { |
|
482 | + $vObject = Reader::read($objectData['calendardata']); |
|
483 | + $component = $componentType = null; |
|
484 | + foreach ($vObject->getComponents() as $component) { |
|
485 | + if (in_array($component->name, ['VEVENT', 'VTODO'])) { |
|
486 | + $componentType = $component->name; |
|
487 | + break; |
|
488 | + } |
|
489 | + } |
|
490 | + |
|
491 | + if (!$componentType) { |
|
492 | + // Calendar objects must have a VEVENT or VTODO component |
|
493 | + return false; |
|
494 | + } |
|
495 | + |
|
496 | + if ($componentType === 'VEVENT') { |
|
497 | + return ['id' => (string) $component->UID, 'name' => (string) $component->SUMMARY, 'type' => 'event']; |
|
498 | + } |
|
499 | + return ['id' => (string) $component->UID, 'name' => (string) $component->SUMMARY, 'type' => 'todo', 'status' => (string) $component->STATUS]; |
|
500 | + } |
|
501 | + |
|
502 | + /** |
|
503 | + * Get all users that have access to a given calendar |
|
504 | + * |
|
505 | + * @param array $shares |
|
506 | + * @return string[] |
|
507 | + */ |
|
508 | + protected function getUsersForShares(array $shares) { |
|
509 | + $users = $groups = []; |
|
510 | + foreach ($shares as $share) { |
|
511 | + $principal = explode('/', $share['{http://owncloud.org/ns}principal']); |
|
512 | + if ($principal[1] === 'users') { |
|
513 | + $users[] = $principal[2]; |
|
514 | + } elseif ($principal[1] === 'groups') { |
|
515 | + $groups[] = $principal[2]; |
|
516 | + } |
|
517 | + } |
|
518 | + |
|
519 | + if (!empty($groups)) { |
|
520 | + foreach ($groups as $gid) { |
|
521 | + $group = $this->groupManager->get($gid); |
|
522 | + if ($group instanceof IGroup) { |
|
523 | + foreach ($group->getUsers() as $user) { |
|
524 | + $users[] = $user->getUID(); |
|
525 | + } |
|
526 | + } |
|
527 | + } |
|
528 | + } |
|
529 | + |
|
530 | + return array_unique($users); |
|
531 | + } |
|
532 | 532 | } |
@@ -148,7 +148,7 @@ discard block |
||
148 | 148 | foreach ($users as $user) { |
149 | 149 | $event->setAffectedUser($user) |
150 | 150 | ->setSubject( |
151 | - $user === $currentUser ? $action . '_self' : $action, |
|
151 | + $user === $currentUser ? $action.'_self' : $action, |
|
152 | 152 | [ |
153 | 153 | 'actor' => $currentUser, |
154 | 154 | 'calendar' => [ |
@@ -201,7 +201,7 @@ discard block |
||
201 | 201 | $event, |
202 | 202 | $calendarData, |
203 | 203 | Calendar::SUBJECT_UNSHARE_USER, |
204 | - Calendar::SUBJECT_DELETE . '_self' |
|
204 | + Calendar::SUBJECT_DELETE.'_self' |
|
205 | 205 | ); |
206 | 206 | |
207 | 207 | if ($owner !== $principal[2]) { |
@@ -216,15 +216,15 @@ discard block |
||
216 | 216 | ]; |
217 | 217 | |
218 | 218 | if ($owner === $event->getAuthor()) { |
219 | - $subject = Calendar::SUBJECT_UNSHARE_USER . '_you'; |
|
219 | + $subject = Calendar::SUBJECT_UNSHARE_USER.'_you'; |
|
220 | 220 | } elseif ($principal[2] === $event->getAuthor()) { |
221 | - $subject = Calendar::SUBJECT_UNSHARE_USER . '_self'; |
|
221 | + $subject = Calendar::SUBJECT_UNSHARE_USER.'_self'; |
|
222 | 222 | } else { |
223 | 223 | $event->setAffectedUser($event->getAuthor()) |
224 | - ->setSubject(Calendar::SUBJECT_UNSHARE_USER . '_you', $parameters); |
|
224 | + ->setSubject(Calendar::SUBJECT_UNSHARE_USER.'_you', $parameters); |
|
225 | 225 | $this->activityManager->publish($event); |
226 | 226 | |
227 | - $subject = Calendar::SUBJECT_UNSHARE_USER . '_by'; |
|
227 | + $subject = Calendar::SUBJECT_UNSHARE_USER.'_by'; |
|
228 | 228 | } |
229 | 229 | |
230 | 230 | $event->setAffectedUser($owner) |
@@ -245,13 +245,13 @@ discard block |
||
245 | 245 | ]; |
246 | 246 | |
247 | 247 | if ($owner === $event->getAuthor()) { |
248 | - $subject = Calendar::SUBJECT_UNSHARE_GROUP . '_you'; |
|
248 | + $subject = Calendar::SUBJECT_UNSHARE_GROUP.'_you'; |
|
249 | 249 | } else { |
250 | 250 | $event->setAffectedUser($event->getAuthor()) |
251 | - ->setSubject(Calendar::SUBJECT_UNSHARE_GROUP . '_you', $parameters); |
|
251 | + ->setSubject(Calendar::SUBJECT_UNSHARE_GROUP.'_you', $parameters); |
|
252 | 252 | $this->activityManager->publish($event); |
253 | 253 | |
254 | - $subject = Calendar::SUBJECT_UNSHARE_GROUP . '_by'; |
|
254 | + $subject = Calendar::SUBJECT_UNSHARE_GROUP.'_by'; |
|
255 | 255 | } |
256 | 256 | |
257 | 257 | $event->setAffectedUser($owner) |
@@ -287,13 +287,13 @@ discard block |
||
287 | 287 | ]; |
288 | 288 | |
289 | 289 | if ($owner === $event->getAuthor()) { |
290 | - $subject = Calendar::SUBJECT_SHARE_USER . '_you'; |
|
290 | + $subject = Calendar::SUBJECT_SHARE_USER.'_you'; |
|
291 | 291 | } else { |
292 | 292 | $event->setAffectedUser($event->getAuthor()) |
293 | - ->setSubject(Calendar::SUBJECT_SHARE_USER . '_you', $parameters); |
|
293 | + ->setSubject(Calendar::SUBJECT_SHARE_USER.'_you', $parameters); |
|
294 | 294 | $this->activityManager->publish($event); |
295 | 295 | |
296 | - $subject = Calendar::SUBJECT_SHARE_USER . '_by'; |
|
296 | + $subject = Calendar::SUBJECT_SHARE_USER.'_by'; |
|
297 | 297 | } |
298 | 298 | |
299 | 299 | $event->setAffectedUser($owner) |
@@ -314,13 +314,13 @@ discard block |
||
314 | 314 | ]; |
315 | 315 | |
316 | 316 | if ($owner === $event->getAuthor()) { |
317 | - $subject = Calendar::SUBJECT_SHARE_GROUP . '_you'; |
|
317 | + $subject = Calendar::SUBJECT_SHARE_GROUP.'_you'; |
|
318 | 318 | } else { |
319 | 319 | $event->setAffectedUser($event->getAuthor()) |
320 | - ->setSubject(Calendar::SUBJECT_SHARE_GROUP . '_you', $parameters); |
|
320 | + ->setSubject(Calendar::SUBJECT_SHARE_GROUP.'_you', $parameters); |
|
321 | 321 | $this->activityManager->publish($event); |
322 | 322 | |
323 | - $subject = Calendar::SUBJECT_SHARE_GROUP . '_by'; |
|
323 | + $subject = Calendar::SUBJECT_SHARE_GROUP.'_by'; |
|
324 | 324 | } |
325 | 325 | |
326 | 326 | $event->setAffectedUser($owner) |
@@ -419,7 +419,7 @@ discard block |
||
419 | 419 | |
420 | 420 | $classification = $objectData['classification'] ?? CalDavBackend::CLASSIFICATION_PUBLIC; |
421 | 421 | $object = $this->getObjectNameAndType($objectData); |
422 | - $action = $action . '_' . $object['type']; |
|
422 | + $action = $action.'_'.$object['type']; |
|
423 | 423 | |
424 | 424 | if ($object['type'] === 'todo' && strpos($action, Event::SUBJECT_OBJECT_UPDATE) === 0 && $object['status'] === 'COMPLETED') { |
425 | 425 | $action .= '_completed'; |
@@ -466,7 +466,7 @@ discard block |
||
466 | 466 | |
467 | 467 | $event->setAffectedUser($user) |
468 | 468 | ->setSubject( |
469 | - $user === $currentUser ? $action . '_self' : $action, |
|
469 | + $user === $currentUser ? $action.'_self' : $action, |
|
470 | 470 | $params |
471 | 471 | ); |
472 | 472 |