check parents resharing rights
Signed-off-by: Maxence Lange <maxence@artificial-owl.com>
This commit is contained in:
parent
2a17811caf
commit
236a293f6a
1 changed files with 14 additions and 6 deletions
|
@ -39,7 +39,6 @@ use OCP\AppFramework\OCS\OCSNotFoundException;
|
||||||
use OCP\AppFramework\OCSController;
|
use OCP\AppFramework\OCSController;
|
||||||
use OCP\AppFramework\QueryException;
|
use OCP\AppFramework\QueryException;
|
||||||
use OCP\Constants;
|
use OCP\Constants;
|
||||||
use OCP\Files\Folder;
|
|
||||||
use OCP\Files\Node;
|
use OCP\Files\Node;
|
||||||
use OCP\Files\NotFoundException;
|
use OCP\Files\NotFoundException;
|
||||||
use OCP\IConfig;
|
use OCP\IConfig;
|
||||||
|
@ -727,11 +726,10 @@ class ShareAPIController extends OCSController {
|
||||||
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)) {
|
if ($path !== null && !$resharingRight && $this->shareProviderResharingRights($this->currentUser, $share, $path)) {
|
||||||
$resharingRight = true;
|
$resharingRight = true;
|
||||||
}
|
}
|
||||||
|
} catch (\Exception $e) {
|
||||||
} catch (NotFoundException $e) {
|
|
||||||
//Ignore share
|
//Ignore share
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1119,15 +1117,25 @@ class ShareAPIController extends OCSController {
|
||||||
/**
|
/**
|
||||||
* Returns if we can find resharing rights in an IShare object for a specific user.
|
* Returns if we can find resharing rights in an IShare object for a specific user.
|
||||||
*
|
*
|
||||||
|
* @suppress PhanUndeclaredClassMethod
|
||||||
|
*
|
||||||
* @param string $userId
|
* @param string $userId
|
||||||
* @param IShare $share
|
* @param IShare $share
|
||||||
|
* @param Node $node
|
||||||
* @return bool
|
* @return bool
|
||||||
|
* @throws NotFoundException
|
||||||
|
* @throws \OCP\Files\InvalidPathException
|
||||||
*/
|
*/
|
||||||
private function shareProviderResharingRights(string $userId, IShare $share): bool {
|
private function shareProviderResharingRights(string $userId, IShare $share, Node $node): bool {
|
||||||
if ($share->getShareOwner() === $userId) {
|
if ($share->getShareOwner() === $userId) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// we check that current user have parent resharing rights on the current file
|
||||||
|
if (($node->getPermissions() & \OCP\Constants::PERMISSION_SHARE) !== 0) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
if ((\OCP\Constants::PERMISSION_SHARE & $share->getPermissions()) === 0) {
|
if ((\OCP\Constants::PERMISSION_SHARE & $share->getPermissions()) === 0) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue