]> git.mxchange.org Git - friendica-addons.git/blob - dav/SabreDAV/lib/Sabre/CalDAV/Notifications/Collection.php
Merge remote branch 'friendica/master'
[friendica-addons.git] / dav / SabreDAV / lib / Sabre / CalDAV / Notifications / Collection.php
1 <?php
2
3 /**
4  * This node represents a list of notifications.
5  *
6  * It provides no additional functionality, but you must implement this
7  * interface to allow the Notifications plugin to mark the collection
8  * as a notifications collection.
9  *
10  * This collection should only return Sabre_CalDAV_Notifications_INode nodes as
11  * its children.
12  *
13  * @package Sabre
14  * @copyright Copyright (C) 2007-2012 Rooftop Solutions. All rights reserved.
15  * @author Evert Pot (http://www.rooftopsolutions.nl/)
16  * @license http://code.google.com/p/sabredav/wiki/License Modified BSD License
17  */
18 class Sabre_CalDAV_Notifications_Collection extends Sabre_DAV_Collection implements Sabre_CalDAV_Notifications_ICollection {
19
20     /**
21      * The notification backend
22      *
23      * @var Sabre_CalDAV_Backend_NotificationSupport
24      */
25     protected $caldavBackend;
26
27     /**
28      * Principal uri
29      *
30      * @var string
31      */
32     protected $principalUri;
33
34     /**
35      * Constructor
36      *
37      * @param Sabre_CalDAV_Backend_NotificationSupport $caldavBackend
38      * @param string $principalUri
39      */
40     public function __construct(Sabre_CalDAV_Backend_NotificationSupport $caldavBackend, $principalUri) {
41
42         $this->caldavBackend = $caldavBackend;
43         $this->principalUri = $principalUri;
44
45     }
46
47     /**
48      * Returns all notifications for a principal
49      *
50      * @return array
51      */
52     public function getChildren() {
53
54         $children = array();
55         $notifications = $this->caldavBackend->getNotificationsForPrincipal($this->principalUri);
56
57         foreach($notifications as $notification) {
58
59             $children[] = new Sabre_CalDAV_Notifications_Node(
60                 $this->caldavBackend,
61                 $notification
62             );
63         }
64
65         return $children;
66
67     }
68
69     /**
70      * Returns the name of this object
71      *
72      * @return string
73      */
74     public function getName() {
75
76         return 'notifications';
77
78     }
79
80 }