/** * {@inheritdoc} */ public function getDigestHash($realm, $username) { $where = Where::create('username_canonical = $*', [$username]); $users = $this->manager->findWhere('public', 'users', $where); if ($users->count() == 0) { return null; } return $users->get(0)->password_digesta; }
/** * @param string $path * * @return array */ public function getPrincipalByPath($path) { $where = Where::create('uri = $*', [$path]); $principals = $this->manager->findWhere('public', 'principal', $where); if ($principals->count() == 0) { return []; } $principal = $principals->get(0); $ret = ['id' => $principal->id, 'uri' => $principal->uri]; foreach ($this->fieldMap as $key => $value) { $ret[$key] = $principal->{$value}['dbField']; } return $ret; }
/** * {@inheritdoc} */ public function updateUser(UserInterface $user) { $this->updatePassword($user); if ($user->getId() == null) { $this->createPrincipals($user); $ret = $this->manager->insertOne('public', 'users', $user->jsonSerialize()); $user->setId($ret->id); } else { $where = Where::create('id = $*', [$user->getId()]); $dbUser = $this->manager->findWhere('public', 'users', $where)->get(0); $data = $user->jsonSerialize(); foreach ($data as $name => $value) { $dbUser->{$name} = $value; } $this->manager->updateOne('public', 'users', $dbUser, array_keys($data)); } }
/** * {@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; }