Code Duplication    Length = 12-16 lines in 4 locations

lib/private/Group/Database.php 1 location

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

lib/private/Security/CredentialsManager.php 1 location

@@ 79-94 (lines=16) @@
76
	 * @param string $identifier
77
	 * @return mixed
78
	 */
79
	public function retrieve($userId, $identifier) {
80
		$qb = $this->dbConnection->getQueryBuilder();
81
		$qb->select('credentials')
82
			->from(self::DB_TABLE)
83
			->where($qb->expr()->eq('user', $qb->createNamedParameter($userId)))
84
			->andWhere($qb->expr()->eq('identifier', $qb->createNamedParameter($identifier)))
85
		;
86
		$result = $qb->execute()->fetch();
87
88
		if (!$result) {
89
			return null;
90
		}
91
		$value = $result['credentials'];
92
93
		return json_decode($this->crypto->decrypt($value), true);
94
	}
95
96
	/**
97
	 * Delete a set of credentials

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

@@ 171-183 (lines=13) @@
168
	 * @param bool $excludeBirthday
169
	 * @return int
170
	 */
171
	public function getCalendarsForUserCount($principalUri, $excludeBirthday = true) {
172
		$principalUri = $this->convertPrincipal($principalUri, true);
173
		$query = $this->db->getQueryBuilder();
174
		$query->select($query->createFunction('COUNT(*)'))
175
			->from('calendars')
176
			->where($query->expr()->eq('principaluri', $query->createNamedParameter($principalUri)));
177
178
		if ($excludeBirthday) {
179
			$query->andWhere($query->expr()->neq('uri', $query->createNamedParameter(BirthdayService::BIRTHDAY_CALENDAR_URI)));
180
		}
181
182
		return (int)$query->execute()->fetchColumn();
183
	}
184
185
	/**
186
	 * Returns a list of calendars for a principal.
@@ 1801-1812 (lines=12) @@
1798
	 * @param \OCA\DAV\CalDAV\Calendar $calendar
1799
	 * @return mixed
1800
	 */
1801
	public function getPublishStatus($calendar) {
1802
		$query = $this->db->getQueryBuilder();
1803
		$result = $query->select('publicuri')
1804
			->from('dav_shares')
1805
			->where($query->expr()->eq('resourceid', $query->createNamedParameter($calendar->getResourceId())))
1806
			->andWhere($query->expr()->eq('access', $query->createNamedParameter(self::ACCESS_PUBLIC)))
1807
			->execute();
1808
1809
		$row = $result->fetch();
1810
		$result->closeCursor();
1811
		return $row ? reset($row) : false;
1812
	}
1813
1814
	/**
1815
	 * @param int $resourceId