Code Duplication    Length = 8-15 lines in 6 locations

lib/private/Files/Type/Loader.php 1 location

@@ 161-172 (lines=12) @@
158
	 * @param int $mimetypeId
159
	 * @return int number of changed rows
160
	 */
161
	public function updateFilecache($ext, $mimetypeId) {
162
		$update = $this->dbConnection->getQueryBuilder();
163
		$update->update('filecache')
164
			->set('mimetype', $update->createNamedParameter($mimetypeId))
165
			->where($update->expr()->neq(
166
				'mimetype', $update->createNamedParameter($mimetypeId)
167
			))
168
			->andWhere($update->expr()->like(
169
				$update->createFunction('LOWER(`name`)'), $update->createNamedParameter($ext)
170
			));
171
		return $update->execute();
172
	}
173
174
}
175

lib/private/Repair/RemoveOldShares.php 2 locations

@@ 69-83 (lines=15) @@
66
	/**
67
	 * @param IOutput $output
68
	 */
69
	private function removeCalendarShares(IOutput $output) {
70
		$qb = $this->connection->getQueryBuilder();
71
		$qb->delete('share')
72
			->where($qb->expr()->eq('item_type', $qb->createNamedParameter('calendar')));
73
		$qb->execute();
74
75
		$output->advance();
76
77
		$qb = $this->connection->getQueryBuilder();
78
		$qb->delete('share')
79
			->where($qb->expr()->eq('item_type', $qb->createNamedParameter('event')));
80
		$qb->execute();
81
82
		$output->advance();
83
	}
84
85
	/**
86
	 * @param IOutput $output
@@ 88-102 (lines=15) @@
85
	/**
86
	 * @param IOutput $output
87
	 */
88
	private function removeContactShares(IOutput $output) {
89
		$qb = $this->connection->getQueryBuilder();
90
		$qb->delete('share')
91
			->where($qb->expr()->eq('item_type', $qb->createNamedParameter('contact')));
92
		$qb->execute();
93
94
		$output->advance();
95
96
		$qb = $this->connection->getQueryBuilder();
97
		$qb->delete('share')
98
			->where($qb->expr()->eq('item_type', $qb->createNamedParameter('addressbook')));
99
		$qb->execute();
100
101
		$output->advance();
102
	}
103
}
104
105

apps/sharebymail/lib/ShareByMailProvider.php 1 location

@@ 368-381 (lines=14) @@
365
	 * @param IShare $share
366
	 * @return IShare The share object
367
	 */
368
	public function update(IShare $share) {
369
		/*
370
		 * We allow updating the permissions of mail shares
371
		 */
372
		$qb = $this->dbConnection->getQueryBuilder();
373
			$qb->update('share')
374
				->where($qb->expr()->eq('id', $qb->createNamedParameter($share->getId())))
375
				->set('permissions', $qb->createNamedParameter($share->getPermissions()))
376
				->set('uid_owner', $qb->createNamedParameter($share->getShareOwner()))
377
				->set('uid_initiator', $qb->createNamedParameter($share->getSharedBy()))
378
				->execute();
379
380
		return $share;
381
	}
382
383
	/**
384
	 * @inheritdoc

lib/private/Share20/DefaultShareProvider.php 1 location

@@ 301-315 (lines=15) @@
298
	 *
299
	 * @param \OCP\Share\IShare $share
300
	 */
301
	public function delete(\OCP\Share\IShare $share) {
302
		$qb = $this->dbConn->getQueryBuilder();
303
		$qb->delete('share')
304
			->where($qb->expr()->eq('id', $qb->createNamedParameter($share->getId())));
305
306
		/*
307
		 * If the share is a group share delete all possible
308
		 * user defined groups shares.
309
		 */
310
		if ($share->getShareType() === \OCP\Share::SHARE_TYPE_GROUP) {
311
			$qb->orWhere($qb->expr()->eq('parent', $qb->createNamedParameter($share->getId())));
312
		}
313
314
		$qb->execute();
315
	}
316
317
	/**
318
	 * Unshare a share from the recipient. If this is a group share

lib/private/Files/Config/UserMountCache.php 1 location

@@ 185-192 (lines=8) @@
182
		$query->execute();
183
	}
184
185
	private function removeFromCache(ICachedMountInfo $mount) {
186
		$builder = $this->connection->getQueryBuilder();
187
188
		$query = $builder->delete('mounts')
189
			->where($builder->expr()->eq('user_id', $builder->createNamedParameter($mount->getUser()->getUID())))
190
			->andWhere($builder->expr()->eq('root_id', $builder->createNamedParameter($mount->getRootId(), IQueryBuilder::PARAM_INT)));
191
		$query->execute();
192
	}
193
194
	private function dbRowToMountInfo(array $row) {
195
		$user = $this->userManager->get($row['user_id']);