Skip to content

Commit

Permalink
Update shares_find to also find files shared with the current user
Browse files Browse the repository at this point in the history
  • Loading branch information
Raudius committed Jul 15, 2023
1 parent 6781a59 commit 66cfb77
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
],
"require": {
"php": "^7.4",
"raudius/phpdf": "^1.0.3",
"ext-json": "*",
"ext-lua": "*",
"ext-curl": "*",
Expand All @@ -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",
Expand Down
4 changes: 2 additions & 2 deletions docs/Functions.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
8 changes: 6 additions & 2 deletions lib/Interpreter/Functions/Nextcloud/Shares_Find.php
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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);
}
Expand Down

0 comments on commit 66cfb77

Please sign in to comment.