Code Duplication    Length = 12-16 lines in 4 locations

lib/private/Security/CredentialsManager.php 1 location

@@ 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

apps/dav/lib/CalDAV/CalDavBackend.php 2 locations

@@ 207-219 (lines=13) @@
204
	 * @param bool $excludeBirthday
205
	 * @return int
206
	 */
207
	public function getCalendarsForUserCount($principalUri, $excludeBirthday = true) {
208
		$principalUri = $this->convertPrincipal($principalUri, true);
209
		$query = $this->db->getQueryBuilder();
210
		$query->select($query->createFunction('COUNT(*)'))
211
			->from('calendars')
212
			->where($query->expr()->eq('principaluri', $query->createNamedParameter($principalUri)));
213
214
		if ($excludeBirthday) {
215
			$query->andWhere($query->expr()->neq('uri', $query->createNamedParameter(BirthdayService::BIRTHDAY_CALENDAR_URI)));
216
		}
217
218
		return (int)$query->execute()->fetchColumn();
219
	}
220
221
	/**
222
	 * Returns a list of calendars for a principal.
@@ 2187-2198 (lines=12) @@
2184
	 * @param \OCA\DAV\CalDAV\Calendar $calendar
2185
	 * @return mixed
2186
	 */
2187
	public function getPublishStatus($calendar) {
2188
		$query = $this->db->getQueryBuilder();
2189
		$result = $query->select('publicuri')
2190
			->from('dav_shares')
2191
			->where($query->expr()->eq('resourceid', $query->createNamedParameter($calendar->getResourceId())))
2192
			->andWhere($query->expr()->eq('access', $query->createNamedParameter(self::ACCESS_PUBLIC)))
2193
			->execute();
2194
2195
		$row = $result->fetch();
2196
		$result->closeCursor();
2197
		return $row ? reset($row) : false;
2198
	}
2199
2200
	/**
2201
	 * @param int $resourceId

lib/private/Group/Database.php 1 location

@@ 153-168 (lines=16) @@
150
	 *
151
	 * Checks whether the user is member of a group or not.
152
	 */
153
	public function inGroup( $uid, $gid ) {
154
		$this->fixDI();
155
156
		// check
157
		$qb = $this->dbConn->getQueryBuilder();
158
		$cursor = $qb->select('uid')
159
			->from('group_user')
160
			->where($qb->expr()->eq('gid', $qb->createNamedParameter($gid)))
161
			->andWhere($qb->expr()->eq('uid', $qb->createNamedParameter($uid)))
162
			->execute();
163
164
		$result = $cursor->fetch();
165
		$cursor->closeCursor();
166
167
		return $result ? true : false;
168
	}
169
170
	/**
171
	 * Add a user to a group