diff options
Diffstat (limited to 'apps/files_sharing/lib')
-rw-r--r-- | apps/files_sharing/lib/AppInfo/Application.php | 9 | ||||
-rw-r--r-- | apps/files_sharing/lib/Controller/ShareAPIController.php | 50 |
2 files changed, 59 insertions, 0 deletions
diff --git a/apps/files_sharing/lib/AppInfo/Application.php b/apps/files_sharing/lib/AppInfo/Application.php index 48802617b4f..5a18cce8e49 100644 --- a/apps/files_sharing/lib/AppInfo/Application.php +++ b/apps/files_sharing/lib/AppInfo/Application.php @@ -278,6 +278,15 @@ class Application extends App { 'name' => $l->t('Deleted shares'), ]); + array_push($sharingSublistArray, [ + 'id' => 'pendingshares', + 'appname' => 'files_sharing', + 'script' => 'list.php', + 'order' => 19, + 'name' => $l->t('Pending shares'), + ]); + + // show_Quick_Access stored as string \OCA\Files\App::getNavigationManager()->add([ 'id' => 'shareoverview', diff --git a/apps/files_sharing/lib/Controller/ShareAPIController.php b/apps/files_sharing/lib/Controller/ShareAPIController.php index 906eb82221b..b71d3dac3a7 100644 --- a/apps/files_sharing/lib/Controller/ShareAPIController.php +++ b/apps/files_sharing/lib/Controller/ShareAPIController.php @@ -1081,6 +1081,56 @@ class ShareAPIController extends OCSController { /** * @NoAdminRequired + */ + public function pendingShares(): DataResponse { + $pendingShares = []; + + $shareTypes = [ + IShare::TYPE_USER, + IShare::TYPE_GROUP + ]; + + foreach ($shareTypes as $shareType) { + $shares = $this->shareManager->getSharedWith($this->currentUser, $shareType, null, -1, 0); + + foreach ($shares as $share) { + if ($share->getStatus() === IShare::STATUS_PENDING || $share->getStatus() === IShare::STATUS_REJECTED) { + $pendingShares[] = $share; + } + } + } + + $result = array_filter(array_map(function (IShare $share) { + $userFolder = $this->rootFolder->getUserFolder($share->getSharedBy()); + $nodes = $userFolder->getById($share->getNodeId()); + if (empty($nodes)) { + // fallback to guessing the path + $node = $userFolder->get($share->getTarget()); + if ($node === null || $share->getTarget() === '') { + return null; + } + } else { + $node = $nodes[0]; + } + + try { + $formattedShare = $this->formatShare($share, $node); + $formattedShare['status'] = $share->getStatus(); + $formattedShare['path'] = $share->getNode()->getName(); + $formattedShare['permissions'] = 0; + return $formattedShare; + } catch (NotFoundException $e) { + return null; + } + }, $pendingShares), function ($entry) { + return $entry !== null; + }); + + return new DataResponse($result); + } + + /** + * @NoAdminRequired * * @param string $id * @return DataResponse |