]> git.mxchange.org Git - friendica-addons.git/blob - dav/common/wdcal_cal_source.inc.php
Merge remote branch 'friendica/master'
[friendica-addons.git] / dav / common / wdcal_cal_source.inc.php
1 <?php
2
3
4 abstract class AnimexxCalSource
5 {
6
7         /**
8          * @var int $namespace_id
9          */
10         protected $namespace_id;
11
12         /**
13          * @var DBClass_friendica_calendars $calendarDb
14          */
15         protected $calendarDb;
16
17         /**
18          * @var int
19          */
20         protected $user_id;
21
22
23         /**
24          * @param int $user_id
25          * @param int $namespace_id
26          * @throws Sabre_DAV_Exception_NotFound
27          */
28         function __construct($user_id = 0, $namespace_id = 0)
29         {
30                 $this->namespace_id = IntVal($namespace_id);
31                 $this->user_id = IntVal($user_id);
32
33                 $x                  = q("SELECT * FROM %s%scalendars WHERE `namespace` = %d AND `namespace_id` = %d AND `uid` = %d",
34                         CALDAV_SQL_DB, CALDAV_SQL_PREFIX, $this->getNamespace(), $this->namespace_id, $this->user_id
35                 );
36
37                 if (count($x) != 1) throw new Sabre_DAV_Exception_NotFound("Not found");
38
39                 try {
40                         $this->calendarDb = new DBClass_friendica_calendars($x[0]);
41                 } catch (Exception $e) {
42                         throw new Sabre_DAV_Exception_NotFound("Not found");
43                 }
44         }
45
46         /**
47          * @abstract
48          * @return int
49          */
50         public static abstract function getNamespace();
51
52         /**
53          * @abstract
54          * @param int $user
55          * @return array
56          */
57         public abstract function getPermissionsCalendar($user);
58
59         /**
60          * @abstract
61          * @param int $user
62          * @param string $item_uri
63          * @param string $recurrence_uri
64          * @param array|null $item_arr
65          * @return array
66          */
67         public abstract function getPermissionsItem($user, $item_uri, $recurrence_uri, $item_arr = null);
68
69         /**
70          * @param string $uri
71          * @param array $start
72          * @param array $end
73          * @param string $subject
74          * @param bool $allday
75          * @param string $description
76          * @param string $location
77          * @param null $color
78          * @param string $timezone
79          * @param bool $notification
80          * @param null $notification_type
81          * @param null $notification_value
82          */
83         public abstract function updateItem($uri, $start, $end, $subject = "", $allday = false, $description = "", $location = "", $color = null,
84                                                                                 $timezone = "", $notification = true, $notification_type = null, $notification_value = null);
85
86
87         /**
88          * @abstract
89          * @param array $start
90          * @param array $end
91          * @param string $subject
92          * @param bool $allday
93          * @param string $description
94          * @param string $location
95          * @param null $color
96          * @param string $timezone
97          * @param bool $notification
98          * @param null $notification_type
99          * @param null $notification_value
100          * @return array
101          */
102         public abstract function addItem($start, $end, $subject, $allday = false, $description = "", $location = "", $color = null,
103                                                                          $timezone = "", $notification = true, $notification_type = null, $notification_value = null);
104
105
106         /**
107          * @param string $uri
108          */
109         public abstract function removeItem($uri);
110
111
112         /**
113          * @abstract
114          * @param string $sd
115          * @param string $ed
116          * @param string $base_path
117          * @return array
118          */
119         public abstract function listItemsByRange($sd, $ed, $base_path);
120
121
122         /**
123          * @abstract
124          * @param string $uri
125          * @return array
126          */
127         public abstract function getItemByUri($uri);
128
129
130         /**
131          * @param string $uri
132          * @return null|string
133          */
134         public function getItemDetailRedirect($uri) {
135                 return null;
136         }
137
138 }