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

lib/private/Group/Database.php 1 location

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

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

@@ 200-212 (lines=13) @@
197
	 * @param bool $excludeBirthday
198
	 * @return int
199
	 */
200
	public function getCalendarsForUserCount($principalUri, $excludeBirthday = true) {
201
		$principalUri = $this->convertPrincipal($principalUri, true);
202
		$query = $this->db->getQueryBuilder();
203
		$query->select($query->createFunction('COUNT(*)'))
204
			->from('calendars')
205
			->where($query->expr()->eq('principaluri', $query->createNamedParameter($principalUri)));
206
207
		if ($excludeBirthday) {
208
			$query->andWhere($query->expr()->neq('uri', $query->createNamedParameter(BirthdayService::BIRTHDAY_CALENDAR_URI)));
209
		}
210
211
		return (int)$query->execute()->fetchColumn();
212
	}
213
214
	/**
215
	 * Returns a list of calendars for a principal.
@@ 2152-2163 (lines=12) @@
2149
	 * @param \OCA\DAV\CalDAV\Calendar $calendar
2150
	 * @return mixed
2151
	 */
2152
	public function getPublishStatus($calendar) {
2153
		$query = $this->db->getQueryBuilder();
2154
		$result = $query->select('publicuri')
2155
			->from('dav_shares')
2156
			->where($query->expr()->eq('resourceid', $query->createNamedParameter($calendar->getResourceId())))
2157
			->andWhere($query->expr()->eq('access', $query->createNamedParameter(self::ACCESS_PUBLIC)))
2158
			->execute();
2159
2160
		$row = $result->fetch();
2161
		$result->closeCursor();
2162
		return $row ? reset($row) : false;
2163
	}
2164
2165
	/**
2166
	 * @param int $resourceId