Passed
Push — master ( 02306d...9f9b89 )
by Morris
14:24 queued 10s
created
lib/private/Share/Share.php 1 patch
Spacing   +40 added lines, -40 removed lines patch added patch discarded remove patch
@@ -84,7 +84,7 @@  discard block
 block discarded – undo
84 84
 					'collectionOf' => $collectionOf,
85 85
 					'supportedFileExtensions' => $supportedFileExtensions
86 86
 				);
87
-				if(count(self::$backendTypes) === 1) {
87
+				if (count(self::$backendTypes) === 1) {
88 88
 					Util::addScript('core', 'dist/share_backend');
89 89
 				}
90 90
 				return true;
@@ -156,7 +156,7 @@  discard block
 block discarded – undo
156 156
 
157 157
 		$select = self::createSelectStatement(self::FORMAT_NONE, $fileDependent);
158 158
 
159
-		$where .= ' `' . $column . '` = ? AND `item_type` = ? ';
159
+		$where .= ' `'.$column.'` = ? AND `item_type` = ? ';
160 160
 		$arguments = array($itemSource, $itemType);
161 161
 		// for link shares $user === null
162 162
 		if ($user !== null) {
@@ -174,7 +174,7 @@  discard block
 block discarded – undo
174 174
 			$arguments[] = $owner;
175 175
 		}
176 176
 
177
-		$query = \OC_DB::prepare('SELECT ' . $select . ' FROM `*PREFIX*share` '. $fileDependentWhere . $where);
177
+		$query = \OC_DB::prepare('SELECT '.$select.' FROM `*PREFIX*share` '.$fileDependentWhere.$where);
178 178
 
179 179
 		$result = \OC_DB::executeAudited($query, $arguments);
180 180
 
@@ -182,7 +182,7 @@  discard block
 block discarded – undo
182 182
 			if ($fileDependent && !self::isFileReachable($row['path'], $row['storage_id'])) {
183 183
 				continue;
184 184
 			}
185
-			if ($fileDependent && (int)$row['file_parent'] === -1) {
185
+			if ($fileDependent && (int) $row['file_parent'] === -1) {
186 186
 				// if it is a mount point we need to get the path from the mount manager
187 187
 				$mountManager = \OC\Files\Filesystem::getMountManager();
188 188
 				$mountPoint = $mountManager->findByStorageId($row['storage_id']);
@@ -193,7 +193,7 @@  discard block
 block discarded – undo
193 193
 					$row['path'] = $path;
194 194
 				} else {
195 195
 					\OC::$server->getLogger()->warning(
196
-						'Could not resolve mount point for ' . $row['storage_id'],
196
+						'Could not resolve mount point for '.$row['storage_id'],
197 197
 						['app' => 'OCP\Share']
198 198
 					);
199 199
 				}
@@ -202,7 +202,7 @@  discard block
 block discarded – undo
202 202
 		}
203 203
 
204 204
 		//if didn't found a result than let's look for a group share.
205
-		if(empty($shares) && $user !== null) {
205
+		if (empty($shares) && $user !== null) {
206 206
 			$userObject = \OC::$server->getUserManager()->get($user);
207 207
 			$groups = [];
208 208
 			if ($userObject) {
@@ -210,7 +210,7 @@  discard block
 block discarded – undo
210 210
 			}
211 211
 
212 212
 			if (!empty($groups)) {
213
-				$where = $fileDependentWhere . ' WHERE `' . $column . '` = ? AND `item_type` = ? AND `share_with` in (?)';
213
+				$where = $fileDependentWhere.' WHERE `'.$column.'` = ? AND `item_type` = ? AND `share_with` in (?)';
214 214
 				$arguments = array($itemSource, $itemType, $groups);
215 215
 				$types = array(null, null, IQueryBuilder::PARAM_STR_ARRAY);
216 216
 
@@ -224,7 +224,7 @@  discard block
 block discarded – undo
224 224
 				// class isn't static anymore...
225 225
 				$conn = \OC::$server->getDatabaseConnection();
226 226
 				$result = $conn->executeQuery(
227
-					'SELECT ' . $select . ' FROM `*PREFIX*share` ' . $where,
227
+					'SELECT '.$select.' FROM `*PREFIX*share` '.$where,
228 228
 					$arguments,
229 229
 					$types
230 230
 				);
@@ -266,7 +266,7 @@  discard block
 block discarded – undo
266 266
 		$query = \OC_DB::prepare('SELECT * FROM `*PREFIX*share` WHERE `token` = ?', 1);
267 267
 		$result = $query->execute(array($token));
268 268
 		if ($result === false) {
269
-			\OCP\Util::writeLog('OCP\Share', \OC_DB::getErrorMessage() . ', token=' . $token, ILogger::ERROR);
269
+			\OCP\Util::writeLog('OCP\Share', \OC_DB::getErrorMessage().', token='.$token, ILogger::ERROR);
270 270
 		}
271 271
 		$row = $result->fetchRow();
272 272
 		if ($row === false) {
@@ -401,12 +401,12 @@  discard block
 block discarded – undo
401 401
 		$currentUser = $owner ? $owner : \OC_User::getUser();
402 402
 		foreach ($items as $item) {
403 403
 			// delete the item with the expected share_type and owner
404
-			if ((int)$item['share_type'] === (int)$shareType && $item['uid_owner'] === $currentUser) {
404
+			if ((int) $item['share_type'] === (int) $shareType && $item['uid_owner'] === $currentUser) {
405 405
 				$toDelete = $item;
406 406
 				// if there is more then one result we don't have to delete the children
407 407
 				// but update their parent. For group shares the new parent should always be
408 408
 				// the original group share and not the db entry with the unique name
409
-			} else if ((int)$item['share_type'] === self::$shareTypeGroupUserUnique) {
409
+			} else if ((int) $item['share_type'] === self::$shareTypeGroupUserUnique) {
410 410
 				$newParent = $item['parent'];
411 411
 			} else {
412 412
 				$newParent = $item['id'];
@@ -438,7 +438,7 @@  discard block
 block discarded – undo
438 438
 
439 439
 		$result = $query->execute(array($status, $itemType, $itemSource, $shareType, $recipient));
440 440
 
441
-		if($result === false) {
441
+		if ($result === false) {
442 442
 			\OCP\Util::writeLog('OCP\Share', 'Couldn\'t set send mail status', ILogger::ERROR);
443 443
 		}
444 444
 	}
@@ -488,7 +488,7 @@  discard block
 block discarded – undo
488 488
 	 */
489 489
 	protected static function unshareItem(array $item, $newParent = null) {
490 490
 
491
-		$shareType = (int)$item['share_type'];
491
+		$shareType = (int) $item['share_type'];
492 492
 		$shareWith = null;
493 493
 		if ($shareType !== \OCP\Share::SHARE_TYPE_LINK) {
494 494
 			$shareWith = $item['share_with'];
@@ -504,7 +504,7 @@  discard block
 block discarded – undo
504 504
 			'itemParent'    => $item['parent'],
505 505
 			'uidOwner'      => $item['uid_owner'],
506 506
 		);
507
-		if($item['item_type'] === 'file' || $item['item_type'] === 'folder') {
507
+		if ($item['item_type'] === 'file' || $item['item_type'] === 'folder') {
508 508
 			$hookParams['fileSource'] = $item['file_source'];
509 509
 			$hookParams['fileTarget'] = $item['file_target'];
510 510
 		}
@@ -514,7 +514,7 @@  discard block
 block discarded – undo
514 514
 		$deletedShares[] = $hookParams;
515 515
 		$hookParams['deletedShares'] = $deletedShares;
516 516
 		\OC_Hook::emit(\OCP\Share::class, 'post_unshare', $hookParams);
517
-		if ((int)$item['share_type'] === \OCP\Share::SHARE_TYPE_REMOTE && \OC::$server->getUserSession()->getUser()) {
517
+		if ((int) $item['share_type'] === \OCP\Share::SHARE_TYPE_REMOTE && \OC::$server->getUserSession()->getUser()) {
518 518
 			list(, $remote) = Helper::splitUserRemote($item['share_with']);
519 519
 			self::sendRemoteUnshare($remote, $item['id'], $item['token']);
520 520
 		}
@@ -678,7 +678,7 @@  discard block
 block discarded – undo
678 678
 		// Get filesystem root to add it to the file target and remove from the
679 679
 		// file source, match file_source with the file cache
680 680
 		if ($itemType == 'file' || $itemType == 'folder') {
681
-			if(!is_null($uidOwner)) {
681
+			if (!is_null($uidOwner)) {
682 682
 				$root = \OC\Files\Filesystem::getRoot();
683 683
 			} else {
684 684
 				$root = '';
@@ -823,7 +823,7 @@  discard block
 block discarded – undo
823 823
 		$result = $query->execute($queryArgs);
824 824
 		if ($result === false) {
825 825
 			\OCP\Util::writeLog('OCP\Share',
826
-				\OC_DB::getErrorMessage() . ', select=' . $select . ' where=',
826
+				\OC_DB::getErrorMessage().', select='.$select.' where=',
827 827
 				ILogger::ERROR);
828 828
 		}
829 829
 		$items = array();
@@ -865,14 +865,14 @@  discard block
 block discarded – undo
865 865
 						}
866 866
 						// Switch ids if sharing permission is granted on only
867 867
 						// one share to ensure correct parent is used if resharing
868
-						if (~(int)$items[$id]['permissions'] & \OCP\Constants::PERMISSION_SHARE
869
-							&& (int)$row['permissions'] & \OCP\Constants::PERMISSION_SHARE) {
868
+						if (~(int) $items[$id]['permissions'] & \OCP\Constants::PERMISSION_SHARE
869
+							&& (int) $row['permissions'] & \OCP\Constants::PERMISSION_SHARE) {
870 870
 							$items[$row['id']] = $items[$id];
871 871
 							$switchedItems[$id] = $row['id'];
872 872
 							unset($items[$id]);
873 873
 							$id = $row['id'];
874 874
 						}
875
-						$items[$id]['permissions'] |= (int)$row['permissions'];
875
+						$items[$id]['permissions'] |= (int) $row['permissions'];
876 876
 
877 877
 					}
878 878
 					continue;
@@ -886,8 +886,8 @@  discard block
 block discarded – undo
886 886
 					$query = \OC_DB::prepare('SELECT `file_target` FROM `*PREFIX*share` WHERE `id` = ?');
887 887
 					$parentResult = $query->execute(array($row['parent']));
888 888
 					if ($result === false) {
889
-						\OCP\Util::writeLog('OCP\Share', 'Can\'t select parent: ' .
890
-							\OC_DB::getErrorMessage() . ', select=' . $select . ' where=' . $where,
889
+						\OCP\Util::writeLog('OCP\Share', 'Can\'t select parent: '.
890
+							\OC_DB::getErrorMessage().', select='.$select.' where='.$where,
891 891
 							ILogger::ERROR);
892 892
 					} else {
893 893
 						$parentRow = $parentResult->fetchRow();
@@ -897,7 +897,7 @@  discard block
 block discarded – undo
897 897
 						$subPath = substr($row['path'], $pos);
898 898
 						$splitPath = explode('/', $subPath);
899 899
 						foreach (array_slice($splitPath, 2) as $pathPart) {
900
-							$tmpPath = $tmpPath . '/' . $pathPart;
900
+							$tmpPath = $tmpPath.'/'.$pathPart;
901 901
 						}
902 902
 						$row['path'] = $tmpPath;
903 903
 					}
@@ -916,7 +916,7 @@  discard block
 block discarded – undo
916 916
 				}
917 917
 			}
918 918
 
919
-			if($checkExpireDate) {
919
+			if ($checkExpireDate) {
920 920
 				if (self::expireItem($row)) {
921 921
 					continue;
922 922
 				}
@@ -927,11 +927,11 @@  discard block
 block discarded – undo
927 927
 			}
928 928
 			// Add display names to result
929 929
 			$row['share_with_displayname'] = $row['share_with'];
930
-			if ( isset($row['share_with']) && $row['share_with'] != '' &&
930
+			if (isset($row['share_with']) && $row['share_with'] != '' &&
931 931
 				$row['share_type'] === self::SHARE_TYPE_USER) {
932 932
 				$shareWithUser = \OC::$server->getUserManager()->get($row['share_with']);
933 933
 				$row['share_with_displayname'] = $shareWithUser === null ? $row['share_with'] : $shareWithUser->getDisplayName();
934
-			} else if(isset($row['share_with']) && $row['share_with'] != '' &&
934
+			} else if (isset($row['share_with']) && $row['share_with'] != '' &&
935 935
 				$row['share_type'] === self::SHARE_TYPE_REMOTE) {
936 936
 				$addressBookEntries = \OC::$server->getContactsManager()->search($row['share_with'], ['CLOUD']);
937 937
 				foreach ($addressBookEntries as $entry) {
@@ -942,7 +942,7 @@  discard block
 block discarded – undo
942 942
 					}
943 943
 				}
944 944
 			}
945
-			if ( isset($row['uid_owner']) && $row['uid_owner'] != '') {
945
+			if (isset($row['uid_owner']) && $row['uid_owner'] != '') {
946 946
 				$ownerUser = \OC::$server->getUserManager()->get($row['uid_owner']);
947 947
 				$row['displayname_owner'] = $ownerUser === null ? $row['uid_owner'] : $ownerUser->getDisplayName();
948 948
 			}
@@ -1091,7 +1091,7 @@  discard block
 block discarded – undo
1091 1091
 				// for file/folder shares we need to compare file_source, otherwise we compare item_source
1092 1092
 				// only group shares if they already point to the same target, otherwise the file where shared
1093 1093
 				// before grouping of shares was added. In this case we don't group them toi avoid confusions
1094
-				if (( $fileSharing && $item['file_source'] === $r['file_source'] && $item['file_target'] === $r['file_target']) ||
1094
+				if (($fileSharing && $item['file_source'] === $r['file_source'] && $item['file_target'] === $r['file_target']) ||
1095 1095
 					(!$fileSharing && $item['item_source'] === $r['item_source'] && $item['item_target'] === $r['item_target'])) {
1096 1096
 					// add the first item to the list of grouped shares
1097 1097
 					if (!isset($result[$key]['grouped'])) {
@@ -1136,7 +1136,7 @@  discard block
 block discarded – undo
1136 1136
 		$groupItemTarget = $itemTarget = $fileSource = $parent = 0;
1137 1137
 
1138 1138
 		$result = self::checkReshare('test', $itemSource, self::SHARE_TYPE_USER, $shareWith, $uidOwner, $permissions, null, null);
1139
-		if(!empty($result)) {
1139
+		if (!empty($result)) {
1140 1140
 			$parent = $result['parent'];
1141 1141
 			$itemSource = $result['itemSource'];
1142 1142
 			$fileSource = $result['fileSource'];
@@ -1184,7 +1184,7 @@  discard block
 block discarded – undo
1184 1184
 				$fileTarget = $sourceExists['file_target'];
1185 1185
 				$itemTarget = $sourceExists['item_target'];
1186 1186
 
1187
-			} elseif(!$sourceExists)  {
1187
+			} elseif (!$sourceExists) {
1188 1188
 
1189 1189
 				$itemTarget = Helper::generateTarget($itemType, $itemSource, $userShareType, $user,
1190 1190
 					$uidOwner, $suggestedItemTarget, $parent);
@@ -1295,8 +1295,8 @@  discard block
 block discarded – undo
1295 1295
 
1296 1296
 		if ($checkReshare && $checkReshare['uid_owner'] !== \OC_User::getUser()) {
1297 1297
 			// Check if share permissions is granted
1298
-			if (self::isResharingAllowed() && (int)$checkReshare['permissions'] & \OCP\Constants::PERMISSION_SHARE) {
1299
-				if (~(int)$checkReshare['permissions'] & $permissions) {
1298
+			if (self::isResharingAllowed() && (int) $checkReshare['permissions'] & \OCP\Constants::PERMISSION_SHARE) {
1299
+				if (~(int) $checkReshare['permissions'] & $permissions) {
1300 1300
 					$message = 'Sharing %1$s failed, because the permissions exceed permissions granted to %2$s';
1301 1301
 					throw new \Exception(sprintf($message, $itemSourceName, $uidOwner));
1302 1302
 				} else {
@@ -1305,7 +1305,7 @@  discard block
 block discarded – undo
1305 1305
 
1306 1306
 					$result['expirationDate'] = $expirationDate;
1307 1307
 					// $checkReshare['expiration'] could be null and then is always less than any value
1308
-					if(isset($checkReshare['expiration']) && $checkReshare['expiration'] < $expirationDate) {
1308
+					if (isset($checkReshare['expiration']) && $checkReshare['expiration'] < $expirationDate) {
1309 1309
 						$result['expirationDate'] = $checkReshare['expiration'];
1310 1310
 					}
1311 1311
 
@@ -1385,7 +1385,7 @@  discard block
 block discarded – undo
1385 1385
 
1386 1386
 		$id = false;
1387 1387
 		if ($result) {
1388
-			$id =  \OC::$server->getDatabaseConnection()->lastInsertId('*PREFIX*share');
1388
+			$id = \OC::$server->getDatabaseConnection()->lastInsertId('*PREFIX*share');
1389 1389
 		}
1390 1390
 
1391 1391
 		return $id;
@@ -1413,8 +1413,8 @@  discard block
 block discarded – undo
1413 1413
 			return true;
1414 1414
 		}
1415 1415
 
1416
-		if ( \OC::$server->getSession()->exists('public_link_authenticated')
1417
-			&& \OC::$server->getSession()->get('public_link_authenticated') === (string)$linkItem['id'] ) {
1416
+		if (\OC::$server->getSession()->exists('public_link_authenticated')
1417
+			&& \OC::$server->getSession()->get('public_link_authenticated') === (string) $linkItem['id']) {
1418 1418
 			return true;
1419 1419
 		}
1420 1420
 
@@ -1516,7 +1516,7 @@  discard block
 block discarded – undo
1516 1516
 	 * @param array $parameters additional format parameters
1517 1517
 	 * @return array format result
1518 1518
 	 */
1519
-	private static function formatResult($items, $column, $backend, $format = self::FORMAT_NONE , $parameters = null) {
1519
+	private static function formatResult($items, $column, $backend, $format = self::FORMAT_NONE, $parameters = null) {
1520 1520
 		if ($format === self::FORMAT_NONE) {
1521 1521
 			return $items;
1522 1522
 		} else if ($format === self::FORMAT_STATUSES) {
@@ -1573,13 +1573,13 @@  discard block
 block discarded – undo
1573 1573
 		$try = 0;
1574 1574
 		$discoveryService = \OC::$server->query(\OCP\OCS\IDiscoveryService::class);
1575 1575
 		while ($result['success'] === false && $try < 2) {
1576
-			$federationEndpoints = $discoveryService->discover($protocol . $remoteDomain, 'FEDERATED_SHARING');
1576
+			$federationEndpoints = $discoveryService->discover($protocol.$remoteDomain, 'FEDERATED_SHARING');
1577 1577
 			$endpoint = isset($federationEndpoints['share']) ? $federationEndpoints['share'] : '/ocs/v2.php/cloud/shares';
1578 1578
 			$client = \OC::$server->getHTTPClientService()->newClient();
1579 1579
 
1580 1580
 			try {
1581 1581
 				$response = $client->post(
1582
-					$protocol . $remoteDomain . $endpoint . $urlSuffix . '?format=' . self::RESPONSE_FORMAT,
1582
+					$protocol.$remoteDomain.$endpoint.$urlSuffix.'?format='.self::RESPONSE_FORMAT,
1583 1583
 					[
1584 1584
 						'body' => $fields,
1585 1585
 						'connect_timeout' => 10,
@@ -1628,7 +1628,7 @@  discard block
 block discarded – undo
1628 1628
 	 * @return int
1629 1629
 	 */
1630 1630
 	public static function getExpireInterval() {
1631
-		return (int)\OC::$server->getConfig()->getAppValue('core', 'shareapi_expire_after_n_days', '7');
1631
+		return (int) \OC::$server->getConfig()->getAppValue('core', 'shareapi_expire_after_n_days', '7');
1632 1632
 	}
1633 1633
 
1634 1634
 	/**
Please login to merge, or discard this patch.