Exemplo n.º 1
0
 /**
  * {@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;
 }
Exemplo n.º 2
0
 /**
  * @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;
 }
Exemplo n.º 3
0
 /**
  * @param $calendarId
  * @param $objectUri
  * @param $operation
  */
 protected function addChange($calendarId, $objectUri, $operation)
 {
     $calendar = $this->manager->findById('public', 'calendar', $calendarId);
     $change = ['uri' => $objectUri, 'synctoken' => $calendar->synctoken, 'calendarid' => $calendarId, 'operation' => $operation];
     $this->manager->insertOne('public', 'calendarchange', $change);
     $sql = 'UPDATE calendar SET synctoken = synctoken + 1 WHERE uid = ' . $calendarId;
     $this->manager->query($sql);
 }
Exemplo n.º 4
0
 /**
  * {@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));
     }
 }