|
|
|
@ -342,6 +342,46 @@ class Share20OCS { |
|
|
|
return new \OC_OCS_Result($formatted); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* @param \OCP\Files\Folder $folder |
|
|
|
* @return \OC_OCS_Result |
|
|
|
*/ |
|
|
|
private function getSharesInDir($folder) { |
|
|
|
if (!($folder instanceof \OCP\Files\Folder)) { |
|
|
|
return new \OC_OCS_Result(null, 400, "not a directory"); |
|
|
|
} |
|
|
|
|
|
|
|
$nodes = $folder->getDirectoryListing(); |
|
|
|
/** @var IShare[] $shares */ |
|
|
|
$shares = []; |
|
|
|
foreach ($nodes as $node) { |
|
|
|
$userShares = array_merge($shares, $this->shareManager->getSharesBy($this->currentUser, \OCP\Share::SHARE_TYPE_USER, $node, false, -1, 0)); |
|
|
|
$groupShares = array_merge($shares, $this->shareManager->getSharesBy($this->currentUser, \OCP\Share::SHARE_TYPE_GROUP, $node, false, -1, 0)); |
|
|
|
$linkShares = array_merge($shares, $this->shareManager->getSharesBy($this->currentUser, \OCP\Share::SHARE_TYPE_LINK, $node, false, -1, 0)); |
|
|
|
//TODO: Add federated shares
|
|
|
|
|
|
|
|
$shares = array_merge($shares, $userShares, $groupShares, $linkShares); |
|
|
|
} |
|
|
|
|
|
|
|
$formatted = []; |
|
|
|
foreach ($shares as $share) { |
|
|
|
$formatted[] = $this->formatShare($share); |
|
|
|
} |
|
|
|
|
|
|
|
return new \OC_OCS_Result($formatted); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* The getShares function. |
|
|
|
* |
|
|
|
* - Get shares by the current user |
|
|
|
* - Get shares by the current user and reshares (?reshares=true) |
|
|
|
* - Get shares with the current user (?shared_with_me=true) |
|
|
|
* - Get shares for a specific path (?path=...) |
|
|
|
* - Get all shares in a folder (?subfiles=true&path=..) |
|
|
|
* |
|
|
|
* @return \OC_OCS_Result |
|
|
|
*/ |
|
|
|
public function getShares() { |
|
|
|
$sharedWithMe = $this->request->getParam('shared_with_me', null); |
|
|
|
$reshares = $this->request->getParam('reshares', null); |
|
|
|
@ -361,6 +401,10 @@ class Share20OCS { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
if ($subfiles === 'true') { |
|
|
|
return $this->getSharesInDir($path); |
|
|
|
} |
|
|
|
|
|
|
|
if ($reshares === 'true') { |
|
|
|
$reshares = true; |
|
|
|
} else { |
|
|
|
|