@@ -84,7 +84,7 @@ discard block |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 | ); |
@@ -358,12 +358,12 @@ discard block |
||
| 358 | 358 | $currentUser = $owner ? $owner : \OC_User::getUser(); |
| 359 | 359 | foreach ($items as $item) { |
| 360 | 360 | // delete the item with the expected share_type and owner |
| 361 | - if ((int)$item['share_type'] === (int)$shareType && $item['uid_owner'] === $currentUser) { |
|
| 361 | + if ((int) $item['share_type'] === (int) $shareType && $item['uid_owner'] === $currentUser) { |
|
| 362 | 362 | $toDelete = $item; |
| 363 | 363 | // if there is more then one result we don't have to delete the children |
| 364 | 364 | // but update their parent. For group shares the new parent should always be |
| 365 | 365 | // the original group share and not the db entry with the unique name |
| 366 | - } else if ((int)$item['share_type'] === self::$shareTypeGroupUserUnique) { |
|
| 366 | + } else if ((int) $item['share_type'] === self::$shareTypeGroupUserUnique) { |
|
| 367 | 367 | $newParent = $item['parent']; |
| 368 | 368 | } else { |
| 369 | 369 | $newParent = $item['id']; |
@@ -422,7 +422,7 @@ discard block |
||
| 422 | 422 | */ |
| 423 | 423 | protected static function unshareItem(array $item, $newParent = null) { |
| 424 | 424 | |
| 425 | - $shareType = (int)$item['share_type']; |
|
| 425 | + $shareType = (int) $item['share_type']; |
|
| 426 | 426 | $shareWith = null; |
| 427 | 427 | if ($shareType !== \OCP\Share::SHARE_TYPE_LINK) { |
| 428 | 428 | $shareWith = $item['share_with']; |
@@ -438,7 +438,7 @@ discard block |
||
| 438 | 438 | 'itemParent' => $item['parent'], |
| 439 | 439 | 'uidOwner' => $item['uid_owner'], |
| 440 | 440 | ); |
| 441 | - if($item['item_type'] === 'file' || $item['item_type'] === 'folder') { |
|
| 441 | + if ($item['item_type'] === 'file' || $item['item_type'] === 'folder') { |
|
| 442 | 442 | $hookParams['fileSource'] = $item['file_source']; |
| 443 | 443 | $hookParams['fileTarget'] = $item['file_target']; |
| 444 | 444 | } |
@@ -448,7 +448,7 @@ discard block |
||
| 448 | 448 | $deletedShares[] = $hookParams; |
| 449 | 449 | $hookParams['deletedShares'] = $deletedShares; |
| 450 | 450 | \OC_Hook::emit(\OCP\Share::class, 'post_unshare', $hookParams); |
| 451 | - if ((int)$item['share_type'] === \OCP\Share::SHARE_TYPE_REMOTE && \OC::$server->getUserSession()->getUser()) { |
|
| 451 | + if ((int) $item['share_type'] === \OCP\Share::SHARE_TYPE_REMOTE && \OC::$server->getUserSession()->getUser()) { |
|
| 452 | 452 | list(, $remote) = Helper::splitUserRemote($item['share_with']); |
| 453 | 453 | self::sendRemoteUnshare($remote, $item['id'], $item['token']); |
| 454 | 454 | } |
@@ -612,7 +612,7 @@ discard block |
||
| 612 | 612 | // Get filesystem root to add it to the file target and remove from the |
| 613 | 613 | // file source, match file_source with the file cache |
| 614 | 614 | if ($itemType == 'file' || $itemType == 'folder') { |
| 615 | - if(!is_null($uidOwner)) { |
|
| 615 | + if (!is_null($uidOwner)) { |
|
| 616 | 616 | $root = \OC\Files\Filesystem::getRoot(); |
| 617 | 617 | } else { |
| 618 | 618 | $root = ''; |
@@ -757,7 +757,7 @@ discard block |
||
| 757 | 757 | $result = $query->execute($queryArgs); |
| 758 | 758 | if ($result === false) { |
| 759 | 759 | \OCP\Util::writeLog('OCP\Share', |
| 760 | - \OC_DB::getErrorMessage() . ', select=' . $select . ' where=', |
|
| 760 | + \OC_DB::getErrorMessage().', select='.$select.' where=', |
|
| 761 | 761 | ILogger::ERROR); |
| 762 | 762 | } |
| 763 | 763 | $items = array(); |
@@ -799,14 +799,14 @@ discard block |
||
| 799 | 799 | } |
| 800 | 800 | // Switch ids if sharing permission is granted on only |
| 801 | 801 | // one share to ensure correct parent is used if resharing |
| 802 | - if (~(int)$items[$id]['permissions'] & \OCP\Constants::PERMISSION_SHARE |
|
| 803 | - && (int)$row['permissions'] & \OCP\Constants::PERMISSION_SHARE) { |
|
| 802 | + if (~(int) $items[$id]['permissions'] & \OCP\Constants::PERMISSION_SHARE |
|
| 803 | + && (int) $row['permissions'] & \OCP\Constants::PERMISSION_SHARE) { |
|
| 804 | 804 | $items[$row['id']] = $items[$id]; |
| 805 | 805 | $switchedItems[$id] = $row['id']; |
| 806 | 806 | unset($items[$id]); |
| 807 | 807 | $id = $row['id']; |
| 808 | 808 | } |
| 809 | - $items[$id]['permissions'] |= (int)$row['permissions']; |
|
| 809 | + $items[$id]['permissions'] |= (int) $row['permissions']; |
|
| 810 | 810 | |
| 811 | 811 | } |
| 812 | 812 | continue; |
@@ -820,8 +820,8 @@ discard block |
||
| 820 | 820 | $query = \OC_DB::prepare('SELECT `file_target` FROM `*PREFIX*share` WHERE `id` = ?'); |
| 821 | 821 | $parentResult = $query->execute(array($row['parent'])); |
| 822 | 822 | if ($result === false) { |
| 823 | - \OCP\Util::writeLog('OCP\Share', 'Can\'t select parent: ' . |
|
| 824 | - \OC_DB::getErrorMessage() . ', select=' . $select . ' where=' . $where, |
|
| 823 | + \OCP\Util::writeLog('OCP\Share', 'Can\'t select parent: '. |
|
| 824 | + \OC_DB::getErrorMessage().', select='.$select.' where='.$where, |
|
| 825 | 825 | ILogger::ERROR); |
| 826 | 826 | } else { |
| 827 | 827 | $parentRow = $parentResult->fetchRow(); |
@@ -831,7 +831,7 @@ discard block |
||
| 831 | 831 | $subPath = substr($row['path'], $pos); |
| 832 | 832 | $splitPath = explode('/', $subPath); |
| 833 | 833 | foreach (array_slice($splitPath, 2) as $pathPart) { |
| 834 | - $tmpPath = $tmpPath . '/' . $pathPart; |
|
| 834 | + $tmpPath = $tmpPath.'/'.$pathPart; |
|
| 835 | 835 | } |
| 836 | 836 | $row['path'] = $tmpPath; |
| 837 | 837 | } |
@@ -850,7 +850,7 @@ discard block |
||
| 850 | 850 | } |
| 851 | 851 | } |
| 852 | 852 | |
| 853 | - if($checkExpireDate) { |
|
| 853 | + if ($checkExpireDate) { |
|
| 854 | 854 | if (self::expireItem($row)) { |
| 855 | 855 | continue; |
| 856 | 856 | } |
@@ -861,11 +861,11 @@ discard block |
||
| 861 | 861 | } |
| 862 | 862 | // Add display names to result |
| 863 | 863 | $row['share_with_displayname'] = $row['share_with']; |
| 864 | - if ( isset($row['share_with']) && $row['share_with'] != '' && |
|
| 864 | + if (isset($row['share_with']) && $row['share_with'] != '' && |
|
| 865 | 865 | $row['share_type'] === self::SHARE_TYPE_USER) { |
| 866 | 866 | $shareWithUser = \OC::$server->getUserManager()->get($row['share_with']); |
| 867 | 867 | $row['share_with_displayname'] = $shareWithUser === null ? $row['share_with'] : $shareWithUser->getDisplayName(); |
| 868 | - } else if(isset($row['share_with']) && $row['share_with'] != '' && |
|
| 868 | + } else if (isset($row['share_with']) && $row['share_with'] != '' && |
|
| 869 | 869 | $row['share_type'] === self::SHARE_TYPE_REMOTE) { |
| 870 | 870 | $addressBookEntries = \OC::$server->getContactsManager()->search($row['share_with'], ['CLOUD']); |
| 871 | 871 | foreach ($addressBookEntries as $entry) { |
@@ -876,7 +876,7 @@ discard block |
||
| 876 | 876 | } |
| 877 | 877 | } |
| 878 | 878 | } |
| 879 | - if ( isset($row['uid_owner']) && $row['uid_owner'] != '') { |
|
| 879 | + if (isset($row['uid_owner']) && $row['uid_owner'] != '') { |
|
| 880 | 880 | $ownerUser = \OC::$server->getUserManager()->get($row['uid_owner']); |
| 881 | 881 | $row['displayname_owner'] = $ownerUser === null ? $row['uid_owner'] : $ownerUser->getDisplayName(); |
| 882 | 882 | } |
@@ -1025,7 +1025,7 @@ discard block |
||
| 1025 | 1025 | // for file/folder shares we need to compare file_source, otherwise we compare item_source |
| 1026 | 1026 | // only group shares if they already point to the same target, otherwise the file where shared |
| 1027 | 1027 | // before grouping of shares was added. In this case we don't group them toi avoid confusions |
| 1028 | - if (( $fileSharing && $item['file_source'] === $r['file_source'] && $item['file_target'] === $r['file_target']) || |
|
| 1028 | + if (($fileSharing && $item['file_source'] === $r['file_source'] && $item['file_target'] === $r['file_target']) || |
|
| 1029 | 1029 | (!$fileSharing && $item['item_source'] === $r['item_source'] && $item['item_target'] === $r['item_target'])) { |
| 1030 | 1030 | // add the first item to the list of grouped shares |
| 1031 | 1031 | if (!isset($result[$key]['grouped'])) { |
@@ -1070,7 +1070,7 @@ discard block |
||
| 1070 | 1070 | $groupItemTarget = $itemTarget = $fileSource = $parent = 0; |
| 1071 | 1071 | |
| 1072 | 1072 | $result = self::checkReshare('test', $itemSource, self::SHARE_TYPE_USER, $shareWith, $uidOwner, $permissions, null, null); |
| 1073 | - if(!empty($result)) { |
|
| 1073 | + if (!empty($result)) { |
|
| 1074 | 1074 | $parent = $result['parent']; |
| 1075 | 1075 | $itemSource = $result['itemSource']; |
| 1076 | 1076 | $fileSource = $result['fileSource']; |
@@ -1118,7 +1118,7 @@ discard block |
||
| 1118 | 1118 | $fileTarget = $sourceExists['file_target']; |
| 1119 | 1119 | $itemTarget = $sourceExists['item_target']; |
| 1120 | 1120 | |
| 1121 | - } elseif(!$sourceExists) { |
|
| 1121 | + } elseif (!$sourceExists) { |
|
| 1122 | 1122 | |
| 1123 | 1123 | $itemTarget = Helper::generateTarget($itemType, $itemSource, $userShareType, $user, |
| 1124 | 1124 | $uidOwner, $suggestedItemTarget, $parent); |
@@ -1229,8 +1229,8 @@ discard block |
||
| 1229 | 1229 | |
| 1230 | 1230 | if ($checkReshare && $checkReshare['uid_owner'] !== \OC_User::getUser()) { |
| 1231 | 1231 | // Check if share permissions is granted |
| 1232 | - if (self::isResharingAllowed() && (int)$checkReshare['permissions'] & \OCP\Constants::PERMISSION_SHARE) { |
|
| 1233 | - if (~(int)$checkReshare['permissions'] & $permissions) { |
|
| 1232 | + if (self::isResharingAllowed() && (int) $checkReshare['permissions'] & \OCP\Constants::PERMISSION_SHARE) { |
|
| 1233 | + if (~(int) $checkReshare['permissions'] & $permissions) { |
|
| 1234 | 1234 | $message = 'Sharing %1$s failed, because the permissions exceed permissions granted to %2$s'; |
| 1235 | 1235 | throw new \Exception(sprintf($message, $itemSourceName, $uidOwner)); |
| 1236 | 1236 | } else { |
@@ -1239,7 +1239,7 @@ discard block |
||
| 1239 | 1239 | |
| 1240 | 1240 | $result['expirationDate'] = $expirationDate; |
| 1241 | 1241 | // $checkReshare['expiration'] could be null and then is always less than any value |
| 1242 | - if(isset($checkReshare['expiration']) && $checkReshare['expiration'] < $expirationDate) { |
|
| 1242 | + if (isset($checkReshare['expiration']) && $checkReshare['expiration'] < $expirationDate) { |
|
| 1243 | 1243 | $result['expirationDate'] = $checkReshare['expiration']; |
| 1244 | 1244 | } |
| 1245 | 1245 | |
@@ -1319,7 +1319,7 @@ discard block |
||
| 1319 | 1319 | |
| 1320 | 1320 | $id = false; |
| 1321 | 1321 | if ($result) { |
| 1322 | - $id = \OC::$server->getDatabaseConnection()->lastInsertId('*PREFIX*share'); |
|
| 1322 | + $id = \OC::$server->getDatabaseConnection()->lastInsertId('*PREFIX*share'); |
|
| 1323 | 1323 | } |
| 1324 | 1324 | |
| 1325 | 1325 | return $id; |
@@ -1421,7 +1421,7 @@ discard block |
||
| 1421 | 1421 | * @param array $parameters additional format parameters |
| 1422 | 1422 | * @return array format result |
| 1423 | 1423 | */ |
| 1424 | - private static function formatResult($items, $column, $backend, $format = self::FORMAT_NONE , $parameters = null) { |
|
| 1424 | + private static function formatResult($items, $column, $backend, $format = self::FORMAT_NONE, $parameters = null) { |
|
| 1425 | 1425 | if ($format === self::FORMAT_NONE) { |
| 1426 | 1426 | return $items; |
| 1427 | 1427 | } else if ($format === self::FORMAT_STATUSES) { |
@@ -1478,13 +1478,13 @@ discard block |
||
| 1478 | 1478 | $try = 0; |
| 1479 | 1479 | $discoveryService = \OC::$server->query(\OCP\OCS\IDiscoveryService::class); |
| 1480 | 1480 | while ($result['success'] === false && $try < 2) { |
| 1481 | - $federationEndpoints = $discoveryService->discover($protocol . $remoteDomain, 'FEDERATED_SHARING'); |
|
| 1481 | + $federationEndpoints = $discoveryService->discover($protocol.$remoteDomain, 'FEDERATED_SHARING'); |
|
| 1482 | 1482 | $endpoint = isset($federationEndpoints['share']) ? $federationEndpoints['share'] : '/ocs/v2.php/cloud/shares'; |
| 1483 | 1483 | $client = \OC::$server->getHTTPClientService()->newClient(); |
| 1484 | 1484 | |
| 1485 | 1485 | try { |
| 1486 | 1486 | $response = $client->post( |
| 1487 | - $protocol . $remoteDomain . $endpoint . $urlSuffix . '?format=' . self::RESPONSE_FORMAT, |
|
| 1487 | + $protocol.$remoteDomain.$endpoint.$urlSuffix.'?format='.self::RESPONSE_FORMAT, |
|
| 1488 | 1488 | [ |
| 1489 | 1489 | 'body' => $fields, |
| 1490 | 1490 | 'connect_timeout' => 10, |
@@ -1525,7 +1525,7 @@ discard block |
||
| 1525 | 1525 | * @return int |
| 1526 | 1526 | */ |
| 1527 | 1527 | public static function getExpireInterval() { |
| 1528 | - return (int)\OC::$server->getConfig()->getAppValue('core', 'shareapi_expire_after_n_days', '7'); |
|
| 1528 | + return (int) \OC::$server->getConfig()->getAppValue('core', 'shareapi_expire_after_n_days', '7'); |
|
| 1529 | 1529 | } |
| 1530 | 1530 | |
| 1531 | 1531 | /** |