aboutsummaryrefslogtreecommitdiffstats
path: root/apps/files_external/lib/Service/UserStoragesService.php
diff options
context:
space:
mode:
Diffstat (limited to 'apps/files_external/lib/Service/UserStoragesService.php')
-rw-r--r--apps/files_external/lib/Service/UserStoragesService.php48
1 files changed, 18 insertions, 30 deletions
diff --git a/apps/files_external/lib/Service/UserStoragesService.php b/apps/files_external/lib/Service/UserStoragesService.php
index 9a1e4e648b3..9d4192734b6 100644
--- a/apps/files_external/lib/Service/UserStoragesService.php
+++ b/apps/files_external/lib/Service/UserStoragesService.php
@@ -1,37 +1,16 @@
<?php
+
/**
- * @copyright Copyright (c) 2016, ownCloud, Inc.
- *
- * @author Joas Schilling <coding@schilljs.com>
- * @author Morris Jobke <hey@morrisjobke.de>
- * @author Robin Appelman <robin@icewind.nl>
- * @author Robin McCorkell <robin@mccorkell.me.uk>
- * @author Roeland Jago Douma <roeland@famdouma.nl>
- * @author Stefan Weil <sw@weilnetz.de>
- * @author szaimen <szaimen@e.mail.de>
- * @author Vincent Petry <vincent@nextcloud.com>
- *
- * @license AGPL-3.0
- *
- * This code is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License, version 3,
- * as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License, version 3,
- * along with this program. If not, see <http://www.gnu.org/licenses/>
- *
+ * SPDX-FileCopyrightText: 2018-2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
+ * SPDX-License-Identifier: AGPL-3.0-only
*/
namespace OCA\Files_External\Service;
use OC\Files\Filesystem;
use OCA\Files_External\Lib\StorageConfig;
+use OCA\Files_External\MountConfig;
use OCA\Files_External\NotFoundException;
-
use OCP\EventDispatcher\IEventDispatcher;
use OCP\Files\Config\IUserMountCache;
use OCP\IUserSession;
@@ -57,7 +36,7 @@ class UserStoragesService extends StoragesService {
DBConfigService $dbConfig,
IUserSession $userSession,
IUserMountCache $userMountCache,
- IEventDispatcher $eventDispatcher
+ IEventDispatcher $eventDispatcher,
) {
$this->userSession = $userSession;
parent::__construct($backendService, $dbConfig, $userMountCache, $eventDispatcher);
@@ -81,7 +60,7 @@ class UserStoragesService extends StoragesService {
$this->triggerApplicableHooks(
$signal,
$storage->getMountPoint(),
- \OCA\Files_External\MountConfig::MOUNT_TYPE_USER,
+ MountConfig::MOUNT_TYPE_USER,
[$user]
);
}
@@ -103,7 +82,7 @@ class UserStoragesService extends StoragesService {
}
protected function getType() {
- return DBConfigService::MOUNT_TYPE_PERSONAl;
+ return DBConfigService::MOUNT_TYPE_PERSONAL;
}
/**
@@ -127,6 +106,9 @@ class UserStoragesService extends StoragesService {
* @throws NotFoundException if the given storage does not exist in the config
*/
public function updateStorage(StorageConfig $updatedStorage) {
+ // verify ownership through $this->isApplicable() and otherwise throws an exception
+ $this->getStorage($updatedStorage->getId());
+
$updatedStorage->setApplicableUsers([$this->getUser()->getUID()]);
return parent::updateStorage($updatedStorage);
}
@@ -141,6 +123,12 @@ class UserStoragesService extends StoragesService {
}
protected function isApplicable(StorageConfig $config) {
- return ($config->getApplicableUsers() === [$this->getUser()->getUID()]) && $config->getType() === StorageConfig::MOUNT_TYPE_PERSONAl;
+ return ($config->getApplicableUsers() === [$this->getUser()->getUID()]) && $config->getType() === StorageConfig::MOUNT_TYPE_PERSONAL;
+ }
+
+ public function removeStorage($id) {
+ // verify ownership through $this->isApplicable() and otherwise throws an exception
+ $this->getStorage($id);
+ parent::removeStorage($id);
}
}