getSyncCalendars() public static method

Returns the calendars that should be used for syncing.
public static getSyncCalendars ( boolean $prune = false ) : array
$prune boolean Remove calendar ids from the sync list that no longer exist. The values are pruned *after* the results are passed back to the client to give sync clients a chance to remove their entries.
return array An array of calendar ids
Esempio n. 1
0
File: Api.php Progetto: horde/horde
 /**
  * Method for obtaining all server changes between two timestamps. Basically
  * a wrapper around listBy(), but returns an array containing all adds,
  * edits and deletions. If $ignoreExceptions is true, events representing
  * recurring event exceptions will not be included in the results.
  *
  * @param integer $start             The starting timestamp
  * @param integer $end               The ending timestamp.
  * @param boolean $ignoreExceptions  Do not include exceptions in results.
  * @param boolean $isModSeq          If true, $timestamp and $end are
  *                                   modification sequences and not
  *                                   timestamps. @since 4.1.1
  * @param string|array $calendars    The sources to check. @since 4.2.0
  *
  * @return array  An hash with 'add', 'modify' and 'delete' arrays.
  * @throws Horde_Exception_PermissionDenied
  * @throws Kronolith_Exception
  */
 public function getChanges($start, $end, $ignoreExceptions = true, $isModSeq = false, $calendars = null)
 {
     // Only get the calendar once
     if (is_null($calendars)) {
         $cs = Kronolith::getSyncCalendars();
     } else {
         if (!is_array($calendars)) {
             $calendars = array($calendars);
         }
         $cs = $calendars;
     }
     $changes = array('add' => array(), 'modify' => array(), 'delete' => array());
     foreach ($cs as $c) {
         // New events
         $driver = Kronolith::getDriver(null, $c);
         $driver->synchronize(true);
         $uids = $this->listBy('add', $start, $c, $end, $isModSeq);
         if ($ignoreExceptions) {
             foreach ($uids as $uid) {
                 try {
                     $event = Kronolith::getDriver()->getByUID($uid, array($c));
                 } catch (Exception $e) {
                     continue;
                 }
                 if (empty($event->baseid)) {
                     $changes['add'][] = $uid;
                 }
             }
         } else {
             $changes['add'] = array_keys(array_flip(array_merge($changes['add'], $uids)));
         }
         // Edits
         $uids = $this->listBy('modify', $start, $c, $end, $isModSeq);
         if ($ignoreExceptions) {
             foreach ($uids as $uid) {
                 try {
                     $event = Kronolith::getDriver()->getByUID($uid, array($c));
                 } catch (Exception $e) {
                     continue;
                 }
                 if (empty($event->baseid)) {
                     $changes['modify'][] = $uid;
                 }
             }
         } else {
             $changes['modify'] = array_keys(array_flip(array_merge($changes['modify'], $uids)));
         }
         // No way to figure out if this was an exception, so we must include all
         $changes['delete'] = array_keys(array_flip(array_merge($changes['delete'], $this->listBy('delete', $start, $c, $end, $isModSeq))));
     }
     return $changes;
 }