| @@ 78-93 (lines=16) @@ | ||
| 75 | * @param string $identifier |
|
| 76 | * @return mixed |
|
| 77 | */ |
|
| 78 | public function retrieve($userId, $identifier) { |
|
| 79 | $qb = $this->dbConnection->getQueryBuilder(); |
|
| 80 | $qb->select('credentials') |
|
| 81 | ->from(self::DB_TABLE) |
|
| 82 | ->where($qb->expr()->eq('user', $qb->createNamedParameter($userId))) |
|
| 83 | ->andWhere($qb->expr()->eq('identifier', $qb->createNamedParameter($identifier))) |
|
| 84 | ; |
|
| 85 | $result = $qb->execute()->fetch(); |
|
| 86 | ||
| 87 | if (!$result) { |
|
| 88 | return null; |
|
| 89 | } |
|
| 90 | $value = $result['credentials']; |
|
| 91 | ||
| 92 | return json_decode($this->crypto->decrypt($value), true); |
|
| 93 | } |
|
| 94 | ||
| 95 | /** |
|
| 96 | * Delete a set of credentials |
|
| @@ 136-151 (lines=16) @@ | ||
| 133 | * |
|
| 134 | * Checks whether the user is member of a group or not. |
|
| 135 | */ |
|
| 136 | public function inGroup( $uid, $gid ) { |
|
| 137 | $this->fixDI(); |
|
| 138 | ||
| 139 | // check |
|
| 140 | $qb = $this->dbConn->getQueryBuilder(); |
|
| 141 | $cursor = $qb->select('uid') |
|
| 142 | ->from('group_user') |
|
| 143 | ->where($qb->expr()->eq('gid', $qb->createNamedParameter($gid))) |
|
| 144 | ->andWhere($qb->expr()->eq('uid', $qb->createNamedParameter($uid))) |
|
| 145 | ->execute(); |
|
| 146 | ||
| 147 | $result = $cursor->fetch(); |
|
| 148 | $cursor->closeCursor(); |
|
| 149 | ||
| 150 | return $result ? true : false; |
|
| 151 | } |
|
| 152 | ||
| 153 | /** |
|
| 154 | * Add a user to a group |
|
| @@ 209-221 (lines=13) @@ | ||
| 206 | * @param bool $excludeBirthday |
|
| 207 | * @return int |
|
| 208 | */ |
|
| 209 | public function getCalendarsForUserCount($principalUri, $excludeBirthday = true) { |
|
| 210 | $principalUri = $this->convertPrincipal($principalUri, true); |
|
| 211 | $query = $this->db->getQueryBuilder(); |
|
| 212 | $query->select($query->createFunction('COUNT(*)')) |
|
| 213 | ->from('calendars') |
|
| 214 | ->where($query->expr()->eq('principaluri', $query->createNamedParameter($principalUri))); |
|
| 215 | ||
| 216 | if ($excludeBirthday) { |
|
| 217 | $query->andWhere($query->expr()->neq('uri', $query->createNamedParameter(BirthdayService::BIRTHDAY_CALENDAR_URI))); |
|
| 218 | } |
|
| 219 | ||
| 220 | return (int)$query->execute()->fetchColumn(); |
|
| 221 | } |
|
| 222 | ||
| 223 | /** |
|
| 224 | * Returns a list of calendars for a principal. |
|
| @@ 2189-2200 (lines=12) @@ | ||
| 2186 | * @param \OCA\DAV\CalDAV\Calendar $calendar |
|
| 2187 | * @return mixed |
|
| 2188 | */ |
|
| 2189 | public function getPublishStatus($calendar) { |
|
| 2190 | $query = $this->db->getQueryBuilder(); |
|
| 2191 | $result = $query->select('publicuri') |
|
| 2192 | ->from('dav_shares') |
|
| 2193 | ->where($query->expr()->eq('resourceid', $query->createNamedParameter($calendar->getResourceId()))) |
|
| 2194 | ->andWhere($query->expr()->eq('access', $query->createNamedParameter(self::ACCESS_PUBLIC))) |
|
| 2195 | ->execute(); |
|
| 2196 | ||
| 2197 | $row = $result->fetch(); |
|
| 2198 | $result->closeCursor(); |
|
| 2199 | return $row ? reset($row) : false; |
|
| 2200 | } |
|
| 2201 | ||
| 2202 | /** |
|
| 2203 | * @param int $resourceId |
|