|
@@ -172,7 +172,7 @@ discard block |
|
|
block discarded – undo |
|
172
|
172
|
// for backward compatibility make sure that the remote url stored in the |
|
173
|
173
|
// database ends with a trailing slash |
|
174
|
174
|
if (substr($remote, -1) !== '/') { |
|
175
|
|
- $remote = $remote . '/'; |
|
|
175
|
+ $remote = $remote.'/'; |
|
176
|
176
|
} |
|
177
|
177
|
|
|
178
|
178
|
$token = $share->getShareSecret(); |
|
@@ -200,23 +200,23 @@ discard block |
|
|
block discarded – undo |
|
200
|
200
|
|
|
201
|
201
|
// FIXME this should be a method in the user management instead |
|
202
|
202
|
if ($shareType === Share::SHARE_TYPE_USER) { |
|
203
|
|
- $this->logger->debug('shareWith before, ' . $shareWith, ['app' => 'files_sharing']); |
|
|
203
|
+ $this->logger->debug('shareWith before, '.$shareWith, ['app' => 'files_sharing']); |
|
204
|
204
|
Util::emitHook( |
|
205
|
205
|
'\OCA\Files_Sharing\API\Server2Server', |
|
206
|
206
|
'preLoginNameUsedAsUserName', |
|
207
|
207
|
array('uid' => &$shareWith) |
|
208
|
208
|
); |
|
209
|
|
- $this->logger->debug('shareWith after, ' . $shareWith, ['app' => 'files_sharing']); |
|
|
209
|
+ $this->logger->debug('shareWith after, '.$shareWith, ['app' => 'files_sharing']); |
|
210
|
210
|
|
|
211
|
211
|
if (!$this->userManager->userExists($shareWith)) { |
|
212
|
|
- throw new ProviderCouldNotAddShareException('User does not exists', '',Http::STATUS_BAD_REQUEST); |
|
|
212
|
+ throw new ProviderCouldNotAddShareException('User does not exists', '', Http::STATUS_BAD_REQUEST); |
|
213
|
213
|
} |
|
214
|
214
|
|
|
215
|
215
|
\OC_Util::setupFS($shareWith); |
|
216
|
216
|
} |
|
217
|
217
|
|
|
218
|
218
|
if ($shareType === Share::SHARE_TYPE_GROUP && !$this->groupManager->groupExists($shareWith)) { |
|
219
|
|
- throw new ProviderCouldNotAddShareException('Group does not exists', '',Http::STATUS_BAD_REQUEST); |
|
|
219
|
+ throw new ProviderCouldNotAddShareException('Group does not exists', '', Http::STATUS_BAD_REQUEST); |
|
220
|
220
|
} |
|
221
|
221
|
|
|
222
|
222
|
$externalManager = new \OCA\Files_Sharing\External\Manager( |
|
@@ -234,7 +234,7 @@ discard block |
|
|
block discarded – undo |
|
234
|
234
|
); |
|
235
|
235
|
|
|
236
|
236
|
try { |
|
237
|
|
- $externalManager->addShare($remote, $token, '', $name, $owner, $shareType,false, $shareWith, $remoteId); |
|
|
237
|
+ $externalManager->addShare($remote, $token, '', $name, $owner, $shareType, false, $shareWith, $remoteId); |
|
238
|
238
|
$shareId = \OC::$server->getDatabaseConnection()->lastInsertId('*PREFIX*share_external'); |
|
239
|
239
|
|
|
240
|
240
|
if ($shareType === Share::SHARE_TYPE_USER) { |
|
@@ -243,7 +243,7 @@ discard block |
|
|
block discarded – undo |
|
243
|
243
|
->setType('remote_share') |
|
244
|
244
|
->setSubject(RemoteShares::SUBJECT_REMOTE_SHARE_RECEIVED, [$ownerFederatedId, trim($name, '/')]) |
|
245
|
245
|
->setAffectedUser($shareWith) |
|
246
|
|
- ->setObject('remote_share', (int)$shareId, $name); |
|
|
246
|
+ ->setObject('remote_share', (int) $shareId, $name); |
|
247
|
247
|
\OC::$server->getActivityManager()->publish($event); |
|
248
|
248
|
$this->notifyAboutNewShare($shareWith, $shareId, $ownerFederatedId, $sharedByFederatedId, $name, $sharedBy, $owner); |
|
249
|
249
|
} else { |
|
@@ -254,7 +254,7 @@ discard block |
|
|
block discarded – undo |
|
254
|
254
|
->setType('remote_share') |
|
255
|
255
|
->setSubject(RemoteShares::SUBJECT_REMOTE_SHARE_RECEIVED, [$ownerFederatedId, trim($name, '/')]) |
|
256
|
256
|
->setAffectedUser($user->getUID()) |
|
257
|
|
- ->setObject('remote_share', (int)$shareId, $name); |
|
|
257
|
+ ->setObject('remote_share', (int) $shareId, $name); |
|
258
|
258
|
\OC::$server->getActivityManager()->publish($event); |
|
259
|
259
|
$this->notifyAboutNewShare($user->getUID(), $shareId, $ownerFederatedId, $sharedByFederatedId, $name, $sharedBy, $owner); |
|
260
|
260
|
} |
|
@@ -266,7 +266,7 @@ discard block |
|
|
block discarded – undo |
|
266
|
266
|
'level' => ILogger::ERROR, |
|
267
|
267
|
'app' => 'files_sharing' |
|
268
|
268
|
]); |
|
269
|
|
- throw new ProviderCouldNotAddShareException('internal server error, was not able to add share from ' . $remote, '', HTTP::STATUS_INTERNAL_SERVER_ERROR); |
|
|
269
|
+ throw new ProviderCouldNotAddShareException('internal server error, was not able to add share from '.$remote, '', HTTP::STATUS_INTERNAL_SERVER_ERROR); |
|
270
|
270
|
} |
|
271
|
271
|
} |
|
272
|
272
|
|
|
@@ -343,12 +343,12 @@ discard block |
|
|
block discarded – undo |
|
343
|
343
|
|
|
344
|
344
|
$declineAction = $notification->createAction(); |
|
345
|
345
|
$declineAction->setLabel('decline') |
|
346
|
|
- ->setLink($this->urlGenerator->getAbsoluteURL($this->urlGenerator->linkTo('', 'ocs/v2.php/apps/files_sharing/api/v1/remote_shares/pending/' . $shareId)), 'DELETE'); |
|
|
346
|
+ ->setLink($this->urlGenerator->getAbsoluteURL($this->urlGenerator->linkTo('', 'ocs/v2.php/apps/files_sharing/api/v1/remote_shares/pending/'.$shareId)), 'DELETE'); |
|
347
|
347
|
$notification->addAction($declineAction); |
|
348
|
348
|
|
|
349
|
349
|
$acceptAction = $notification->createAction(); |
|
350
|
350
|
$acceptAction->setLabel('accept') |
|
351
|
|
- ->setLink($this->urlGenerator->getAbsoluteURL($this->urlGenerator->linkTo('', 'ocs/v2.php/apps/files_sharing/api/v1/remote_shares/pending/' . $shareId)), 'POST'); |
|
|
351
|
+ ->setLink($this->urlGenerator->getAbsoluteURL($this->urlGenerator->linkTo('', 'ocs/v2.php/apps/files_sharing/api/v1/remote_shares/pending/'.$shareId)), 'POST'); |
|
352
|
352
|
$notification->addAction($acceptAction); |
|
353
|
353
|
|
|
354
|
354
|
$this->notificationManager->notify($notification); |
|
@@ -408,7 +408,7 @@ discard block |
|
|
block discarded – undo |
|
408
|
408
|
*/ |
|
409
|
409
|
protected function executeAcceptShare(IShare $share) { |
|
410
|
410
|
try { |
|
411
|
|
- $fileId = (int)$share->getNode()->getId(); |
|
|
411
|
+ $fileId = (int) $share->getNode()->getId(); |
|
412
|
412
|
list($file, $link) = $this->getFile($this->getCorrectUid($share), $fileId); |
|
413
|
413
|
} catch (\Exception $e) { |
|
414
|
414
|
throw new ShareNotFound(); |
|
@@ -486,7 +486,7 @@ discard block |
|
|
block discarded – undo |
|
486
|
486
|
$this->federatedShareProvider->removeShareFromTable($share); |
|
487
|
487
|
|
|
488
|
488
|
try { |
|
489
|
|
- $fileId = (int)$share->getNode()->getId(); |
|
|
489
|
+ $fileId = (int) $share->getNode()->getId(); |
|
490
|
490
|
list($file, $link) = $this->getFile($this->getCorrectUid($share), $fileId); |
|
491
|
491
|
} catch (\Exception $e) { |
|
492
|
492
|
throw new ShareNotFound(); |
|
@@ -581,10 +581,10 @@ discard block |
|
|
block discarded – undo |
|
581
|
581
|
// delete all child in case of a group share |
|
582
|
582
|
$qb = $this->connection->getQueryBuilder(); |
|
583
|
583
|
$qb->delete('share_external') |
|
584
|
|
- ->where($qb->expr()->eq('parent', $qb->createNamedParameter((int)$share['id']))); |
|
|
584
|
+ ->where($qb->expr()->eq('parent', $qb->createNamedParameter((int) $share['id']))); |
|
585
|
585
|
$qb->execute(); |
|
586
|
586
|
|
|
587
|
|
- if ((int)$share['share_type'] === Share::SHARE_TYPE_USER) { |
|
|
587
|
+ if ((int) $share['share_type'] === Share::SHARE_TYPE_USER) { |
|
588
|
588
|
if ($share['accepted']) { |
|
589
|
589
|
$path = trim($mountpoint, '/'); |
|
590
|
590
|
} else { |
|
@@ -593,7 +593,7 @@ discard block |
|
|
block discarded – undo |
|
593
|
593
|
$notification = $this->notificationManager->createNotification(); |
|
594
|
594
|
$notification->setApp('files_sharing') |
|
595
|
595
|
->setUser($share['user']) |
|
596
|
|
- ->setObject('remote_share', (int)$share['id']); |
|
|
596
|
+ ->setObject('remote_share', (int) $share['id']); |
|
597
|
597
|
$this->notificationManager->markProcessed($notification); |
|
598
|
598
|
|
|
599
|
599
|
$event = $this->activityManager->generateEvent(); |
|
@@ -601,7 +601,7 @@ discard block |
|
|
block discarded – undo |
|
601
|
601
|
->setType('remote_share') |
|
602
|
602
|
->setSubject(RemoteShares::SUBJECT_REMOTE_SHARE_UNSHARED, [$owner->getId(), $path]) |
|
603
|
603
|
->setAffectedUser($user) |
|
604
|
|
- ->setObject('remote_share', (int)$share['id'], $path); |
|
|
604
|
+ ->setObject('remote_share', (int) $share['id'], $path); |
|
605
|
605
|
\OC::$server->getActivityManager()->publish($event); |
|
606
|
606
|
} |
|
607
|
607
|
} |
|
@@ -650,7 +650,7 @@ discard block |
|
|
block discarded – undo |
|
650
|
650
|
$owner = $share->getShareOwner(); |
|
651
|
651
|
$currentServer = $this->addressHandler->generateRemoteURL(); |
|
652
|
652
|
if ($this->addressHandler->compareAddresses($user, $remote, $owner, $currentServer)) { |
|
653
|
|
- throw new ProviderCouldNotAddShareException('Resharing back to the owner is not allowed: ' . $id); |
|
|
653
|
+ throw new ProviderCouldNotAddShareException('Resharing back to the owner is not allowed: '.$id); |
|
654
|
654
|
} |
|
655
|
655
|
} catch (\Exception $e) { |
|
656
|
656
|
throw new ProviderCouldNotAddShareException($e->getMessage()); |
|
@@ -664,10 +664,10 @@ discard block |
|
|
block discarded – undo |
|
664
|
664
|
$share->setSharedBy($share->getSharedWith()); |
|
665
|
665
|
$share->setSharedWith($shareWith); |
|
666
|
666
|
$result = $this->federatedShareProvider->create($share); |
|
667
|
|
- $this->federatedShareProvider->storeRemoteId((int)$result->getId(), $senderId); |
|
|
667
|
+ $this->federatedShareProvider->storeRemoteId((int) $result->getId(), $senderId); |
|
668
|
668
|
return ['token' => $result->getToken(), 'providerId' => $result->getId()]; |
|
669
|
669
|
} else { |
|
670
|
|
- throw new ProviderCouldNotAddShareException('resharing not allowed for share: ' . $id); |
|
|
670
|
+ throw new ProviderCouldNotAddShareException('resharing not allowed for share: '.$id); |
|
671
|
671
|
} |
|
672
|
672
|
|
|
673
|
673
|
} |
|
@@ -713,7 +713,7 @@ discard block |
|
|
block discarded – undo |
|
713
|
713
|
*/ |
|
714
|
714
|
protected function ocmPermissions2ncPermissions(array $ocmPermissions) { |
|
715
|
715
|
$ncPermissions = 0; |
|
716
|
|
- foreach($ocmPermissions as $permission) { |
|
|
716
|
+ foreach ($ocmPermissions as $permission) { |
|
717
|
717
|
switch (strtolower($permission)) { |
|
718
|
718
|
case 'read': |
|
719
|
719
|
$ncPermissions += Constants::PERMISSION_READ; |