| @@ 135-150 (lines=16) @@ | ||
| 132 | * |
|
| 133 | * Checks whether the user is member of a group or not. |
|
| 134 | */ |
|
| 135 | public function inGroup( $uid, $gid ) { |
|
| 136 | $this->fixDI(); |
|
| 137 | ||
| 138 | // check |
|
| 139 | $qb = $this->dbConn->getQueryBuilder(); |
|
| 140 | $cursor = $qb->select('uid') |
|
| 141 | ->from('group_user') |
|
| 142 | ->where($qb->expr()->eq('gid', $qb->createNamedParameter($gid))) |
|
| 143 | ->andWhere($qb->expr()->eq('uid', $qb->createNamedParameter($uid))) |
|
| 144 | ->execute(); |
|
| 145 | ||
| 146 | $result = $cursor->fetch(); |
|
| 147 | $cursor->closeCursor(); |
|
| 148 | ||
| 149 | return $result ? true : false; |
|
| 150 | } |
|
| 151 | ||
| 152 | /** |
|
| 153 | * Add a user to a group |
|
| @@ 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 |
|
| @@ 188-200 (lines=13) @@ | ||
| 185 | * @param bool $excludeBirthday |
|
| 186 | * @return int |
|
| 187 | */ |
|
| 188 | public function getCalendarsForUserCount($principalUri, $excludeBirthday = true) { |
|
| 189 | $principalUri = $this->convertPrincipal($principalUri, true); |
|
| 190 | $query = $this->db->getQueryBuilder(); |
|
| 191 | $query->select($query->createFunction('COUNT(*)')) |
|
| 192 | ->from('calendars') |
|
| 193 | ->where($query->expr()->eq('principaluri', $query->createNamedParameter($principalUri))); |
|
| 194 | ||
| 195 | if ($excludeBirthday) { |
|
| 196 | $query->andWhere($query->expr()->neq('uri', $query->createNamedParameter(BirthdayService::BIRTHDAY_CALENDAR_URI))); |
|
| 197 | } |
|
| 198 | ||
| 199 | return (int)$query->execute()->fetchColumn(); |
|
| 200 | } |
|
| 201 | ||
| 202 | /** |
|
| 203 | * Returns a list of calendars for a principal. |
|
| @@ 1948-1959 (lines=12) @@ | ||
| 1945 | * @param \OCA\DAV\CalDAV\Calendar $calendar |
|
| 1946 | * @return mixed |
|
| 1947 | */ |
|
| 1948 | public function getPublishStatus($calendar) { |
|
| 1949 | $query = $this->db->getQueryBuilder(); |
|
| 1950 | $result = $query->select('publicuri') |
|
| 1951 | ->from('dav_shares') |
|
| 1952 | ->where($query->expr()->eq('resourceid', $query->createNamedParameter($calendar->getResourceId()))) |
|
| 1953 | ->andWhere($query->expr()->eq('access', $query->createNamedParameter(self::ACCESS_PUBLIC))) |
|
| 1954 | ->execute(); |
|
| 1955 | ||
| 1956 | $row = $result->fetch(); |
|
| 1957 | $result->closeCursor(); |
|
| 1958 | return $row ? reset($row) : false; |
|
| 1959 | } |
|
| 1960 | ||
| 1961 | /** |
|
| 1962 | * @param int $resourceId |
|