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"]);
90 "uri" => $row["data_uri"],
91 "subject" => escape_tags($row["data_subject"]),
94 "is_allday" => ($row["data_allday"] == 1),
95 "is_moredays" => (date("Ymd", $start) != date("Ymd", $end)),
96 "is_recurring" => ($row["data_type"] == "birthday"),
98 "is_editable" => false,
99 "is_editable_quick" => false,
100 "location" => $row["data_location"],
102 "has_notification" => false,
103 "url_detail" => $a->get_baseurl() . "/dav/wdcal/" . $row["data_uri"] . "/",
105 "special_type" => ($row["data_type"] == "birthday" ? "birthday" : ""),
113 * @param string $base_path
116 public function listItemsByRange($sd, $ed, $base_path)
118 $usr_id = IntVal($this->calendarDb->uid);
120 $evs = FriendicaVirtualCalSourceBackend::getItemsByTime($usr_id, $this->namespace_id, $sd, $ed);
122 foreach ($evs as $row) $events[] = $this->virtualData2wdcal($row);
129 * @throws Sabre_DAV_Exception_MethodNotAllowed
132 public function removeItem($uri) {
133 throw new Sabre_DAV_Exception_MethodNotAllowed();
140 public function getItemByUri($uri)
142 $usr_id = IntVal($this->calendarDb->uid);
143 $row = FriendicaVirtualCalSourceBackend::getItemsByUri($usr_id, $uri);
144 return $this->virtualData2wdcal($row);
151 public function getItemDetailRedirect($uri) {
152 $x = explode("@", $uri);
153 $y = explode("-", $x[0]);
155 if (count($y) != 3) {
156 goaway($a->get_baseurl() . "/dav/wdcal/");
160 $item = q("SELECT `id` FROM `item` WHERE `event-id` = %d AND `uid` = %d AND deleted = 0", IntVal($y[2]), $a->user["uid"]);
161 if (count($item) == 0) return "/events/";
162 return "/display/" . $a->user["nickname"] . "/" . IntVal($item[0]["id"]);