Completed
Pull Request — master (#4042)
by Lukas
56:50 queued 45:38
created
lib/private/Share/Share.php 1 patch
Spacing   +76 added lines, -76 removed lines patch added patch discarded remove patch
@@ -92,7 +92,7 @@  discard block
 block discarded – undo
92 92
 					'collectionOf' => $collectionOf,
93 93
 					'supportedFileExtensions' => $supportedFileExtensions
94 94
 				);
95
-				if(count(self::$backendTypes) === 1) {
95
+				if (count(self::$backendTypes) === 1) {
96 96
 					Util::addScript('core', 'merged-share-backend');
97 97
 					\OC_Util::addStyle('core', 'share');
98 98
 				}
@@ -164,22 +164,22 @@  discard block
 block discarded – undo
164 164
 		$source = -1;
165 165
 		$cache = $mountPath = false;
166 166
 
167
-		$view = new \OC\Files\View('/' . $ownerUser . '/files');
167
+		$view = new \OC\Files\View('/'.$ownerUser.'/files');
168 168
 		$meta = $view->getFileInfo($path);
169 169
 		if ($meta) {
170
-			$path = substr($meta->getPath(), strlen('/' . $ownerUser . '/files'));
170
+			$path = substr($meta->getPath(), strlen('/'.$ownerUser.'/files'));
171 171
 		} else {
172 172
 			// if the file doesn't exists yet we start with the parent folder
173 173
 			$meta = $view->getFileInfo(dirname($path));
174 174
 		}
175 175
 
176
-		if($meta !== false) {
176
+		if ($meta !== false) {
177 177
 			$source = $meta['fileid'];
178 178
 			$cache = new \OC\Files\Cache\Cache($meta['storage']);
179 179
 
180 180
 			$mountPath = $meta->getMountPoint()->getMountPoint();
181 181
 			if ($mountPath !== false) {
182
-				$mountPath = substr($mountPath, strlen('/' . $ownerUser . '/files'));
182
+				$mountPath = substr($mountPath, strlen('/'.$ownerUser.'/files'));
183 183
 			}
184 184
 		}
185 185
 
@@ -297,10 +297,10 @@  discard block
 block discarded – undo
297 297
 			}
298 298
 
299 299
 			// let's get the parent for the next round
300
-			$meta = $cache->get((int)$source);
300
+			$meta = $cache->get((int) $source);
301 301
 			if ($recursive === true && $meta !== false) {
302 302
 				$paths[$source] = $meta['path'];
303
-				$source = (int)$meta['parent'];
303
+				$source = (int) $meta['parent'];
304 304
 			} else {
305 305
 				$source = -1;
306 306
 			}
@@ -319,7 +319,7 @@  discard block
 block discarded – undo
319 319
 				$query = \OC_DB::prepare(
320 320
 					'SELECT `fileid`, `path`
321 321
 					FROM `*PREFIX*filecache`
322
-					WHERE `fileid` IN (' . implode(',', $fileTargetIDs) . ')'
322
+					WHERE `fileid` IN (' . implode(',', $fileTargetIDs).')'
323 323
 				);
324 324
 				$result = $query->execute();
325 325
 
@@ -334,7 +334,7 @@  discard block
 block discarded – undo
334 334
 								$sharePaths[$uid] = $sharedPath;
335 335
 							} else {
336 336
 								$sharedPath = $shareData['file_target'];
337
-								$sharedPath .= substr($path, strlen($row['path']) -5);
337
+								$sharedPath .= substr($path, strlen($row['path']) - 5);
338 338
 								$sharePaths[$uid] = $sharedPath;
339 339
 							}
340 340
 						}
@@ -426,7 +426,7 @@  discard block
 block discarded – undo
426 426
 
427 427
 		$select = self::createSelectStatement(self::FORMAT_NONE, $fileDependent);
428 428
 
429
-		$where .= ' `' . $column . '` = ? AND `item_type` = ? ';
429
+		$where .= ' `'.$column.'` = ? AND `item_type` = ? ';
430 430
 		$arguments = array($itemSource, $itemType);
431 431
 		// for link shares $user === null
432 432
 		if ($user !== null) {
@@ -444,7 +444,7 @@  discard block
 block discarded – undo
444 444
 			$arguments[] = $owner;
445 445
 		}
446 446
 
447
-		$query = \OC_DB::prepare('SELECT ' . $select . ' FROM `*PREFIX*share` '. $fileDependentWhere . $where);
447
+		$query = \OC_DB::prepare('SELECT '.$select.' FROM `*PREFIX*share` '.$fileDependentWhere.$where);
448 448
 
449 449
 		$result = \OC_DB::executeAudited($query, $arguments);
450 450
 
@@ -452,7 +452,7 @@  discard block
 block discarded – undo
452 452
 			if ($fileDependent && !self::isFileReachable($row['path'], $row['storage_id'])) {
453 453
 				continue;
454 454
 			}
455
-			if ($fileDependent && (int)$row['file_parent'] === -1) {
455
+			if ($fileDependent && (int) $row['file_parent'] === -1) {
456 456
 				// if it is a mount point we need to get the path from the mount manager
457 457
 				$mountManager = \OC\Files\Filesystem::getMountManager();
458 458
 				$mountPoint = $mountManager->findByStorageId($row['storage_id']);
@@ -463,7 +463,7 @@  discard block
 block discarded – undo
463 463
 					$row['path'] = $path;
464 464
 				} else {
465 465
 					\OC::$server->getLogger()->warning(
466
-						'Could not resolve mount point for ' . $row['storage_id'],
466
+						'Could not resolve mount point for '.$row['storage_id'],
467 467
 						['app' => 'OCP\Share']
468 468
 					);
469 469
 				}
@@ -472,7 +472,7 @@  discard block
 block discarded – undo
472 472
 		}
473 473
 
474 474
 		//if didn't found a result than let's look for a group share.
475
-		if(empty($shares) && $user !== null) {
475
+		if (empty($shares) && $user !== null) {
476 476
 			$userObject = \OC::$server->getUserManager()->get($user);
477 477
 			$groups = [];
478 478
 			if ($userObject) {
@@ -480,7 +480,7 @@  discard block
 block discarded – undo
480 480
 			}
481 481
 
482 482
 			if (!empty($groups)) {
483
-				$where = $fileDependentWhere . ' WHERE `' . $column . '` = ? AND `item_type` = ? AND `share_with` in (?)';
483
+				$where = $fileDependentWhere.' WHERE `'.$column.'` = ? AND `item_type` = ? AND `share_with` in (?)';
484 484
 				$arguments = array($itemSource, $itemType, $groups);
485 485
 				$types = array(null, null, IQueryBuilder::PARAM_STR_ARRAY);
486 486
 
@@ -494,7 +494,7 @@  discard block
 block discarded – undo
494 494
 				// class isn't static anymore...
495 495
 				$conn = \OC::$server->getDatabaseConnection();
496 496
 				$result = $conn->executeQuery(
497
-					'SELECT ' . $select . ' FROM `*PREFIX*share` ' . $where,
497
+					'SELECT '.$select.' FROM `*PREFIX*share` '.$where,
498 498
 					$arguments,
499 499
 					$types
500 500
 				);
@@ -548,7 +548,7 @@  discard block
 block discarded – undo
548 548
 		$query = \OC_DB::prepare('SELECT * FROM `*PREFIX*share` WHERE `token` = ?', 1);
549 549
 		$result = $query->execute(array($token));
550 550
 		if ($result === false) {
551
-			\OCP\Util::writeLog('OCP\Share', \OC_DB::getErrorMessage() . ', token=' . $token, \OCP\Util::ERROR);
551
+			\OCP\Util::writeLog('OCP\Share', \OC_DB::getErrorMessage().', token='.$token, \OCP\Util::ERROR);
552 552
 		}
553 553
 		$row = $result->fetchRow();
554 554
 		if ($row === false) {
@@ -634,9 +634,9 @@  discard block
 block discarded – undo
634 634
 		$items = self::getItems($itemType, $itemSource, null, null, $uidOwner, self::FORMAT_NONE, null, -1, $includeCollections, false, $checkExpireDate);
635 635
 		if ($items) {
636 636
 			foreach ($items as $item) {
637
-				if ((int)$item['share_type'] === self::SHARE_TYPE_USER) {
637
+				if ((int) $item['share_type'] === self::SHARE_TYPE_USER) {
638 638
 					$users[] = $item['share_with'];
639
-				} else if ((int)$item['share_type'] === self::SHARE_TYPE_GROUP) {
639
+				} else if ((int) $item['share_type'] === self::SHARE_TYPE_GROUP) {
640 640
 
641 641
 					$group = \OC::$server->getGroupManager()->get($item['share_with']);
642 642
 					$userIds = [];
@@ -712,12 +712,12 @@  discard block
 block discarded – undo
712 712
 
713 713
 		//verify that we don't share a folder which already contains a share mount point
714 714
 		if ($itemType === 'folder') {
715
-			$path = '/' . $uidOwner . '/files' . \OC\Files\Filesystem::getPath($itemSource) . '/';
715
+			$path = '/'.$uidOwner.'/files'.\OC\Files\Filesystem::getPath($itemSource).'/';
716 716
 			$mountManager = \OC\Files\Filesystem::getMountManager();
717 717
 			$mounts = $mountManager->findIn($path);
718 718
 			foreach ($mounts as $mount) {
719 719
 				if ($mount->getStorage()->instanceOfStorage('\OCA\Files_Sharing\ISharedStorage')) {
720
-					$message = 'Sharing "' . $itemSourceName . '" failed, because it contains files shared with you!';
720
+					$message = 'Sharing "'.$itemSourceName.'" failed, because it contains files shared with you!';
721 721
 					\OCP\Util::writeLog('OCP\Share', $message, \OCP\Util::DEBUG);
722 722
 					throw new \Exception($message);
723 723
 				}
@@ -727,7 +727,7 @@  discard block
 block discarded – undo
727 727
 
728 728
 		// single file shares should never have delete permissions
729 729
 		if ($itemType === 'file') {
730
-			$permissions = (int)$permissions & ~\OCP\Constants::PERMISSION_DELETE;
730
+			$permissions = (int) $permissions & ~\OCP\Constants::PERMISSION_DELETE;
731 731
 		}
732 732
 
733 733
 		//Validate expirationDate
@@ -881,7 +881,7 @@  discard block
 block discarded – undo
881 881
 					} else {
882 882
 						// reuse the already set password, but only if we change permissions
883 883
 						// otherwise the user disabled the password protection
884
-						if ($checkExists && (int)$permissions !== (int)$oldPermissions) {
884
+						if ($checkExists && (int) $permissions !== (int) $oldPermissions) {
885 885
 							$shareWith = $checkExists['share_with'];
886 886
 						}
887 887
 					}
@@ -954,10 +954,10 @@  discard block
 block discarded – undo
954 954
 				throw new \Exception($message_t);
955 955
 			}
956 956
 
957
-			$token = \OC::$server->getSecureRandom()->generate(self::TOKEN_LENGTH, \OCP\Security\ISecureRandom::CHAR_LOWER . \OCP\Security\ISecureRandom::CHAR_UPPER .
957
+			$token = \OC::$server->getSecureRandom()->generate(self::TOKEN_LENGTH, \OCP\Security\ISecureRandom::CHAR_LOWER.\OCP\Security\ISecureRandom::CHAR_UPPER.
958 958
 				\OCP\Security\ISecureRandom::CHAR_DIGITS);
959 959
 
960
-			$shareWith = $user . '@' . $remote;
960
+			$shareWith = $user.'@'.$remote;
961 961
 			$shareId = self::put($itemType, $itemSource, $shareType, $shareWith, $uidOwner, $permissions, null, $token, $itemSourceName);
962 962
 
963 963
 			$send = false;
@@ -1008,12 +1008,12 @@  discard block
 block discarded – undo
1008 1008
 		$currentUser = $owner ? $owner : \OC_User::getUser();
1009 1009
 		foreach ($items as $item) {
1010 1010
 			// delete the item with the expected share_type and owner
1011
-			if ((int)$item['share_type'] === (int)$shareType && $item['uid_owner'] === $currentUser) {
1011
+			if ((int) $item['share_type'] === (int) $shareType && $item['uid_owner'] === $currentUser) {
1012 1012
 				$toDelete = $item;
1013 1013
 				// if there is more then one result we don't have to delete the children
1014 1014
 				// but update their parent. For group shares the new parent should always be
1015 1015
 				// the original group share and not the db entry with the unique name
1016
-			} else if ((int)$item['share_type'] === self::$shareTypeGroupUserUnique) {
1016
+			} else if ((int) $item['share_type'] === self::$shareTypeGroupUserUnique) {
1017 1017
 				$newParent = $item['parent'];
1018 1018
 			} else {
1019 1019
 				$newParent = $item['id'];
@@ -1035,7 +1035,7 @@  discard block
 block discarded – undo
1035 1035
 	 */
1036 1036
 	public static function unshareAll($itemType, $itemSource) {
1037 1037
 		// Get all of the owners of shares of this item.
1038
-		$query = \OC_DB::prepare( 'SELECT `uid_owner` from `*PREFIX*share` WHERE `item_type`=? AND `item_source`=?' );
1038
+		$query = \OC_DB::prepare('SELECT `uid_owner` from `*PREFIX*share` WHERE `item_type`=? AND `item_source`=?');
1039 1039
 		$result = $query->execute(array($itemType, $itemSource));
1040 1040
 		$shares = array();
1041 1041
 		// Add each owner's shares to the array of all shares for this item.
@@ -1073,9 +1073,9 @@  discard block
 block discarded – undo
1073 1073
 		$uid = \OCP\User::getUser();
1074 1074
 
1075 1075
 		if ($itemType === 'file' || $itemType === 'folder') {
1076
-			$statement = 'SELECT * FROM `*PREFIX*share` WHERE `item_type` = ? and `file_' . $originType . '` = ?';
1076
+			$statement = 'SELECT * FROM `*PREFIX*share` WHERE `item_type` = ? and `file_'.$originType.'` = ?';
1077 1077
 		} else {
1078
-			$statement = 'SELECT * FROM `*PREFIX*share` WHERE `item_type` = ? and `item_' . $originType . '` = ?';
1078
+			$statement = 'SELECT * FROM `*PREFIX*share` WHERE `item_type` = ? and `item_'.$originType.'` = ?';
1079 1079
 		}
1080 1080
 
1081 1081
 		$query = \OCP\DB::prepare($statement);
@@ -1087,7 +1087,7 @@  discard block
 block discarded – undo
1087 1087
 
1088 1088
 		$itemUnshared = false;
1089 1089
 		foreach ($shares as $share) {
1090
-			if ((int)$share['share_type'] === \OCP\Share::SHARE_TYPE_USER &&
1090
+			if ((int) $share['share_type'] === \OCP\Share::SHARE_TYPE_USER &&
1091 1091
 				$share['share_with'] === $uid) {
1092 1092
 				$deletedShares = Helper::delete($share['id']);
1093 1093
 				$shareTmp = array(
@@ -1095,7 +1095,7 @@  discard block
 block discarded – undo
1095 1095
 					'shareWith' => $share['share_with'],
1096 1096
 					'itemTarget' => $share['item_target'],
1097 1097
 					'itemType' => $share['item_type'],
1098
-					'shareType' => (int)$share['share_type'],
1098
+					'shareType' => (int) $share['share_type'],
1099 1099
 				);
1100 1100
 				if (isset($share['file_target'])) {
1101 1101
 					$shareTmp['fileTarget'] = $share['file_target'];
@@ -1103,13 +1103,13 @@  discard block
 block discarded – undo
1103 1103
 				$listOfUnsharedItems = array_merge($listOfUnsharedItems, $deletedShares, array($shareTmp));
1104 1104
 				$itemUnshared = true;
1105 1105
 				break;
1106
-			} elseif ((int)$share['share_type'] === \OCP\Share::SHARE_TYPE_GROUP) {
1106
+			} elseif ((int) $share['share_type'] === \OCP\Share::SHARE_TYPE_GROUP) {
1107 1107
 				$group = \OC::$server->getGroupManager()->get($share['share_with']);
1108 1108
 				$user = \OC::$server->getUserManager()->get($uid);
1109 1109
 				if ($group && $user && $group->inGroup($user)) {
1110 1110
 					$groupShare = $share;
1111 1111
 				}
1112
-			} elseif ((int)$share['share_type'] === self::$shareTypeGroupUserUnique &&
1112
+			} elseif ((int) $share['share_type'] === self::$shareTypeGroupUserUnique &&
1113 1113
 				$share['share_with'] === $uid) {
1114 1114
 				$uniqueGroupShare = $share;
1115 1115
 			}
@@ -1129,7 +1129,7 @@  discard block
 block discarded – undo
1129 1129
 				'shareWith' => $groupShare['share_with'],
1130 1130
 				'itemTarget' => $groupShare['item_target'],
1131 1131
 				'itemType' => $groupShare['item_type'],
1132
-				'shareType' => (int)$groupShare['share_type'],
1132
+				'shareType' => (int) $groupShare['share_type'],
1133 1133
 			);
1134 1134
 			if (isset($groupShare['file_target'])) {
1135 1135
 				$shareTmp['fileTarget'] = $groupShare['file_target'];
@@ -1144,7 +1144,7 @@  discard block
 block discarded – undo
1144 1144
 				'shareWith' => $uniqueGroupShare['share_with'],
1145 1145
 				'itemTarget' => $uniqueGroupShare['item_target'],
1146 1146
 				'itemType' => $uniqueGroupShare['item_type'],
1147
-				'shareType' => (int)$uniqueGroupShare['share_type'],
1147
+				'shareType' => (int) $uniqueGroupShare['share_type'],
1148 1148
 			);
1149 1149
 			if (isset($uniqueGroupShare['file_target'])) {
1150 1150
 				$shareTmp['fileTarget'] = $uniqueGroupShare['file_target'];
@@ -1179,7 +1179,7 @@  discard block
 block discarded – undo
1179 1179
 
1180 1180
 		$result = $query->execute(array($status, $itemType, $itemSource, $shareType, $recipient));
1181 1181
 
1182
-		if($result === false) {
1182
+		if ($result === false) {
1183 1183
 			\OCP\Util::writeLog('OCP\Share', 'Couldn\'t set send mail status', \OCP\Util::ERROR);
1184 1184
 		}
1185 1185
 	}
@@ -1200,12 +1200,12 @@  discard block
 block discarded – undo
1200 1200
 
1201 1201
 		$intArrayToLiteralArray = function($intArray, $eb) {
1202 1202
 			return array_map(function($int) use ($eb) {
1203
-				return $eb->literal((int)$int, 'integer');
1203
+				return $eb->literal((int) $int, 'integer');
1204 1204
 			}, $intArray);
1205 1205
 		};
1206 1206
 		$sanitizeItem = function($item) {
1207
-			$item['id'] = (int)$item['id'];
1208
-			$item['premissions'] = (int)$item['permissions'];
1207
+			$item['id'] = (int) $item['id'];
1208
+			$item['premissions'] = (int) $item['permissions'];
1209 1209
 			return $item;
1210 1210
 		};
1211 1211
 
@@ -1223,7 +1223,7 @@  discard block
 block discarded – undo
1223 1223
 
1224 1224
 				$result = $dbresult->fetch();
1225 1225
 				$dbresult->closeCursor();
1226
-				if (~(int)$result['permissions'] & $permissions) {
1226
+				if (~(int) $result['permissions'] & $permissions) {
1227 1227
 					$message = 'Setting permissions for %s failed,'
1228 1228
 						.' because the permissions exceed permissions granted to %s';
1229 1229
 					$message_t = $l->t('Setting permissions for %s failed, because the permissions exceed permissions granted to %s', array($itemSource, \OC_User::getUser()));
@@ -1256,7 +1256,7 @@  discard block
 block discarded – undo
1256 1256
 			$items = [];
1257 1257
 
1258 1258
 			// Check if permissions were removed
1259
-			if ((int)$rootItem['permissions'] & ~$permissions) {
1259
+			if ((int) $rootItem['permissions'] & ~$permissions) {
1260 1260
 				// If share permission is removed all reshares must be deleted
1261 1261
 				if (($rootItem['permissions'] & \OCP\Constants::PERMISSION_SHARE) && (~$permissions & \OCP\Constants::PERMISSION_SHARE)) {
1262 1262
 					// delete all shares, keep parent and group children
@@ -1309,14 +1309,14 @@  discard block
 block discarded – undo
1309 1309
 			 * Permissions were added
1310 1310
 			 * Update all USERGROUP shares. (So group shares where the user moved their mountpoint).
1311 1311
 			 */
1312
-			if ($permissions & ~(int)$rootItem['permissions']) {
1312
+			if ($permissions & ~(int) $rootItem['permissions']) {
1313 1313
 				$qb = $connection->getQueryBuilder();
1314 1314
 				$qb->select('id', 'permissions', 'item_type')
1315 1315
 					->from('share')
1316 1316
 					->where($qb->expr()->eq('parent', $qb->createParameter('parent')))
1317 1317
 					->andWhere($qb->expr()->eq('share_type', $qb->createParameter('share_type')))
1318 1318
 					->andWhere($qb->expr()->neq('permissions', $qb->createParameter('shareDeleted')))
1319
-					->setParameter(':parent', (int)$rootItem['id'])
1319
+					->setParameter(':parent', (int) $rootItem['id'])
1320 1320
 					->setParameter(':share_type', 2)
1321 1321
 					->setParameter(':shareDeleted', 0);
1322 1322
 				$result = $qb->execute();
@@ -1376,7 +1376,7 @@  discard block
 block discarded – undo
1376 1376
 		if ($defaultExpireDateEnforced && $shareTime === null) {
1377 1377
 			$items = self::getItemShared($itemType, $itemSource);
1378 1378
 			$firstItem = reset($items);
1379
-			$shareTime = (int)$firstItem['stime'];
1379
+			$shareTime = (int) $firstItem['stime'];
1380 1380
 		}
1381 1381
 
1382 1382
 		if ($defaultExpireDateEnforced) {
@@ -1384,9 +1384,9 @@  discard block
 block discarded – undo
1384 1384
 			$maxDate = new \DateTime();
1385 1385
 			$maxDate->setTimestamp($shareTime);
1386 1386
 			$maxDays = \OCP\Config::getAppValue('core', 'shareapi_expire_after_n_days', '7');
1387
-			$maxDate->add(new \DateInterval('P' . $maxDays . 'D'));
1387
+			$maxDate->add(new \DateInterval('P'.$maxDays.'D'));
1388 1388
 			if ($date > $maxDate) {
1389
-				$warning = 'Cannot set expiration date. Shares cannot expire later than ' . $maxDays . ' after they have been shared';
1389
+				$warning = 'Cannot set expiration date. Shares cannot expire later than '.$maxDays.' after they have been shared';
1390 1390
 				$warning_t = $l->t('Cannot set expiration date. Shares cannot expire later than %s after they have been shared', array($maxDays));
1391 1391
 				\OCP\Util::writeLog('OCP\Share', $warning, \OCP\Util::WARN);
1392 1392
 				throw new \Exception($warning_t);
@@ -1566,7 +1566,7 @@  discard block
 block discarded – undo
1566 1566
 	 */
1567 1567
 	protected static function unshareItem(array $item, $newParent = null) {
1568 1568
 
1569
-		$shareType = (int)$item['share_type'];
1569
+		$shareType = (int) $item['share_type'];
1570 1570
 		$shareWith = null;
1571 1571
 		if ($shareType !== \OCP\Share::SHARE_TYPE_LINK) {
1572 1572
 			$shareWith = $item['share_with'];
@@ -1582,7 +1582,7 @@  discard block
 block discarded – undo
1582 1582
 			'itemParent'    => $item['parent'],
1583 1583
 			'uidOwner'      => $item['uid_owner'],
1584 1584
 		);
1585
-		if($item['item_type'] === 'file' || $item['item_type'] === 'folder') {
1585
+		if ($item['item_type'] === 'file' || $item['item_type'] === 'folder') {
1586 1586
 			$hookParams['fileSource'] = $item['file_source'];
1587 1587
 			$hookParams['fileTarget'] = $item['file_target'];
1588 1588
 		}
@@ -1592,7 +1592,7 @@  discard block
 block discarded – undo
1592 1592
 		$deletedShares[] = $hookParams;
1593 1593
 		$hookParams['deletedShares'] = $deletedShares;
1594 1594
 		\OC_Hook::emit('OCP\Share', 'post_unshare', $hookParams);
1595
-		if ((int)$item['share_type'] === \OCP\Share::SHARE_TYPE_REMOTE && \OC::$server->getUserSession()->getUser()) {
1595
+		if ((int) $item['share_type'] === \OCP\Share::SHARE_TYPE_REMOTE && \OC::$server->getUserSession()->getUser()) {
1596 1596
 			list(, $remote) = Helper::splitUserRemote($item['share_with']);
1597 1597
 			self::sendRemoteUnshare($remote, $item['id'], $item['token']);
1598 1598
 		}
@@ -1753,7 +1753,7 @@  discard block
 block discarded – undo
1753 1753
 		// Get filesystem root to add it to the file target and remove from the
1754 1754
 		// file source, match file_source with the file cache
1755 1755
 		if ($itemType == 'file' || $itemType == 'folder') {
1756
-			if(!is_null($uidOwner)) {
1756
+			if (!is_null($uidOwner)) {
1757 1757
 				$root = \OC\Files\Filesystem::getRoot();
1758 1758
 			} else {
1759 1759
 				$root = '';
@@ -1898,7 +1898,7 @@  discard block
 block discarded – undo
1898 1898
 		$result = $query->execute($queryArgs);
1899 1899
 		if ($result === false) {
1900 1900
 			\OCP\Util::writeLog('OCP\Share',
1901
-				\OC_DB::getErrorMessage() . ', select=' . $select . ' where=',
1901
+				\OC_DB::getErrorMessage().', select='.$select.' where=',
1902 1902
 				\OCP\Util::ERROR);
1903 1903
 		}
1904 1904
 		$items = array();
@@ -1940,14 +1940,14 @@  discard block
 block discarded – undo
1940 1940
 						}
1941 1941
 						// Switch ids if sharing permission is granted on only
1942 1942
 						// one share to ensure correct parent is used if resharing
1943
-						if (~(int)$items[$id]['permissions'] & \OCP\Constants::PERMISSION_SHARE
1944
-							&& (int)$row['permissions'] & \OCP\Constants::PERMISSION_SHARE) {
1943
+						if (~(int) $items[$id]['permissions'] & \OCP\Constants::PERMISSION_SHARE
1944
+							&& (int) $row['permissions'] & \OCP\Constants::PERMISSION_SHARE) {
1945 1945
 							$items[$row['id']] = $items[$id];
1946 1946
 							$switchedItems[$id] = $row['id'];
1947 1947
 							unset($items[$id]);
1948 1948
 							$id = $row['id'];
1949 1949
 						}
1950
-						$items[$id]['permissions'] |= (int)$row['permissions'];
1950
+						$items[$id]['permissions'] |= (int) $row['permissions'];
1951 1951
 
1952 1952
 					}
1953 1953
 					continue;
@@ -1961,8 +1961,8 @@  discard block
 block discarded – undo
1961 1961
 					$query = \OC_DB::prepare('SELECT `file_target` FROM `*PREFIX*share` WHERE `id` = ?');
1962 1962
 					$parentResult = $query->execute(array($row['parent']));
1963 1963
 					if ($result === false) {
1964
-						\OCP\Util::writeLog('OCP\Share', 'Can\'t select parent: ' .
1965
-							\OC_DB::getErrorMessage() . ', select=' . $select . ' where=' . $where,
1964
+						\OCP\Util::writeLog('OCP\Share', 'Can\'t select parent: '.
1965
+							\OC_DB::getErrorMessage().', select='.$select.' where='.$where,
1966 1966
 							\OCP\Util::ERROR);
1967 1967
 					} else {
1968 1968
 						$parentRow = $parentResult->fetchRow();
@@ -1972,7 +1972,7 @@  discard block
 block discarded – undo
1972 1972
 						$subPath = substr($row['path'], $pos);
1973 1973
 						$splitPath = explode('/', $subPath);
1974 1974
 						foreach (array_slice($splitPath, 2) as $pathPart) {
1975
-							$tmpPath = $tmpPath . '/' . $pathPart;
1975
+							$tmpPath = $tmpPath.'/'.$pathPart;
1976 1976
 						}
1977 1977
 						$row['path'] = $tmpPath;
1978 1978
 					}
@@ -1991,7 +1991,7 @@  discard block
 block discarded – undo
1991 1991
 				}
1992 1992
 			}
1993 1993
 
1994
-			if($checkExpireDate) {
1994
+			if ($checkExpireDate) {
1995 1995
 				if (self::expireItem($row)) {
1996 1996
 					continue;
1997 1997
 				}
@@ -2002,10 +2002,10 @@  discard block
 block discarded – undo
2002 2002
 			}
2003 2003
 			// Add display names to result
2004 2004
 			$row['share_with_displayname'] = $row['share_with'];
2005
-			if ( isset($row['share_with']) && $row['share_with'] != '' &&
2005
+			if (isset($row['share_with']) && $row['share_with'] != '' &&
2006 2006
 				$row['share_type'] === self::SHARE_TYPE_USER) {
2007 2007
 				$row['share_with_displayname'] = \OCP\User::getDisplayName($row['share_with']);
2008
-			} else if(isset($row['share_with']) && $row['share_with'] != '' &&
2008
+			} else if (isset($row['share_with']) && $row['share_with'] != '' &&
2009 2009
 				$row['share_type'] === self::SHARE_TYPE_REMOTE) {
2010 2010
 				$addressBookEntries = \OC::$server->getContactsManager()->search($row['share_with'], ['CLOUD']);
2011 2011
 				foreach ($addressBookEntries as $entry) {
@@ -2016,7 +2016,7 @@  discard block
 block discarded – undo
2016 2016
 					}
2017 2017
 				}
2018 2018
 			}
2019
-			if ( isset($row['uid_owner']) && $row['uid_owner'] != '') {
2019
+			if (isset($row['uid_owner']) && $row['uid_owner'] != '') {
2020 2020
 				$row['displayname_owner'] = \OCP\User::getDisplayName($row['uid_owner']);
2021 2021
 			}
2022 2022
 
@@ -2164,7 +2164,7 @@  discard block
 block discarded – undo
2164 2164
 				// for file/folder shares we need to compare file_source, otherwise we compare item_source
2165 2165
 				// only group shares if they already point to the same target, otherwise the file where shared
2166 2166
 				// before grouping of shares was added. In this case we don't group them toi avoid confusions
2167
-				if (( $fileSharing && $item['file_source'] === $r['file_source'] && $item['file_target'] === $r['file_target']) ||
2167
+				if (($fileSharing && $item['file_source'] === $r['file_source'] && $item['file_target'] === $r['file_target']) ||
2168 2168
 					(!$fileSharing && $item['item_source'] === $r['item_source'] && $item['item_target'] === $r['item_target'])) {
2169 2169
 					// add the first item to the list of grouped shares
2170 2170
 					if (!isset($result[$key]['grouped'])) {
@@ -2210,7 +2210,7 @@  discard block
 block discarded – undo
2210 2210
 		$groupItemTarget = $itemTarget = $fileSource = $parent = 0;
2211 2211
 
2212 2212
 		$result = self::checkReshare($itemType, $itemSource, $shareType, $shareWith, $uidOwner, $permissions, $itemSourceName, $expirationDate);
2213
-		if(!empty($result)) {
2213
+		if (!empty($result)) {
2214 2214
 			$parent = $result['parent'];
2215 2215
 			$itemSource = $result['itemSource'];
2216 2216
 			$fileSource = $result['fileSource'];
@@ -2304,11 +2304,11 @@  discard block
 block discarded – undo
2304 2304
 				$itemTarget = $sourceExists['item_target'];
2305 2305
 
2306 2306
 				// for group shares we don't need a additional entry if the target is the same
2307
-				if($isGroupShare && $groupItemTarget === $itemTarget) {
2307
+				if ($isGroupShare && $groupItemTarget === $itemTarget) {
2308 2308
 					continue;
2309 2309
 				}
2310 2310
 
2311
-			} elseif(!$sourceExists && !$isGroupShare)  {
2311
+			} elseif (!$sourceExists && !$isGroupShare) {
2312 2312
 
2313 2313
 				$itemTarget = Helper::generateTarget($itemType, $itemSource, $userShareType, $user,
2314 2314
 					$uidOwner, $suggestedItemTarget, $parent);
@@ -2439,8 +2439,8 @@  discard block
 block discarded – undo
2439 2439
 
2440 2440
 		if ($checkReshare && $checkReshare['uid_owner'] !== \OC_User::getUser()) {
2441 2441
 			// Check if share permissions is granted
2442
-			if (self::isResharingAllowed() && (int)$checkReshare['permissions'] & \OCP\Constants::PERMISSION_SHARE) {
2443
-				if (~(int)$checkReshare['permissions'] & $permissions) {
2442
+			if (self::isResharingAllowed() && (int) $checkReshare['permissions'] & \OCP\Constants::PERMISSION_SHARE) {
2443
+				if (~(int) $checkReshare['permissions'] & $permissions) {
2444 2444
 					$message = 'Sharing %s failed, because the permissions exceed permissions granted to %s';
2445 2445
 					$message_t = $l->t('Sharing %s failed, because the permissions exceed permissions granted to %s', array($itemSourceName, $uidOwner));
2446 2446
 
@@ -2452,7 +2452,7 @@  discard block
 block discarded – undo
2452 2452
 
2453 2453
 					$result['expirationDate'] = $expirationDate;
2454 2454
 					// $checkReshare['expiration'] could be null and then is always less than any value
2455
-					if(isset($checkReshare['expiration']) && $checkReshare['expiration'] < $expirationDate) {
2455
+					if (isset($checkReshare['expiration']) && $checkReshare['expiration'] < $expirationDate) {
2456 2456
 						$result['expirationDate'] = $checkReshare['expiration'];
2457 2457
 					}
2458 2458
 
@@ -2544,7 +2544,7 @@  discard block
 block discarded – undo
2544 2544
 
2545 2545
 		$id = false;
2546 2546
 		if ($result) {
2547
-			$id =  \OC::$server->getDatabaseConnection()->lastInsertId('*PREFIX*share');
2547
+			$id = \OC::$server->getDatabaseConnection()->lastInsertId('*PREFIX*share');
2548 2548
 		}
2549 2549
 
2550 2550
 		return $id;
@@ -2584,8 +2584,8 @@  discard block
 block discarded – undo
2584 2584
 			return true;
2585 2585
 		}
2586 2586
 
2587
-		if ( \OC::$server->getSession()->exists('public_link_authenticated')
2588
-			&& \OC::$server->getSession()->get('public_link_authenticated') === (string)$linkItem['id'] ) {
2587
+		if (\OC::$server->getSession()->exists('public_link_authenticated')
2588
+			&& \OC::$server->getSession()->get('public_link_authenticated') === (string) $linkItem['id']) {
2589 2589
 			return true;
2590 2590
 		}
2591 2591
 
@@ -2687,7 +2687,7 @@  discard block
 block discarded – undo
2687 2687
 	 * @param array $parameters additional format parameters
2688 2688
 	 * @return array format result
2689 2689
 	 */
2690
-	private static function formatResult($items, $column, $backend, $format = self::FORMAT_NONE , $parameters = null) {
2690
+	private static function formatResult($items, $column, $backend, $format = self::FORMAT_NONE, $parameters = null) {
2691 2691
 		if ($format === self::FORMAT_NONE) {
2692 2692
 			return $items;
2693 2693
 		} else if ($format === self::FORMAT_STATUSES) {
@@ -2747,8 +2747,8 @@  discard block
 block discarded – undo
2747 2747
 			\OC::$server->getHTTPClientService()
2748 2748
 		);
2749 2749
 		while ($result['success'] === false && $try < 2) {
2750
-			$endpoint = $discoveryManager->getShareEndpoint($protocol . $remoteDomain);
2751
-			$result = \OC::$server->getHTTPHelper()->post($protocol . $remoteDomain . $endpoint . $urlSuffix . '?format=' . self::RESPONSE_FORMAT, $fields);
2750
+			$endpoint = $discoveryManager->getShareEndpoint($protocol.$remoteDomain);
2751
+			$result = \OC::$server->getHTTPHelper()->post($protocol.$remoteDomain.$endpoint.$urlSuffix.'?format='.self::RESPONSE_FORMAT, $fields);
2752 2752
 			$try++;
2753 2753
 			$protocol = 'http://';
2754 2754
 		}
@@ -2845,7 +2845,7 @@  discard block
 block discarded – undo
2845 2845
 	 * @return int
2846 2846
 	 */
2847 2847
 	public static function getExpireInterval() {
2848
-		return (int)\OCP\Config::getAppValue('core', 'shareapi_expire_after_n_days', '7');
2848
+		return (int) \OCP\Config::getAppValue('core', 'shareapi_expire_after_n_days', '7');
2849 2849
 	}
2850 2850
 
2851 2851
 	/**
Please login to merge, or discard this patch.