From 66cfb77c5a0caabaee30f39730bb9d92505e7641 Mon Sep 17 00:00:00 2001 From: Raul Ferreira Date: Sat, 15 Jul 2023 23:49:26 +0200 Subject: [PATCH] Update shares_find to also find files shared with the current user --- composer.json | 4 ++-- docs/Functions.md | 4 ++-- lib/Interpreter/Functions/Nextcloud/Shares_Find.php | 8 ++++++-- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/composer.json b/composer.json index 644d718..852b839 100755 --- a/composer.json +++ b/composer.json @@ -10,7 +10,6 @@ ], "require": { "php": "^7.4", - "raudius/phpdf": "^1.0.3", "ext-json": "*", "ext-lua": "*", "ext-curl": "*", @@ -19,7 +18,8 @@ "mustache/mustache": "^2.14", "php-ffmpeg/php-ffmpeg": "0.19.0", "mikehaertl/php-shellcommand": "^1", - "raudius/luar": "^0.1.3" + "raudius/phpdf": "^1.0.3", + "raudius/luar": "^0.1.4" }, "require-dev": { "phpunit/phpunit": "^9.3.11", diff --git a/docs/Functions.md b/docs/Functions.md index c858c52..201962f 100644 --- a/docs/Functions.md +++ b/docs/Functions.md @@ -402,9 +402,9 @@ share_file(file, { ``` ### shares_find -`shares_find(Node|nil node= nil, Int[] share_types): Share[]` +`shares_find(Node|nil node=nil, Int[] share_types): Share[]` -Finds shares created by the current user. If a node is given it finds shares for that Node. It is also possible to specify +Finds shares created by, or shared with, the current user. If a node is given it finds shares for that Node. It is also possible to specify which [share types](#share-types) to search for. If `share_types` is omitted all types will be searched. A list of share objects are returned, share objects are Lua tables which contain the following keys: diff --git a/lib/Interpreter/Functions/Nextcloud/Shares_Find.php b/lib/Interpreter/Functions/Nextcloud/Shares_Find.php index cc4260c..132b52d 100644 --- a/lib/Interpreter/Functions/Nextcloud/Shares_Find.php +++ b/lib/Interpreter/Functions/Nextcloud/Shares_Find.php @@ -9,9 +9,9 @@ use OCA\FilesScripts\Interpreter\RegistrableFunction; /** - * `shares_find(Node|nil node= nil, Int[] share_types): Share[]` + * `shares_find(Node|nil node=nil, Int[] share_types): Share[]` * - * Finds shares created by the current user. If a node is given it finds shares for that Node. It is also possible to specify + * Finds shares created by, or shared with, the current user. If a node is given it finds shares for that Node. It is also possible to specify * which [share types](#share-types) to search for. If `share_types` is omitted all types will be searched. * * A list of share objects are returned, share objects are Lua tables which contain the following keys: @@ -81,7 +81,11 @@ public function run($nodeData=null, $shareTypes=null): array { $homeFolder = $this->getHomeFolder(); foreach ($shareTypes as $shareType) { $shares = $this->shareManager->getSharesBy($user->getUID(), $shareType, $node, false, -1, 0); + foreach ($shares as $share) { + $shareObjects[] = $this->serializeShare($share, $homeFolder); + } + $shares = $this->shareManager->getSharedWith($user->getUID(), $shareType, $node, false, -1, 0); foreach ($shares as $share) { $shareObjects[] = $this->serializeShare($share, $homeFolder); }