| @@ 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  | 
                                |
| @@ 196-208 (lines=13) @@ | ||
| 193 | * @param bool $excludeBirthday  | 
                                |
| 194 | * @return int  | 
                                |
| 195 | */  | 
                                |
| 196 | 	public function getCalendarsForUserCount($principalUri, $excludeBirthday = true) { | 
                                |
| 197 | $principalUri = $this->convertPrincipal($principalUri, true);  | 
                                |
| 198 | $query = $this->db->getQueryBuilder();  | 
                                |
| 199 | 		$query->select($query->createFunction('COUNT(*)')) | 
                                |
| 200 | 			->from('calendars') | 
                                |
| 201 | 			->where($query->expr()->eq('principaluri', $query->createNamedParameter($principalUri))); | 
                                |
| 202 | ||
| 203 | 		if ($excludeBirthday) { | 
                                |
| 204 | 			$query->andWhere($query->expr()->neq('uri', $query->createNamedParameter(BirthdayService::BIRTHDAY_CALENDAR_URI))); | 
                                |
| 205 | }  | 
                                |
| 206 | ||
| 207 | return (int)$query->execute()->fetchColumn();  | 
                                |
| 208 | }  | 
                                |
| 209 | ||
| 210 | /**  | 
                                |
| 211 | * Returns a list of calendars for a principal.  | 
                                |
| @@ 1981-1992 (lines=12) @@ | ||
| 1978 | * @param \OCA\DAV\CalDAV\Calendar $calendar  | 
                                |
| 1979 | * @return mixed  | 
                                |
| 1980 | */  | 
                                |
| 1981 | 	public function getPublishStatus($calendar) { | 
                                |
| 1982 | $query = $this->db->getQueryBuilder();  | 
                                |
| 1983 | 		$result = $query->select('publicuri') | 
                                |
| 1984 | 			->from('dav_shares') | 
                                |
| 1985 | 			->where($query->expr()->eq('resourceid', $query->createNamedParameter($calendar->getResourceId()))) | 
                                |
| 1986 | 			->andWhere($query->expr()->eq('access', $query->createNamedParameter(self::ACCESS_PUBLIC))) | 
                                |
| 1987 | ->execute();  | 
                                |
| 1988 | ||
| 1989 | $row = $result->fetch();  | 
                                |
| 1990 | $result->closeCursor();  | 
                                |
| 1991 | return $row ? reset($row) : false;  | 
                                |
| 1992 | }  | 
                                |
| 1993 | ||
| 1994 | /**  | 
                                |
| 1995 | * @param int $resourceId  | 
                                |
| @@ 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  | 
                                |