| Total Complexity | 41 |
| Total Lines | 568 |
| Duplicated Lines | 0 % |
| Changes | 1 | ||
| Bugs | 1 | Features | 0 |
Complex classes like GrommunioCalDavBackend often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes.
Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.
While breaking up the class, it is a good idea to analyze how other classes use GrommunioCalDavBackend, and based on these observations, apply Extract Interface, too.
| 1 | <?php |
||
| 16 | class GrommunioCalDavBackend extends AbstractBackend implements SchedulingSupport, SyncSupport { |
||
| 17 | /* |
||
| 18 | * TODO IMPLEMENT |
||
| 19 | * |
||
| 20 | * SubscriptionSupport, |
||
| 21 | * SharingSupport, |
||
| 22 | * |
||
| 23 | */ |
||
| 24 | |||
| 25 | private $logger; |
||
| 26 | protected $gDavBackend; |
||
| 27 | |||
| 28 | public const FILE_EXTENSION = '.ics'; |
||
| 29 | // TODO: implement Task support - Issue: #10 |
||
| 30 | public const MESSAGE_CLASSES = ['IPM.Appointment' /* , 'IPM.Note' */]; |
||
| 31 | public const CONTAINER_CLASS = 'IPF.Appointment'; |
||
| 32 | public const CONTAINER_CLASSES = ['IPF.Appointment', 'IPF.Task']; |
||
| 33 | |||
| 34 | /** |
||
| 35 | * Constructor. |
||
| 36 | */ |
||
| 37 | public function __construct(GrommunioDavBackend $gDavBackend, GLogger $glogger) { |
||
| 40 | } |
||
| 41 | |||
| 42 | /** |
||
| 43 | * Returns a list of calendars for a principal. |
||
| 44 | * |
||
| 45 | * Every project is an array with the following keys: |
||
| 46 | * * id, a unique id that will be used by other functions to modify the |
||
| 47 | * calendar. This can be the same as the uri or a database key. |
||
| 48 | * * uri. This is just the 'base uri' or 'filename' of the calendar. |
||
| 49 | * * principaluri. The owner of the calendar. Almost always the same as |
||
| 50 | * principalUri passed to this method. |
||
| 51 | * |
||
| 52 | * Furthermore it can contain webdav properties in clark notation. A very |
||
| 53 | * common one is '{DAV:}displayname'. |
||
| 54 | * |
||
| 55 | * Many clients also require: |
||
| 56 | * {urn:ietf:params:xml:ns:caldav}supported-calendar-component-set |
||
| 57 | * For this property, you can just return an instance of |
||
| 58 | * Sabre\CalDAV\Xml\Property\SupportedCalendarComponentSet. |
||
| 59 | * |
||
| 60 | * If you return {http://sabredav.org/ns}read-only and set the value to 1, |
||
| 61 | * ACL will automatically be put in read-only mode. |
||
| 62 | * |
||
| 63 | * @param string $principalUri |
||
| 64 | * |
||
| 65 | * @return array |
||
| 66 | */ |
||
| 67 | public function getCalendarsForUser($principalUri) { |
||
| 68 | $this->logger->trace("principalUri: %s", $principalUri); |
||
| 69 | |||
| 70 | return $this->gDavBackend->GetFolders($principalUri, static::CONTAINER_CLASSES); |
||
| 71 | } |
||
| 72 | |||
| 73 | /** |
||
| 74 | * Creates a new calendar for a principal. |
||
| 75 | * |
||
| 76 | * If the creation was a success, an id must be returned that can be used |
||
| 77 | * to reference this calendar in other methods, such as updateCalendar. |
||
| 78 | * |
||
| 79 | * @param string $principalUri |
||
| 80 | * @param string $calendarUri |
||
| 81 | * |
||
| 82 | * @return string |
||
| 83 | */ |
||
| 84 | public function createCalendar($principalUri, $calendarUri, array $properties) { |
||
| 85 | $this->logger->trace("principalUri: %s - calendarUri: %s - properties: %s", $principalUri, $calendarUri, $properties); |
||
| 86 | |||
| 87 | // TODO Add displayname |
||
| 88 | return $this->gDavBackend->CreateFolder($principalUri, $calendarUri, static::CONTAINER_CLASS, ""); |
||
| 89 | } |
||
| 90 | |||
| 91 | /** |
||
| 92 | * Delete a calendar and all its objects. |
||
| 93 | * |
||
| 94 | * @param string $calendarId |
||
| 95 | */ |
||
| 96 | public function deleteCalendar($calendarId) { |
||
| 97 | $this->logger->trace("calendarId: %s", $calendarId); |
||
| 98 | $success = $this->gDavBackend->DeleteFolder($calendarId); |
||
|
|
|||
| 99 | // TODO evaluate $success |
||
| 100 | } |
||
| 101 | |||
| 102 | /** |
||
| 103 | * Returns all calendar objects within a calendar. |
||
| 104 | * |
||
| 105 | * Every item contains an array with the following keys: |
||
| 106 | * * calendardata - The iCalendar-compatible calendar data |
||
| 107 | * * uri - a unique key which will be used to construct the uri. This can |
||
| 108 | * be any arbitrary string, but making sure it ends with '.ics' is a |
||
| 109 | * good idea. This is only the basename, or filename, not the full |
||
| 110 | * path. |
||
| 111 | * * lastmodified - a timestamp of the last modification time |
||
| 112 | * * etag - An arbitrary string, surrounded by double-quotes. (e.g.: |
||
| 113 | * ' "abcdef"') |
||
| 114 | * * size - The size of the calendar objects, in bytes. |
||
| 115 | * * component - optional, a string containing the type of object, such |
||
| 116 | * as 'vevent' or 'vtodo'. If specified, this will be used to populate |
||
| 117 | * the Content-Type header. |
||
| 118 | * |
||
| 119 | * Note that the etag is optional, but it's highly encouraged to return for |
||
| 120 | * speed reasons. |
||
| 121 | * |
||
| 122 | * The calendardata is also optional. If it's not returned |
||
| 123 | * 'getCalendarObject' will be called later, which *is* expected to return |
||
| 124 | * calendardata. |
||
| 125 | * |
||
| 126 | * If neither etag or size are specified, the calendardata will be |
||
| 127 | * used/fetched to determine these numbers. If both are specified the |
||
| 128 | * amount of times this is needed is reduced by a great degree. |
||
| 129 | * |
||
| 130 | * @param string $calendarId |
||
| 131 | * |
||
| 132 | * @return array |
||
| 133 | */ |
||
| 134 | public function getCalendarObjects($calendarId) { |
||
| 135 | $result = $this->gDavBackend->GetObjects($calendarId, static::FILE_EXTENSION, ['types' => static::MESSAGE_CLASSES]); |
||
| 136 | $this->logger->trace("calendarId: %s found %d objects", $calendarId, count($result)); |
||
| 137 | |||
| 138 | return $result; |
||
| 139 | } |
||
| 140 | |||
| 141 | /** |
||
| 142 | * Performs a calendar-query on the contents of this calendar. |
||
| 143 | * |
||
| 144 | * The calendar-query is defined in RFC4791 : CalDAV. Using the |
||
| 145 | * calendar-query it is possible for a client to request a specific set of |
||
| 146 | * object, based on contents of iCalendar properties, date-ranges and |
||
| 147 | * iCalendar component types (VTODO, VEVENT). |
||
| 148 | * |
||
| 149 | * This method should just return a list of (relative) urls that match this |
||
| 150 | * query. |
||
| 151 | * |
||
| 152 | * The list of filters are specified as an array. The exact array is |
||
| 153 | * documented by \Sabre\CalDAV\CalendarQueryParser. |
||
| 154 | * |
||
| 155 | * Note that it is extremely likely that getCalendarObject for every path |
||
| 156 | * returned from this method will be called almost immediately after. You |
||
| 157 | * may want to anticipate this to speed up these requests. |
||
| 158 | * |
||
| 159 | * This method provides a default implementation, which parses *all* the |
||
| 160 | * iCalendar objects in the specified calendar. |
||
| 161 | * |
||
| 162 | * This default may well be good enough for personal use, and calendars |
||
| 163 | * that aren't very large. But if you anticipate high usage, big calendars |
||
| 164 | * or high loads, you are strongly advised to optimize certain paths. |
||
| 165 | * |
||
| 166 | * The best way to do so is override this method and to optimize |
||
| 167 | * specifically for 'common filters'. |
||
| 168 | * |
||
| 169 | * Requests that are extremely common are: |
||
| 170 | * * requests for just VEVENTS |
||
| 171 | * * requests for just VTODO |
||
| 172 | * * requests with a time-range-filter on either VEVENT or VTODO. |
||
| 173 | * |
||
| 174 | * ..and combinations of these requests. It may not be worth it to try to |
||
| 175 | * handle every possible situation and just rely on the (relatively |
||
| 176 | * easy to use) CalendarQueryValidator to handle the rest. |
||
| 177 | * |
||
| 178 | * Note that especially time-range-filters may be difficult to parse. A |
||
| 179 | * time-range filter specified on a VEVENT must for instance also handle |
||
| 180 | * recurrence rules correctly. |
||
| 181 | * A good example of how to interpret all these filters can also simply |
||
| 182 | * be found in \Sabre\CalDAV\CalendarQueryFilter. This class is as correct |
||
| 183 | * as possible, so it gives you a good idea on what type of stuff you need |
||
| 184 | * to think of. |
||
| 185 | * |
||
| 186 | * @param mixed $calendarId |
||
| 187 | * |
||
| 188 | * @return array |
||
| 189 | */ |
||
| 190 | public function calendarQuery($calendarId, array $filters) { |
||
| 191 | $start = $end = null; |
||
| 192 | $types = []; |
||
| 193 | foreach ($filters['comp-filters'] as $filter) { |
||
| 194 | $this->logger->trace("got filter: %s", $filter); |
||
| 195 | |||
| 196 | if ($filter['name'] == 'VEVENT') { |
||
| 197 | $types[] = 'IPM.Appointment'; |
||
| 198 | } |
||
| 199 | elseif ($filter['name'] == 'VTODO') { |
||
| 200 | $types[] = 'IPM.Task'; |
||
| 201 | } |
||
| 202 | |||
| 203 | /* will this work on tasks? */ |
||
| 204 | if (is_array($filter['time-range']) && isset($filter['time-range']['start'], $filter['time-range']['end'])) { |
||
| 205 | $start = $filter['time-range']['start']->getTimestamp(); |
||
| 206 | $end = $filter['time-range']['end']->getTimestamp(); |
||
| 207 | } |
||
| 208 | } |
||
| 209 | |||
| 210 | $objfilters = []; |
||
| 211 | if ($start != null && $end != null) { |
||
| 212 | $objfilters["start"] = $start; |
||
| 213 | $objfilters["end"] = $end; |
||
| 214 | } |
||
| 215 | if (!empty($types)) { |
||
| 216 | $objfilters["types"] = $types; |
||
| 217 | } |
||
| 218 | |||
| 219 | $objects = $this->gDavBackend->GetObjects($calendarId, static::FILE_EXTENSION, $objfilters); |
||
| 220 | $result = []; |
||
| 221 | foreach ($objects as $object) { |
||
| 222 | $result[] = $object['uri']; |
||
| 223 | } |
||
| 224 | |||
| 225 | return $result; |
||
| 226 | } |
||
| 227 | |||
| 228 | /** |
||
| 229 | * Returns information from a single calendar object, based on its object uri. |
||
| 230 | * |
||
| 231 | * The object uri is only the basename, or filename and not a full path. |
||
| 232 | * |
||
| 233 | * The returned array must have the same keys as getCalendarObjects. The |
||
| 234 | * 'calendardata' object is required here though, while it's not required |
||
| 235 | * for getCalendarObjects. |
||
| 236 | * |
||
| 237 | * This method must return null if the object did not exist. |
||
| 238 | * |
||
| 239 | * @param string $calendarId |
||
| 240 | * @param string $objectUri |
||
| 241 | * @param resource $mapifolder optional mapifolder resource, used if available |
||
| 242 | * |
||
| 243 | * @return null|array |
||
| 244 | */ |
||
| 245 | public function getCalendarObject($calendarId, $objectUri, $mapifolder = null) { |
||
| 246 | $this->logger->trace("calendarId: %s - objectUri: %s - mapifolder: %s", $calendarId, $objectUri, $mapifolder); |
||
| 247 | |||
| 248 | if (!$mapifolder) { |
||
| 249 | $mapifolder = $this->gDavBackend->GetMapiFolder($calendarId); |
||
| 250 | } |
||
| 251 | |||
| 252 | $mapimessage = $this->gDavBackend->GetMapiMessageForId($calendarId, $objectUri, $mapifolder, static::FILE_EXTENSION); |
||
| 253 | if (!$mapimessage) { |
||
| 254 | $this->logger->info("Object NOT FOUND"); |
||
| 255 | |||
| 256 | return null; |
||
| 257 | } |
||
| 258 | |||
| 259 | $realId = $this->gDavBackend->GetIdOfMapiMessage($calendarId, $mapimessage); |
||
| 260 | |||
| 261 | // this should be cached or moved to gDavBackend |
||
| 262 | $session = $this->gDavBackend->GetSession(); |
||
| 263 | $ab = $this->gDavBackend->GetAddressBook(); |
||
| 264 | |||
| 265 | $ics = mapi_mapitoical($session, $ab, $mapimessage, []); |
||
| 266 | if (!$ics && mapi_last_hresult()) { |
||
| 267 | $this->logger->error("Error generating ical, error code: 0x%08X", mapi_last_hresult()); |
||
| 268 | $ics = null; |
||
| 269 | } |
||
| 270 | elseif (!$ics) { |
||
| 271 | $this->logger->error("Error generating ical, unknown error"); |
||
| 272 | $ics = null; |
||
| 273 | } |
||
| 274 | $this->logger->trace("ics generated by mapi_mapitoical: %s%s", PHP_EOL, $ics); |
||
| 275 | |||
| 276 | $props = mapi_getprops($mapimessage, [PR_LAST_MODIFICATION_TIME]); |
||
| 277 | |||
| 278 | $r = [ |
||
| 279 | 'id' => $realId, |
||
| 280 | 'uri' => $realId . static::FILE_EXTENSION, |
||
| 281 | 'etag' => '"' . $props[PR_LAST_MODIFICATION_TIME] . '"', |
||
| 282 | 'lastmodified' => $props[PR_LAST_MODIFICATION_TIME], |
||
| 283 | 'calendarid' => $calendarId, |
||
| 284 | 'size' => strlen($ics), |
||
| 285 | 'calendardata' => $ics, |
||
| 286 | ]; |
||
| 287 | $this->logger->trace("returned data id: %s - size: %d - etag: %s", $r['id'], $r['size'], $r['etag']); |
||
| 288 | |||
| 289 | return $r; |
||
| 290 | } |
||
| 291 | |||
| 292 | /** |
||
| 293 | * Creates a new calendar object. |
||
| 294 | * |
||
| 295 | * The object uri is only the basename, or filename and not a full path. |
||
| 296 | * |
||
| 297 | * It is possible return an etag from this function, which will be used in |
||
| 298 | * the response to this PUT request. Note that the ETag must be surrounded |
||
| 299 | * by double-quotes. |
||
| 300 | * |
||
| 301 | * However, you should only really return this ETag if you don't mangle the |
||
| 302 | * calendar-data. If the result of a subsequent GET to this object is not |
||
| 303 | * the exact same as this request body, you should omit the ETag. |
||
| 304 | * |
||
| 305 | * @param mixed $calendarId |
||
| 306 | * @param string $objectUri |
||
| 307 | * @param string $calendarData |
||
| 308 | * |
||
| 309 | * @return null|string |
||
| 310 | */ |
||
| 311 | public function createCalendarObject($calendarId, $objectUri, $calendarData) { |
||
| 312 | $this->logger->trace("calendarId: %s - objectUri: %s - calendarData: %s", $calendarId, $objectUri, $calendarData); |
||
| 313 | $objectId = $this->gDavBackend->GetObjectIdFromObjectUri($objectUri, static::FILE_EXTENSION); |
||
| 314 | $folder = $this->gDavBackend->GetMapiFolder($calendarId); |
||
| 315 | $mapimessage = $this->gDavBackend->CreateObject($calendarId, $folder, $objectId); |
||
| 316 | $retval = $this->setData($calendarId, $mapimessage, $calendarData); |
||
| 317 | if (!$retval) { |
||
| 318 | return null; |
||
| 319 | } |
||
| 320 | |||
| 321 | return '"' . $retval . '"'; |
||
| 322 | } |
||
| 323 | |||
| 324 | /** |
||
| 325 | * Updates an existing calendarobject, based on its uri. |
||
| 326 | * |
||
| 327 | * The object uri is only the basename, or filename and not a full path. |
||
| 328 | * |
||
| 329 | * It is possible return an etag from this function, which will be used in |
||
| 330 | * the response to this PUT request. Note that the ETag must be surrounded |
||
| 331 | * by double-quotes. |
||
| 332 | * |
||
| 333 | * However, you should only really return this ETag if you don't mangle the |
||
| 334 | * calendar-data. If the result of a subsequent GET to this object is not |
||
| 335 | * the exact same as this request body, you should omit the ETag. |
||
| 336 | * |
||
| 337 | * @param mixed $calendarId |
||
| 338 | * @param string $objectUri |
||
| 339 | * @param string $calendarData |
||
| 340 | * |
||
| 341 | * @return null|string |
||
| 342 | */ |
||
| 343 | public function updateCalendarObject($calendarId, $objectUri, $calendarData) { |
||
| 344 | $this->logger->trace("calendarId: %s - objectUri: %s - calendarData: %s", $calendarId, $objectUri, $calendarData); |
||
| 345 | |||
| 346 | $folder = $this->gDavBackend->GetMapiFolder($calendarId); |
||
| 347 | $mapimessage = $this->gDavBackend->GetMapiMessageForId($calendarId, $objectUri, null, static::FILE_EXTENSION); |
||
| 348 | $retval = $this->setData($calendarId, $mapimessage, $calendarData); |
||
| 349 | if (!$retval) { |
||
| 350 | return null; |
||
| 351 | } |
||
| 352 | |||
| 353 | return '"' . $retval . '"'; |
||
| 354 | } |
||
| 355 | |||
| 356 | /** |
||
| 357 | * Sets data for a calendar item. |
||
| 358 | * |
||
| 359 | * @param mixed $calendarId |
||
| 360 | * @param MAPIMessage $mapimessage |
||
| 361 | * @param string $ics |
||
| 362 | * |
||
| 363 | * @return null|string |
||
| 364 | */ |
||
| 365 | private function setData($calendarId, $mapimessage, $ics) { |
||
| 366 | $this->logger->trace("mapimessage: %s - ics: %s", $mapimessage, $ics); |
||
| 367 | // this should be cached or moved to gDavBackend |
||
| 368 | $store = $this->gDavBackend->GetStoreById($calendarId); |
||
| 369 | $session = $this->gDavBackend->GetSession(); |
||
| 370 | $ab = $this->gDavBackend->GetAddressBook(); |
||
| 371 | |||
| 372 | // Evolution sends daylight/standard information in the ical data |
||
| 373 | // and some values are not supported by Outlook/Exchange. |
||
| 374 | // Strip that data and leave only the last occurrences of |
||
| 375 | // daylight/standard information. |
||
| 376 | // @see GRAM-52 |
||
| 377 | |||
| 378 | $xLicLocation = stripos($ics, 'X-LIC-LOCATION:'); |
||
| 379 | if (($xLicLocation !== false) && |
||
| 380 | ( |
||
| 381 | substr_count($ics, 'BEGIN:DAYLIGHT', $xLicLocation) > 0 || |
||
| 382 | substr_count($ics, 'BEGIN:STANDARD', $xLicLocation) > 0 |
||
| 383 | )) { |
||
| 384 | $firstDaytime = stripos($ics, 'BEGIN:DAYLIGHT', $xLicLocation); |
||
| 385 | $firstStandard = stripos($ics, 'BEGIN:STANDARD', $xLicLocation); |
||
| 386 | |||
| 387 | $lastDaytime = strripos($ics, 'BEGIN:DAYLIGHT', $xLicLocation); |
||
| 388 | $lastStandard = strripos($ics, 'BEGIN:STANDARD', $xLicLocation); |
||
| 389 | |||
| 390 | // the first part of ics until the first piece of standard/daytime information |
||
| 391 | $cutStart = $firstDaytime < $firstStandard ? $firstDaytime : $firstStandard; |
||
| 392 | |||
| 393 | if ($lastDaytime > $lastStandard) { |
||
| 394 | // the part of the ics with the last piece of standard/daytime information |
||
| 395 | $cutEnd = $lastDaytime; |
||
| 396 | |||
| 397 | // the positions of the last piece of standard information |
||
| 398 | $cut1 = $lastStandard; |
||
| 399 | $cut2 = strripos($ics, 'END:STANDARD', $lastStandard) + 14; // strlen('END:STANDARD') |
||
| 400 | } |
||
| 401 | else { |
||
| 402 | // the part of the ics with the last piece of standard/daytime information |
||
| 403 | $cutEnd = $lastStandard; |
||
| 404 | |||
| 405 | // the positions of the last piece of daylight information |
||
| 406 | $cut1 = $lastDaytime; |
||
| 407 | $cut2 = strripos($ics, 'END:DAYLIGHT', $lastDaytime) + 14; // strlen('END:DAYLIGHT') |
||
| 408 | } |
||
| 409 | |||
| 410 | $ics = substr($ics, 0, $cutStart) . substr($ics, $cut1, $cut2 - $cut1) . substr($ics, $cutEnd); |
||
| 411 | $this->logger->trace("newics: %s", $ics); |
||
| 412 | } |
||
| 413 | |||
| 414 | $ok = mapi_icaltomapi($session, $store, $ab, $mapimessage, $ics, false); |
||
| 415 | if (!$ok && mapi_last_hresult()) { |
||
| 416 | $this->logger->error("Error updating mapi object, error code: 0x%08X", mapi_last_hresult()); |
||
| 417 | |||
| 418 | return null; |
||
| 419 | } |
||
| 420 | if (!$ok) { |
||
| 421 | $this->logger->error("Error updating mapi object, unknown error"); |
||
| 422 | |||
| 423 | return null; |
||
| 424 | } |
||
| 425 | |||
| 426 | mapi_savechanges($mapimessage); |
||
| 427 | $props = mapi_getprops($mapimessage); |
||
| 428 | |||
| 429 | return $props[PR_LAST_MODIFICATION_TIME]; |
||
| 430 | } |
||
| 431 | |||
| 432 | /** |
||
| 433 | * Deletes an existing calendar object. |
||
| 434 | * |
||
| 435 | * The object uri is only the basename, or filename and not a full path. |
||
| 436 | * |
||
| 437 | * @param string $calendarId |
||
| 438 | * @param string $objectUri |
||
| 439 | */ |
||
| 440 | public function deleteCalendarObject($calendarId, $objectUri) { |
||
| 441 | $this->logger->trace("calendarId: %s - objectUri: %s", $calendarId, $objectUri); |
||
| 442 | |||
| 443 | $mapifolder = $this->gDavBackend->GetMapiFolder($calendarId); |
||
| 444 | |||
| 445 | // to delete we need the PR_ENTRYID of the message |
||
| 446 | // TODO move this part to GrommunioDavBackend |
||
| 447 | $mapimessage = $this->gDavBackend->GetMapiMessageForId($calendarId, $objectUri, $mapifolder, static::FILE_EXTENSION); |
||
| 448 | $props = mapi_getprops($mapimessage, [PR_ENTRYID]); |
||
| 449 | mapi_folder_deletemessages($mapifolder, [$props[PR_ENTRYID]]); |
||
| 450 | } |
||
| 451 | |||
| 452 | /** |
||
| 453 | * Return a single scheduling object. |
||
| 454 | * |
||
| 455 | * TODO: Add implementation. |
||
| 456 | * |
||
| 457 | * @param string $principalUri |
||
| 458 | * @param string $objectUri |
||
| 459 | * |
||
| 460 | * @return array |
||
| 461 | */ |
||
| 462 | public function getSchedulingObject($principalUri, $objectUri) { |
||
| 463 | $this->logger->trace("principalUri: %s - objectUri: %s", $principalUri, $objectUri); |
||
| 464 | |||
| 465 | return []; |
||
| 466 | } |
||
| 467 | |||
| 468 | /** |
||
| 469 | * Returns scheduling objects for the principal URI. |
||
| 470 | * |
||
| 471 | * TODO: Add implementation. |
||
| 472 | * |
||
| 473 | * @param string $principalUri |
||
| 474 | * |
||
| 475 | * @return array |
||
| 476 | */ |
||
| 477 | public function getSchedulingObjects($principalUri) { |
||
| 478 | $this->logger->trace("principalUri: %s", $principalUri); |
||
| 479 | |||
| 480 | return []; |
||
| 481 | } |
||
| 482 | |||
| 483 | /** |
||
| 484 | * Delete scheduling object. |
||
| 485 | * |
||
| 486 | * TODO: Add implementation. |
||
| 487 | * |
||
| 488 | * @param string $principalUri |
||
| 489 | * @param string $objectUri |
||
| 490 | */ |
||
| 491 | public function deleteSchedulingObject($principalUri, $objectUri) { |
||
| 492 | $this->logger->trace("principalUri: %s - objectUri: %s", $principalUri, $objectUri); |
||
| 493 | } |
||
| 494 | |||
| 495 | /** |
||
| 496 | * Create a new scheduling object. |
||
| 497 | * |
||
| 498 | * TODO: Add implementation. |
||
| 499 | * |
||
| 500 | * @param string $principalUri |
||
| 501 | * @param string $objectUri |
||
| 502 | * @param string $objectData |
||
| 503 | */ |
||
| 504 | public function createSchedulingObject($principalUri, $objectUri, $objectData) { |
||
| 505 | $this->logger->trace("principalUri: %s - objectUri: %s - objectData: %s", $principalUri, $objectUri, $objectData); |
||
| 506 | } |
||
| 507 | |||
| 508 | /** |
||
| 509 | * Return CTAG for scheduling inbox. |
||
| 510 | * |
||
| 511 | * TODO: Add implementation. |
||
| 512 | * |
||
| 513 | * @param string $principalUri |
||
| 514 | * |
||
| 515 | * @return string |
||
| 516 | */ |
||
| 517 | public function getSchedulingInboxCtag($principalUri) { |
||
| 521 | } |
||
| 522 | |||
| 523 | /** |
||
| 524 | * The getChanges method returns all the changes that have happened, since |
||
| 525 | * the specified syncToken in the specified calendar. |
||
| 526 | * |
||
| 527 | * This function should return an array, such as the following: |
||
| 528 | * |
||
| 529 | * [ |
||
| 530 | * 'syncToken' => 'The current synctoken', |
||
| 531 | * 'added' => [ |
||
| 532 | * 'new.txt', |
||
| 533 | * ], |
||
| 534 | * 'modified' => [ |
||
| 535 | * 'modified.txt', |
||
| 536 | * ], |
||
| 537 | * 'deleted' => [ |
||
| 538 | * 'foo.php.bak', |
||
| 539 | * 'old.txt' |
||
| 540 | * ] |
||
| 541 | * ); |
||
| 542 | * |
||
| 543 | * The returned syncToken property should reflect the *current* syncToken |
||
| 544 | * of the calendar, as reported in the {http://sabredav.org/ns}sync-token |
||
| 545 | * property This is * needed here too, to ensure the operation is atomic. |
||
| 546 | * |
||
| 547 | * If the $syncToken argument is specified as null, this is an initial |
||
| 548 | * sync, and all members should be reported. |
||
| 549 | * |
||
| 550 | * The modified property is an array of nodenames that have changed since |
||
| 551 | * the last token. |
||
| 552 | * |
||
| 553 | * The deleted property is an array with nodenames, that have been deleted |
||
| 554 | * from collection. |
||
| 555 | * |
||
| 556 | * The $syncLevel argument is basically the 'depth' of the report. If it's |
||
| 557 | * 1, you only have to report changes that happened only directly in |
||
| 558 | * immediate descendants. If it's 2, it should also include changes from |
||
| 559 | * the nodes below the child collections. (grandchildren) |
||
| 560 | * |
||
| 561 | * The $limit argument allows a client to specify how many results should |
||
| 562 | * be returned at most. If the limit is not specified, it should be treated |
||
| 563 | * as infinite. |
||
| 564 | * |
||
| 565 | * If the limit (infinite or not) is higher than you're willing to return, |
||
| 566 | * you should throw a Sabre\DAV\Exception\TooMuchMatches() exception. |
||
| 567 | * |
||
| 568 | * If the syncToken is expired (due to data cleanup) or unknown, you must |
||
| 569 | * return null. |
||
| 570 | * |
||
| 571 | * The limit is 'suggestive'. You are free to ignore it. |
||
| 572 | * |
||
| 573 | * @param string $calendarId |
||
| 574 | * @param string $syncToken |
||
| 575 | * @param int $syncLevel |
||
| 576 | * @param int $limit |
||
| 577 | * |
||
| 578 | * @return array |
||
| 579 | */ |
||
| 580 | public function getChangesForCalendar($calendarId, $syncToken, $syncLevel, $limit = null) { |
||
| 584 | } |
||
| 585 | } |
||
| 586 |