3 class FriendicaCalSourceEvents extends AnimexxCalSource
9 public static function getNamespace()
11 return CALDAV_NAMESPACE_FRIENDICA_NATIVE;
18 public function getPermissionsCalendar($user)
20 if ($user == $this->calendarDb->uid) return array("read"=> true, "write"=> false);
21 return array("read"=> false, "write"=> false);
26 * @param string $item_uri
27 * @param string $recurrence_uri
28 * @param null|array $item_arr
31 public function getPermissionsItem($user, $item_uri, $recurrence_uri, $item_arr = null)
33 $cal_perm = $this->getPermissionsCalendar($user);
34 if (!$cal_perm["read"]) return array("read"=> false, "write"=> false);
35 return array("read"=> true, "write"=> false);
43 * @param string $subject
45 * @param string $description
46 * @param string $location
48 * @param string $timezone
49 * @param bool $notification
50 * @param null $notification_type
51 * @param null $notification_value
52 * @throws Sabre_DAV_Exception_MethodNotAllowed
54 public function updateItem($uri, $start, $end, $subject = "", $allday = false, $description = "", $location = "", $color = null, $timezone = "", $notification = true, $notification_type = null, $notification_value = null)
56 throw new Sabre_DAV_Exception_MethodNotAllowed();
62 * @param string $subject
64 * @param string $description
65 * @param string $location
67 * @param string $timezone
68 * @param bool $notification
69 * @param null $notification_type
70 * @param null $notification_value
71 * @throws Sabre_DAV_Exception_MethodNotAllowed
72 * @return array|string
74 public function addItem($start, $end, $subject, $allday = false, $description = "", $location = "", $color = null,
75 $timezone = "", $notification = true, $notification_type = null, $notification_value = null)
77 throw new Sabre_DAV_Exception_MethodNotAllowed();
84 private function virtualData2wdcal($row) {
85 $end = wdcal_mySql2PhpTime($row["data_end"]);
86 if ($row["data_allday"]) $end--;
87 $start = wdcal_mySql2PhpTime($row["data_start"]);
89 "uri" => $row["data_uri"],
90 "subject" => escape_tags($row["data_subject"]),
93 "is_allday" => ($row["data_allday"] == 1),
94 "is_moredays" => (date("Ymd", $start) != date("Ymd", $end)),
95 "is_recurring" => ($row["data_type"] == "birthday"),
97 "is_editable" => false,
98 "is_editable_quick" => false,
99 "location" => $row["data_location"],
101 "has_notification" => false,
102 "url_detail" => "/dav/wdcal/" . $row["data_uri"] . "/",
104 "special_type" => ($row["data_type"] == "birthday" ? "birthday" : ""),
114 public function listItemsByRange($sd, $ed)
116 $usr_id = IntVal($this->calendarDb->uid);
118 $evs = FriendicaVirtualCalSourceBackend::getItemsByTime($usr_id, $this->namespace_id, $sd, $ed);
120 foreach ($evs as $row) $events[] = $this->virtualData2wdcal($row);
127 * @throws Sabre_DAV_Exception_MethodNotAllowed
130 public function removeItem($uri) {
131 throw new Sabre_DAV_Exception_MethodNotAllowed();
138 public function getItemByUri($uri)
140 $usr_id = IntVal($this->calendarDb->uid);
141 $row = FriendicaVirtualCalSourceBackend::getItemsByUri($usr_id, $uri);
142 return $this->virtualData2wdcal($row);
149 public function getItemDetailRedirect($uri) {
150 $x = explode("@", $uri);
151 $y = explode("-", $x[0]);
152 if (count($y) != 3) {
153 goaway("/dav/wdcal/");
157 $item = q("SELECT `id` FROM `item` WHERE `event-id` = %d AND `uid` = %d AND deleted = 0", IntVal($y[2]), $a->user["uid"]);
158 if (count($item) == 0) return "/events/";
159 return "/display/" . $a->user["nickname"] . "/" . IntVal($item[0]["id"]);