annotate plugins/calendar/drivers/kolab/kolab_user_calendar.php @ 3:f6fe4b6ae66a

calendar plugin nearly as distributed
author Charlie Root
date Sat, 13 Jan 2018 08:56:12 -0500
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
3
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
1 <?php
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
2
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
3 /**
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
4 * Kolab calendar storage class simulating a virtual user calendar
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
5 *
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
6 * @author Thomas Bruederli <bruederli@kolabsys.com>
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
7 *
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
8 * Copyright (C) 2014-2016, Kolab Systems AG <contact@kolabsys.com>
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
9 *
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
10 * This program is free software: you can redistribute it and/or modify
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
11 * it under the terms of the GNU Affero General Public License as
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
12 * published by the Free Software Foundation, either version 3 of the
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
13 * License, or (at your option) any later version.
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
14 *
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
15 * This program is distributed in the hope that it will be useful,
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
18 * GNU Affero General Public License for more details.
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
19 *
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
20 * You should have received a copy of the GNU Affero General Public License
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
21 * along with this program. If not, see <http://www.gnu.org/licenses/>.
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
22 */
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
23
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
24 class kolab_user_calendar extends kolab_calendar
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
25 {
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
26 public $id = 'unknown';
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
27 public $ready = false;
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
28 public $editable = false;
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
29 public $attachments = false;
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
30 public $subscriptions = false;
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
31
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
32 protected $userdata = array();
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
33 protected $timeindex = array();
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
34
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
35
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
36 /**
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
37 * Default constructor
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
38 */
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
39 public function __construct($user_or_folder, $calendar)
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
40 {
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
41 $this->cal = $calendar;
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
42
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
43 // full user record is provided
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
44 if (is_array($user_or_folder)) {
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
45 $this->userdata = $user_or_folder;
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
46 $this->storage = new kolab_storage_folder_user($this->userdata['kolabtargetfolder'], '', $this->userdata);
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
47 }
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
48 else if ($user_or_folder instanceof kolab_storage_folder_user) {
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
49 $this->storage = $user_or_folder;
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
50 $this->userdata = $this->storage->ldaprec;
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
51 }
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
52 else { // get user record from LDAP
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
53 $this->storage = new kolab_storage_folder_user($user_or_folder);
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
54 $this->userdata = $this->storage->ldaprec;
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
55 }
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
56
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
57 $this->ready = !empty($this->userdata['kolabtargetfolder']);
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
58 $this->storage->type = 'event';
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
59
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
60 if ($this->ready) {
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
61 // ID is derrived from the user's kolabtargetfolder attribute
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
62 $this->id = kolab_storage::folder_id($this->userdata['kolabtargetfolder'], true);
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
63 $this->imap_folder = $this->userdata['kolabtargetfolder'];
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
64 $this->name = $this->storage->name;
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
65 $this->parent = ''; // user calendars are top level
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
66
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
67 // user-specific alarms settings win
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
68 $prefs = $this->cal->rc->config->get('kolab_calendars', array());
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
69 if (isset($prefs[$this->id]['showalarms']))
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
70 $this->alarms = $prefs[$this->id]['showalarms'];
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
71 }
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
72 }
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
73
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
74 /**
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
75 * Getter for a nice and human readable name for this calendar
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
76 *
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
77 * @return string Name of this calendar
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
78 */
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
79 public function get_name()
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
80 {
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
81 return $this->userdata['displayname'] ?: ($this->userdata['name'] ?: $this->userdata['mail']);
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
82 }
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
83
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
84 /**
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
85 * Getter for the IMAP folder owner
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
86 *
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
87 * @param bool Return a fully qualified owner name (unused)
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
88 *
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
89 * @return string Name of the folder owner
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
90 */
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
91 public function get_owner($fully_qualified = false)
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
92 {
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
93 return $this->userdata['mail'];
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
94 }
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
95
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
96 /**
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
97 *
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
98 */
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
99 public function get_title()
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
100 {
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
101 return trim($this->userdata['displayname'] . '; ' . $this->userdata['mail'], '; ');
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
102 }
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
103
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
104 /**
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
105 * Getter for the name of the namespace to which the IMAP folder belongs
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
106 *
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
107 * @return string Name of the namespace (personal, other, shared)
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
108 */
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
109 public function get_namespace()
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
110 {
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
111 return 'other user';
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
112 }
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
113
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
114 /**
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
115 * Getter for the top-end calendar folder name (not the entire path)
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
116 *
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
117 * @return string Name of this calendar
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
118 */
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
119 public function get_foldername()
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
120 {
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
121 return $this->get_name();
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
122 }
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
123
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
124 /**
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
125 * Return color to display this calendar
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
126 */
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
127 public function get_color($default = null)
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
128 {
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
129 // calendar color is stored in local user prefs
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
130 $prefs = $this->cal->rc->config->get('kolab_calendars', array());
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
131
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
132 if (!empty($prefs[$this->id]) && !empty($prefs[$this->id]['color']))
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
133 return $prefs[$this->id]['color'];
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
134
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
135 return $default ?: 'cc0000';
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
136 }
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
137
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
138 /**
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
139 * Compose an URL for CalDAV access to this calendar (if configured)
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
140 */
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
141 public function get_caldav_url()
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
142 {
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
143 return false;
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
144 }
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
145
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
146 /**
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
147 * Check subscription status of this folder
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
148 *
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
149 * @return boolean True if subscribed, false if not
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
150 */
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
151 public function is_subscribed()
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
152 {
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
153 return $this->storage->is_subscribed();
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
154 }
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
155
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
156 /**
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
157 * Update properties of this calendar folder
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
158 *
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
159 * @see calendar_driver::edit_calendar()
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
160 */
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
161 public function update(&$prop)
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
162 {
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
163 // don't change anything.
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
164 // let kolab_driver save props in local prefs
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
165 return $prop['id'];
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
166 }
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
167
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
168 /**
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
169 * Getter for a single event object
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
170 */
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
171 public function get_event($id)
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
172 {
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
173 // TODO: implement this
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
174 return $this->events[$id];
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
175 }
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
176
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
177 /**
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
178 * Get attachment body
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
179 * @see calendar_driver::get_attachment_body()
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
180 */
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
181 public function get_attachment_body($id, $event)
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
182 {
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
183 if (!$event['calendar'] && ($ev = $this->get_event($event['id']))) {
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
184 $event['calendar'] = $ev['calendar'];
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
185 }
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
186
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
187 if ($event['calendar'] && ($cal = $this->cal->get_calendar($event['calendar']))) {
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
188 return $cal->get_attachment_body($id, $event);
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
189 }
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
190
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
191 return false;
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
192 }
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
193
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
194 /**
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
195 * @param integer Event's new start (unix timestamp)
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
196 * @param integer Event's new end (unix timestamp)
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
197 * @param string Search query (optional)
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
198 * @param boolean Include virtual events (optional)
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
199 * @param array Additional parameters to query storage
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
200 * @param array Additional query to filter events
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
201 *
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
202 * @return array A list of event records
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
203 */
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
204 public function list_events($start, $end, $search = null, $virtual = 1, $query = array(), $filter_query = null)
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
205 {
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
206 // convert to DateTime for comparisons
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
207 try {
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
208 $start_dt = new DateTime('@'.$start);
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
209 }
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
210 catch (Exception $e) {
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
211 $start_dt = new DateTime('@0');
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
212 }
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
213 try {
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
214 $end_dt = new DateTime('@'.$end);
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
215 }
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
216 catch (Exception $e) {
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
217 $end_dt = new DateTime('today +10 years');
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
218 }
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
219
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
220 $limit_changed = null;
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
221 if (!empty($query)) {
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
222 foreach ($query as $q) {
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
223 if ($q[0] == 'changed' && $q[1] == '>=') {
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
224 try { $limit_changed = new DateTime('@'.$q[2]); }
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
225 catch (Exception $e) { /* ignore */ }
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
226 }
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
227 }
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
228 }
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
229
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
230 // aggregate all calendar folders the user shares (but are not activated)
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
231 foreach (kolab_storage::list_user_folders($this->userdata, 'event', 2) as $foldername) {
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
232 $cal = new kolab_calendar($foldername, $this->cal);
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
233 foreach ($cal->list_events($start, $end, $search, 1) as $event) {
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
234 $uid = $event['id'] ?: $event['uid'];
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
235 $this->events[$uid] = $event;
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
236 $this->timeindex[$this->time_key($event)] = $uid;
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
237 }
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
238 }
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
239
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
240 // get events from the user's free/busy feed (for quickview only)
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
241 $fbview = $this->cal->rc->config->get('calendar_include_freebusy_data', 1);
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
242 if ($fbview && ($fbview == 1 || !empty($_REQUEST['_quickview'])) && empty($search)) {
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
243 $this->fetch_freebusy($limit_changed);
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
244 }
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
245
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
246 $events = array();
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
247 foreach ($this->events as $event) {
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
248 // list events in requested time window
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
249 if ($event['start'] <= $end_dt && $event['end'] >= $start_dt &&
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
250 (!$limit_changed || !$event['changed'] || $event['changed'] >= $limit_changed)) {
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
251 $events[] = $event;
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
252 }
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
253 }
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
254
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
255 // avoid session race conditions that will loose temporary subscriptions
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
256 $this->cal->rc->session->nowrite = true;
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
257
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
258 return $events;
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
259 }
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
260
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
261 /**
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
262 *
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
263 * @param integer Date range start (unix timestamp)
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
264 * @param integer Date range end (unix timestamp)
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
265 * @param array Additional query to filter events
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
266 * @return integer Count
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
267 */
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
268 public function count_events($start, $end = null, $filter_query = null)
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
269 {
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
270 // not implemented
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
271 return 0;
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
272 }
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
273
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
274 /**
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
275 * Helper method to fetch free/busy data for the user and turn it into calendar data
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
276 */
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
277 private function fetch_freebusy($limit_changed = null)
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
278 {
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
279 // ask kolab server first
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
280 try {
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
281 $request_config = array(
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
282 'store_body' => true,
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
283 'follow_redirects' => true,
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
284 );
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
285 $request = libkolab::http_request(kolab_storage::get_freebusy_url($this->userdata['mail']), 'GET', $request_config);
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
286 $response = $request->send();
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
287
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
288 // authentication required
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
289 if ($response->getStatus() == 401) {
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
290 $request->setAuth($this->cal->rc->user->get_username(), $this->cal->rc->decrypt($_SESSION['password']));
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
291 $response = $request->send();
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
292 }
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
293
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
294 if ($response->getStatus() == 200)
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
295 $fbdata = $response->getBody();
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
296
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
297 unset($request, $response);
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
298 }
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
299 catch (Exception $e) {
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
300 rcube::raise_error(array(
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
301 'code' => 900,
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
302 'type' => 'php',
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
303 'file' => __FILE__,
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
304 'line' => __LINE__,
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
305 'message' => "Error fetching free/busy information: " . $e->getMessage()),
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
306 true, false);
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
307
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
308 return false;
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
309 }
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
310
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
311 $statusmap = array(
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
312 'FREE' => 'free',
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
313 'BUSY' => 'busy',
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
314 'BUSY-TENTATIVE' => 'tentative',
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
315 'X-OUT-OF-OFFICE' => 'outofoffice',
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
316 'OOF' => 'outofoffice',
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
317 );
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
318 $titlemap = array(
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
319 'FREE' => $this->cal->gettext('availfree'),
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
320 'BUSY' => $this->cal->gettext('availbusy'),
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
321 'BUSY-TENTATIVE' => $this->cal->gettext('availtentative'),
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
322 'X-OUT-OF-OFFICE' => $this->cal->gettext('availoutofoffice'),
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
323 );
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
324
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
325 // rcube::console('_fetch_freebusy', kolab_storage::get_freebusy_url($this->userdata['mail']), $fbdata);
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
326
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
327 // parse free-busy information
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
328 $count = 0;
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
329 if ($fbdata) {
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
330 $ical = $this->cal->get_ical();
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
331 $ical->import($fbdata);
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
332 if ($fb = $ical->freebusy) {
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
333 // consider 'changed >= X' queries
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
334 if ($limit_changed && $fb['created'] && $fb['created'] < $limit_changed) {
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
335 return 0;
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
336 }
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
337
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
338 foreach ($fb['periods'] as $tuple) {
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
339 list($from, $to, $type) = $tuple;
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
340 $event = array(
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
341 'uid' => md5($this->id . $from->format('U') . '/' . $to->format('U')),
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
342 'calendar' => $this->id,
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
343 'changed' => $fb['created'] ?: new DateTime(),
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
344 'title' => $this->get_name() . ' ' . ($titlemap[$type] ?: $type),
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
345 'start' => $from,
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
346 'end' => $to,
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
347 'free_busy' => $statusmap[$type] ?: 'busy',
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
348 'className' => 'fc-type-freebusy',
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
349 'organizer' => array(
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
350 'email' => $this->userdata['mail'],
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
351 'name' => $this->userdata['displayname'],
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
352 ),
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
353 );
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
354
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
355 // avoid duplicate entries
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
356 $key = $this->time_key($event);
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
357 if (!$this->timeindex[$key]) {
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
358 $this->events[$event['uid']] = $event;
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
359 $this->timeindex[$key] = $event['uid'];
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
360 $count++;
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
361 }
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
362 }
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
363 }
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
364 }
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
365
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
366 return $count;
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
367 }
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
368
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
369 /**
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
370 * Helper to build a key for the absolute time slot the given event convers
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
371 */
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
372 private function time_key($event)
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
373 {
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
374 return sprintf('%s/%s', $event['start']->format('U'), is_object($event['end']) ? $event['end']->format('U') : '0');
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
375 }
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
376
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
377 /**
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
378 * Create a new event record
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
379 *
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
380 * @see calendar_driver::new_event()
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
381 *
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
382 * @return mixed The created record ID on success, False on error
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
383 */
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
384 public function insert_event($event)
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
385 {
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
386 return false;
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
387 }
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
388
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
389 /**
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
390 * Update a specific event record
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
391 *
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
392 * @see calendar_driver::new_event()
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
393 * @return boolean True on success, False on error
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
394 */
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
395 public function update_event($event, $exception_id = null)
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
396 {
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
397 return false;
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
398 }
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
399
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
400 /**
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
401 * Delete an event record
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
402 *
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
403 * @see calendar_driver::remove_event()
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
404 * @return boolean True on success, False on error
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
405 */
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
406 public function delete_event($event, $force = true)
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
407 {
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
408 return false;
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
409 }
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
410
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
411 /**
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
412 * Restore deleted event record
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
413 *
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
414 * @see calendar_driver::undelete_event()
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
415 * @return boolean True on success, False on error
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
416 */
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
417 public function restore_event($event)
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
418 {
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
419 return false;
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
420 }
f6fe4b6ae66a calendar plugin nearly as distributed
Charlie Root
parents:
diff changeset
421 }