shares are displayed to users with resharing rights
Signed-off-by: Maxence Lange <maxence@artificial-owl.com>
This commit is contained in:
parent
f13c7dda1c
commit
68c44bb642
|
@ -720,14 +720,23 @@ class ShareAPIController extends OCSController {
|
||||||
}
|
}
|
||||||
|
|
||||||
$formatted = [];
|
$formatted = [];
|
||||||
|
$resharingRight = false;
|
||||||
foreach ($shares as $share) {
|
foreach ($shares as $share) {
|
||||||
try {
|
try {
|
||||||
$formatted[] = $this->formatShare($share, $path);
|
$formatted[] = $this->formatShare($share, $path);
|
||||||
|
if (!$resharingRight && $this->shareProviderResharingRights($this->currentUser, $share)) {
|
||||||
|
$resharingRight = true;
|
||||||
|
}
|
||||||
|
|
||||||
} catch (NotFoundException $e) {
|
} catch (NotFoundException $e) {
|
||||||
//Ignore share
|
//Ignore share
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!$resharingRight) {
|
||||||
|
$formatted = [];
|
||||||
|
}
|
||||||
|
|
||||||
if ($include_tags) {
|
if ($include_tags) {
|
||||||
$formatted = Helper::populateTags($formatted, 'file_source', \OC::$server->getTagManager());
|
$formatted = Helper::populateTags($formatted, 'file_source', \OC::$server->getTagManager());
|
||||||
}
|
}
|
||||||
|
@ -1102,4 +1111,33 @@ class ShareAPIController extends OCSController {
|
||||||
|
|
||||||
return $this->serverContainer->query('\OCA\Spreed\Share\Helper\ShareAPIController');
|
return $this->serverContainer->query('\OCA\Spreed\Share\Helper\ShareAPIController');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns if we can find resharing rights in an IShare object for a specific user.
|
||||||
|
*
|
||||||
|
* @param string $userId
|
||||||
|
* @param IShare $share
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
private function shareProviderResharingRights(string $userId, IShare $share): bool {
|
||||||
|
if ($share->getShareOwner() === $userId) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((\OCP\Constants::PERMISSION_SHARE & $share->getPermissions()) === 0) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($share->getShareType() === \OCP\Share::SHARE_TYPE_USER && $share->getSharedWith() === $userId) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($share->getShareType() === \OCP\Share::SHARE_TYPE_GROUP && $this->groupManager->isInGroup($userId, $share->getSharedWith())) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -617,6 +617,7 @@ class DefaultShareProvider implements IShareProvider {
|
||||||
/**
|
/**
|
||||||
* Reshares for this user are shares where they are the owner.
|
* Reshares for this user are shares where they are the owner.
|
||||||
*/
|
*/
|
||||||
|
if ($node === null) {
|
||||||
if ($reshares === false) {
|
if ($reshares === false) {
|
||||||
$qb->andWhere($qb->expr()->eq('uid_initiator', $qb->createNamedParameter($userId)));
|
$qb->andWhere($qb->expr()->eq('uid_initiator', $qb->createNamedParameter($userId)));
|
||||||
} else {
|
} else {
|
||||||
|
@ -627,8 +628,7 @@ class DefaultShareProvider implements IShareProvider {
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
if ($node !== null) {
|
|
||||||
$qb->andWhere($qb->expr()->eq('file_source', $qb->createNamedParameter($node->getId())));
|
$qb->andWhere($qb->expr()->eq('file_source', $qb->createNamedParameter($node->getId())));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue