예제 #1
0
 /**
  * {@inheritdoc}
  */
 public function findUsers()
 {
     $users = $this->manager->findAll('public', 'users');
     $ret = [];
     foreach ($users as $user) {
         $ret[] = $this->createFromDatabase($user);
     }
     return $ret;
 }
예제 #2
0
 /**
  * @param string $prefixPath
  *
  * @return array|null
  */
 public function getPrincipalsByPrefix($prefixPath)
 {
     $dbPrincipals = $this->manager->findAll('public', 'principal');
     if ($dbPrincipals->count() == 0) {
         return null;
     }
     $principals = [];
     foreach ($dbPrincipals as $dbPrincipal) {
         // Checking if the principal is in the prefix
         list($rowPrefix, $basename) = Uri\split($dbPrincipal->uri);
         if ($rowPrefix !== $prefixPath) {
             continue;
         }
         $principal = ['uri' => $dbPrincipal->uri];
         foreach ($this->fieldMap as $key => $value) {
             $principal[$key] = $dbPrincipal->{$value}['dbField'];
         }
         $principals[] = $principal;
     }
     return $principals;
 }
예제 #3
0
 /**
  * {@inheritdoc}
  */
 public function getChangesForCalendar($calendarId, $syncToken, $syncLevel, $limit = null)
 {
     // Current synctoken
     $calendar = $this->manager->findById('public', 'calendar', $calendarId);
     $currentToken = $calendar->synctoken;
     if (is_null($currentToken)) {
         return;
     }
     $result = ['syncToken' => $currentToken, 'added' => [], 'modified' => [], 'deleted' => []];
     if ($syncToken) {
         $where = Where::create('synctoken >= $*', [$syncToken])->andWhere('synctoken < $*', [$currentToken])->andWhere('calendarid = $*', [$calendarId]);
         // Fetching all changes
         $calendarChanges = $this->manager->findWhere('public', 'calendarchange', $where, 'ORDER BY synctoken');
         $changes = [];
         // This loop ensures that any duplicates are overwritten, only the
         // last change on a node is relevant.
         foreach ($calendarChanges as $change) {
             $changes[$change->uri] = $change->operation;
         }
         foreach ($changes as $uri => $operation) {
             switch ($operation) {
                 case 1:
                     $result['added'][] = $uri;
                     break;
                 case 2:
                     $result['modified'][] = $uri;
                     break;
                 case 3:
                     $result['deleted'][] = $uri;
                     break;
             }
         }
     } else {
         // No synctoken supplied, this is the initial sync.
         $objects = $this->manager->findAll('public', 'calendarobject');
         foreach ($objects as $object) {
             $result['added'] = $object->uri;
         }
     }
     return $result;
 }