diff options
author | John Molakvoæ <skjnldsv@users.noreply.github.com> | 2023-07-11 15:06:03 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-07-11 15:06:03 +0200 |
commit | 2cf8d6d9652a55f81c6800f2e69b71597736c56c (patch) | |
tree | 3e48463d8ebc3c01961243e8e6b1fc10a60133b7 /apps/files_sharing/lib | |
parent | 5c6ed30369f5c4edcf46e5e882c6096a7e3cd01e (diff) | |
parent | 74763e875737ea2bb0775194544a809041a2e7d6 (diff) | |
download | nextcloud-server-2cf8d6d9652a55f81c6800f2e69b71597736c56c.tar.gz nextcloud-server-2cf8d6d9652a55f81c6800f2e69b71597736c56c.zip |
Merge pull request #39196 from nextcloud/feat/f2v/sharing
Diffstat (limited to 'apps/files_sharing/lib')
4 files changed, 21 insertions, 77 deletions
diff --git a/apps/files_sharing/lib/AppInfo/Application.php b/apps/files_sharing/lib/AppInfo/Application.php index eff4a3ac5b7..946d82a3df7 100644 --- a/apps/files_sharing/lib/AppInfo/Application.php +++ b/apps/files_sharing/lib/AppInfo/Application.php @@ -117,7 +117,6 @@ class Application extends App implements IBootstrap { $context->injectFn([$this, 'registerMountProviders']); $context->injectFn([$this, 'registerEventsScripts']); $context->injectFn([$this, 'registerDownloadEvents']); - $context->injectFn([$this, 'setupSharingMenus']); Helper::registerHooks(); @@ -214,77 +213,4 @@ class Application extends App implements IBootstrap { } ); } - - public function setupSharingMenus(IManager $shareManager, IFactory $l10nFactory, IUserSession $userSession): void { - if (!$shareManager->shareApiEnabled() || !class_exists('\OCA\Files\App')) { - return; - } - - $navigationManager = \OCA\Files\App::getNavigationManager(); - // show_Quick_Access stored as string - $navigationManager->add(function () use ($shareManager, $l10nFactory, $userSession) { - $l = $l10nFactory->get('files_sharing'); - $user = $userSession->getUser(); - $userId = $user ? $user->getUID() : null; - - $sharingSublistArray = []; - - if ($shareManager->sharingDisabledForUser($userId) === false) { - $sharingSublistArray[] = [ - 'id' => 'sharingout', - 'appname' => 'files_sharing', - 'script' => 'list.php', - 'order' => 16, - 'name' => $l->t('Shared with others'), - ]; - } - - $sharingSublistArray[] = [ - 'id' => 'sharingin', - 'appname' => 'files_sharing', - 'script' => 'list.php', - 'order' => 15, - 'name' => $l->t('Shared with you'), - ]; - - if ($shareManager->sharingDisabledForUser($userId) === false) { - // Check if sharing by link is enabled - if ($shareManager->shareApiAllowLinks()) { - $sharingSublistArray[] = [ - 'id' => 'sharinglinks', - 'appname' => 'files_sharing', - 'script' => 'list.php', - 'order' => 17, - 'name' => $l->t('Shared by link'), - ]; - } - } - - $sharingSublistArray[] = [ - 'id' => 'deletedshares', - 'appname' => 'files_sharing', - 'script' => 'list.php', - 'order' => 19, - 'name' => $l->t('Deleted shares'), - ]; - - $sharingSublistArray[] = [ - 'id' => 'pendingshares', - 'appname' => 'files_sharing', - 'script' => 'list.php', - 'order' => 19, - 'name' => $l->t('Pending shares'), - ]; - - return [ - 'id' => 'shareoverview', - 'appname' => 'files_sharing', - 'script' => 'list.php', - 'order' => 18, - 'name' => $l->t('Shares'), - 'classes' => 'collapsible', - 'sublist' => $sharingSublistArray, - ]; - }); - } } diff --git a/apps/files_sharing/lib/Controller/DeletedShareAPIController.php b/apps/files_sharing/lib/Controller/DeletedShareAPIController.php index 19d1cbd0af6..33bd9eeb4cd 100644 --- a/apps/files_sharing/lib/Controller/DeletedShareAPIController.php +++ b/apps/files_sharing/lib/Controller/DeletedShareAPIController.php @@ -133,6 +133,8 @@ class DeletedShareAPIController extends OCSController { $result['file_source'] = $node->getId(); $result['file_parent'] = $node->getParent()->getId(); $result['file_target'] = $share->getTarget(); + $result['item_size'] = $node->getSize(); + $result['item_mtime'] = $node->getMTime(); $expiration = $share->getExpirationDate(); if ($expiration !== null) { diff --git a/apps/files_sharing/lib/Controller/ShareAPIController.php b/apps/files_sharing/lib/Controller/ShareAPIController.php index e2fb950dceb..5d5015cfca6 100644 --- a/apps/files_sharing/lib/Controller/ShareAPIController.php +++ b/apps/files_sharing/lib/Controller/ShareAPIController.php @@ -182,6 +182,11 @@ class ShareAPIController extends OCSController { $sharedBy = $this->userManager->get($share->getSharedBy()); $shareOwner = $this->userManager->get($share->getShareOwner()); + $isOwnShare = false; + if ($shareOwner !== null) { + $isOwnShare = $shareOwner->getUID() === $this->currentUser; + } + $result = [ 'id' => $share->getId(), 'share_type' => $share->getShareType(), @@ -225,6 +230,11 @@ class ShareAPIController extends OCSController { $result['item_type'] = 'file'; } + // Get the original node permission if the share owner is the current user + if ($isOwnShare) { + $result['item_permissions'] = $node->getPermissions(); + } + $result['mimetype'] = $node->getMimetype(); $result['has_preview'] = $this->previewManager->isAvailable($node); $result['storage_id'] = $node->getStorage()->getId(); @@ -233,6 +243,8 @@ class ShareAPIController extends OCSController { $result['file_source'] = $node->getId(); $result['file_parent'] = $node->getParent()->getId(); $result['file_target'] = $share->getTarget(); + $result['item_size'] = $node->getSize(); + $result['item_mtime'] = $node->getMTime(); $expiration = $share->getExpirationDate(); if ($expiration !== null) { @@ -1423,7 +1435,7 @@ class ShareAPIController extends OCSController { try { $formattedShare = $this->formatShare($share, $node); $formattedShare['status'] = $share->getStatus(); - $formattedShare['path'] = $share->getNode()->getName(); + $formattedShare['path'] = '/' . $share->getNode()->getName(); $formattedShare['permissions'] = 0; return $formattedShare; } catch (NotFoundException $e) { diff --git a/apps/files_sharing/lib/Listener/LoadAdditionalListener.php b/apps/files_sharing/lib/Listener/LoadAdditionalListener.php index 8c11fec3999..583cd575793 100644 --- a/apps/files_sharing/lib/Listener/LoadAdditionalListener.php +++ b/apps/files_sharing/lib/Listener/LoadAdditionalListener.php @@ -29,6 +29,7 @@ use OCA\Files_Sharing\AppInfo\Application; use OCA\Files\Event\LoadAdditionalScriptsEvent; use OCP\EventDispatcher\Event; use OCP\EventDispatcher\IEventListener; +use OCP\Share\IManager; use OCP\Util; class LoadAdditionalListener implements IEventListener { @@ -37,10 +38,13 @@ class LoadAdditionalListener implements IEventListener { return; } - // After files for the files list shared content - Util::addScript(Application::APP_ID, 'files_sharing', 'files'); // After files for the breadcrumb share indicator Util::addScript(Application::APP_ID, 'additionalScripts', 'files'); Util::addStyle(Application::APP_ID, 'icons'); + + $shareManager = \OC::$server->get(IManager::class); + if ($shareManager->shareApiEnabled() && class_exists('\OCA\Files\App')) { + Util::addScript(Application::APP_ID, 'files_sharing', 'files'); + } } } |