From d2cbc6fe4e9a6882e3b1d92f768773811ea8ed5e Mon Sep 17 00:00:00 2001 From: Arne Hamann Date: Sun, 25 Jun 2023 12:38:19 +0200 Subject: [PATCH 1/2] Hides map link, when there are no read permissions Signed-off-by: Arne Hamann --- src/models/copyMapsLinkAction.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/models/copyMapsLinkAction.js b/src/models/copyMapsLinkAction.js index 8d1d1a04f..2e0fff3df 100644 --- a/src/models/copyMapsLinkAction.js +++ b/src/models/copyMapsLinkAction.js @@ -40,7 +40,7 @@ export default class CopyMapsLinkAction { data({ share, fileInfo }) { this._share = share return { - is: NcActionButton, + is: share.hasReadPermission ? NcActionButton : null, ariaLabel: t('maps', 'Copy link to map'), icon: 'icon-clippy', title: t('maps', 'Copy link to map'), From 1e2df2e11dbc319cdb37feddfb7547a74d380aa5 Mon Sep 17 00:00:00 2001 From: Arne Hamann Date: Sun, 25 Jun 2023 13:07:33 +0200 Subject: [PATCH 2/2] Disable my maps when there are no read permissions (disables favorite drop maps) Signed-off-by: Arne Hamann --- lib/Controller/PublicPageController.php | 6 ++++++ lib/Controller/PublicUtilsController.php | 6 +++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/lib/Controller/PublicPageController.php b/lib/Controller/PublicPageController.php index c0de3b387..437a36cc9 100644 --- a/lib/Controller/PublicPageController.php +++ b/lib/Controller/PublicPageController.php @@ -98,6 +98,12 @@ private function validateShare(\OCP\Share\IShare $share) { return false; } + //Disable mymaps on file-drop links + $isReadable = ($share->getPermissions() & (1 << 0)); + if (!$isReadable) { + return false; + } + return $share->getNode()->isReadable() && $share->getNode()->isShareable(); } diff --git a/lib/Controller/PublicUtilsController.php b/lib/Controller/PublicUtilsController.php index 197bb7b34..58699a5c7 100644 --- a/lib/Controller/PublicUtilsController.php +++ b/lib/Controller/PublicUtilsController.php @@ -177,6 +177,10 @@ public function getOptionsValues(): DataResponse { $share = $this->getShare(); $permissions = $share->getPermissions(); $folder = $this->getShareNode(); + $isReadable = ($permissions & (1 << 0)) && $folder->isReadable(); + if (!$isReadable) { + throw new NotPermittedException(); + } $isCreatable = ($permissions & (1 << 2)) && $folder->isCreatable(); try { $file=$folder->get(".index.maps"); @@ -190,7 +194,7 @@ public function getOptionsValues(): DataResponse { $ov = json_decode($file->getContent(),true, 512); // Maps content can be read mostly from the folder - $ov['isReadable'] = ($permissions & (1 << 0)) && $folder->isReadable(); + $ov['isReadable'] = $isReadable; //Saving maps information in the file $ov['isUpdateable'] = ($permissions & (1 << 1)) && $file->isUpdateable(); $ov['isCreatable'] = ($permissions & (1 << 2)) && $folder->isCreatable();