]> git.mxchange.org Git - friendica-addons.git/blob - dav/dav_caldav_backend_friendica.inc.php
privacy_image_cache: Adding a file cache
[friendica-addons.git] / dav / dav_caldav_backend_friendica.inc.php
1 <?php
2
3 class Sabre_CalDAV_Backend_Friendica extends Sabre_CalDAV_Backend_Common
4 {
5
6         public function getNamespace() {
7                 return CALDAV_NAMESPACE_FRIENDICA_NATIVE;
8         }
9
10         public function getCalUrlPrefix() {
11                 return "friendica";
12         }
13
14
15         /**
16          * Creates a new calendar for a principal.
17          *
18          * If the creation was a success, an id must be returned that can be used to reference
19          * this calendar in other methods, such as updateCalendar.
20          *
21          * @param string $principalUri
22          * @param string $calendarUri
23          * @param array $properties
24          * @throws Sabre_DAV_Exception_Forbidden
25          * @return void
26          */
27         function createCalendar($principalUri, $calendarUri, array $properties)
28         {
29                 throw new Sabre_DAV_Exception_Forbidden();
30         }
31
32         /**
33          * Delete a calendar and all it's objects
34          *
35          * @param string $calendarId
36          * @throws Sabre_DAV_Exception_Forbidden
37          * @return void
38          */
39         function deleteCalendar($calendarId)
40         {
41                 throw new Sabre_DAV_Exception_Forbidden();
42         }
43
44         /**
45          * @param string $calendarId
46          * @return array
47          */
48         function getCalendarObjects($calendarId)
49         {
50                 $a = get_app();
51                 $user_id = $a->user["uid"];
52                 $x = explode("-", $calendarId);
53
54                 $ret = array();
55                 $objs = FriendicaVirtualCalSourceBackend::getItemsByTime($user_id, $x[1]);
56                 foreach ($objs as $obj) {
57                         $ret[] = array(
58                                 "id" => IntVal($obj["data_uri"]),
59                                 "calendardata" => $obj["ical"],
60                                 "uri" => $obj["data_uri"],
61                                 "lastmodified" => $obj["date"],
62                                 "calendarid" => $calendarId,
63                                 "etag" => $obj["ical_etag"],
64                                 "size" => IntVal($obj["ical_size"]),
65                         );
66                 }
67
68                 return $ret;
69         }
70
71         /**
72          * Returns information from a single calendar object, based on it's object
73          * uri.
74          *
75          * The returned array must have the same keys as getCalendarObjects. The
76          * 'calendardata' object is required here though, while it's not required
77          * for getCalendarObjects.
78          *
79          * @param string $calendarId
80          * @param string $objectUri
81          * @throws Sabre_DAV_Exception_FileNotFound
82          * @return array
83          */
84         function getCalendarObject($calendarId, $objectUri)
85         {
86                 $a = get_app();
87                 $user_id = $a->user["uid"];
88                 $obj = FriendicaVirtualCalSourceBackend::getItemsByUri($user_id, $objectUri);
89
90                 return array(
91                         "id" => IntVal($obj["data_uri"]),
92                         "calendardata" => $obj["ical"],
93                         "uri" => $obj["data_uri"],
94                         "lastmodified" => $obj["date"],
95                         "calendarid" => $calendarId,
96                         "etag" => $obj["ical_etag"],
97                         "size" => IntVal($obj["ical_size"]),
98                 );
99         }
100
101         /**
102          * Creates a new calendar object.
103          *
104          * @param string $calendarId
105          * @param string $objectUri
106          * @param string $calendarData
107          * @throws Sabre_DAV_Exception_Forbidden
108          * @return null|string|void
109          */
110         function createCalendarObject($calendarId, $objectUri, $calendarData)
111         {
112                 throw new Sabre_DAV_Exception_Forbidden();
113         }
114
115         /**
116          * Updates an existing calendarobject, based on it's uri.
117          *
118          * @param string $calendarId
119          * @param string $objectUri
120          * @param string $calendarData
121          * @throws Sabre_DAV_Exception_Forbidden
122          * @return null|string|void
123          */
124         function updateCalendarObject($calendarId, $objectUri, $calendarData)
125         {
126                 throw new Sabre_DAV_Exception_Forbidden();
127         }
128
129         /**
130          * Deletes an existing calendar object.
131          *
132          * @param string $calendarId
133          * @param string $objectUri
134          * @throws Sabre_DAV_Exception_Forbidden
135          * @return void
136          */
137         function deleteCalendarObject($calendarId, $objectUri)
138         {
139                 throw new Sabre_DAV_Exception_Forbidden();
140         }
141 }