prevent download on user shares according to the share download permission
Signed-off-by: Julien Veyssier <eneiluj@posteo.net>
This commit is contained in:
Родитель
c6dff61a27
Коммит
6f904ca04b
|
@ -22,6 +22,7 @@
|
|||
namespace OCA\Richdocuments;
|
||||
|
||||
use OC\Files\Filesystem;
|
||||
use OCA\Files_Sharing\SharedStorage;
|
||||
use OCA\Richdocuments\Db\Direct;
|
||||
use OCA\Richdocuments\Db\WopiMapper;
|
||||
use OCA\Richdocuments\Db\Wopi;
|
||||
|
@ -147,6 +148,25 @@ class TokenManager {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
// disable download if at least one shared access has it disabled
|
||||
|
||||
foreach ($files as $file) {
|
||||
$storage = $file->getStorage();
|
||||
// using string as we have no guarantee that "files_sharing" app is loaded
|
||||
if ($storage->instanceOfStorage(SharedStorage::class)) {
|
||||
if (!method_exists(SharedStorage::class, 'getAttributes')) {
|
||||
break;
|
||||
}
|
||||
/** @var SharedStorage $storage */
|
||||
$share = $storage->getShare();
|
||||
$canDownload = $share->getAttributes()->getAttribute('permissions', 'download');
|
||||
if ($canDownload !== null && !$canDownload) {
|
||||
$hideDownload = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
throw $e;
|
||||
}
|
||||
|
|
|
@ -17,6 +17,12 @@ namespace Doctrine\DBAL\Platforms {
|
|||
class SqlitePlatform {}
|
||||
}
|
||||
|
||||
namespace OCA\Files_Sharing {
|
||||
use \OCP\Share\IShare;
|
||||
class SharedStorage {
|
||||
public function getShare(): IShare {}
|
||||
}
|
||||
}
|
||||
|
||||
namespace OCA\Files_Sharing\Event {
|
||||
use \OCP\Share\IShare;
|
||||
|
|
Загрузка…
Ссылка в новой задаче