aboutsummaryrefslogtreecommitdiffstats
path: root/apps/files_external/lib/Service/DBConfigService.php
diff options
context:
space:
mode:
Diffstat (limited to 'apps/files_external/lib/Service/DBConfigService.php')
-rw-r--r--apps/files_external/lib/Service/DBConfigService.php90
1 files changed, 28 insertions, 62 deletions
diff --git a/apps/files_external/lib/Service/DBConfigService.php b/apps/files_external/lib/Service/DBConfigService.php
index f6446eea363..41ec4512d70 100644
--- a/apps/files_external/lib/Service/DBConfigService.php
+++ b/apps/files_external/lib/Service/DBConfigService.php
@@ -1,29 +1,9 @@
<?php
+
/**
- * @copyright Copyright (c) 2016, ownCloud, Inc.
- *
- * @author Arthur Schiwon <blizzz@arthur-schiwon.de>
- * @author Christoph Wurst <christoph@winzerhof-wurst.at>
- * @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>
- *
- * @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;
@@ -37,38 +17,21 @@ use OCP\Security\ICrypto;
*/
class DBConfigService {
public const MOUNT_TYPE_ADMIN = 1;
+ public const MOUNT_TYPE_PERSONAL = 2;
+ /** @deprecated use MOUNT_TYPE_PERSONAL (full uppercase) instead */
public const MOUNT_TYPE_PERSONAl = 2;
public const APPLICABLE_TYPE_GLOBAL = 1;
public const APPLICABLE_TYPE_GROUP = 2;
public const APPLICABLE_TYPE_USER = 3;
- /**
- * @var IDBConnection
- */
- private $connection;
-
- /**
- * @var ICrypto
- */
- private $crypto;
-
- /**
- * DBConfigService constructor.
- *
- * @param IDBConnection $connection
- * @param ICrypto $crypto
- */
- public function __construct(IDBConnection $connection, ICrypto $crypto) {
- $this->connection = $connection;
- $this->crypto = $crypto;
+ public function __construct(
+ private IDBConnection $connection,
+ private ICrypto $crypto,
+ ) {
}
- /**
- * @param int $mountId
- * @return array
- */
- public function getMountById($mountId) {
+ public function getMountById(int $mountId): ?array {
$builder = $this->connection->getQueryBuilder();
$query = $builder->select(['mount_id', 'mount_point', 'storage_backend', 'auth_backend', 'priority', 'type'])
->from('external_mounts', 'm')
@@ -135,7 +98,7 @@ class DBConfigService {
)
)
->groupBy(['a.mount_id']);
- $stmt = $query->execute();
+ $stmt = $query->executeQuery();
$result = $stmt->fetchAll();
$stmt->closeCursor();
@@ -238,7 +201,7 @@ class DBConfigService {
public function getUserMountsFor($type, $value) {
$builder = $this->connection->getQueryBuilder();
$query = $this->getForQuery($builder, $type, $value);
- $query->andWhere($builder->expr()->eq('m.type', $builder->expr()->literal(self::MOUNT_TYPE_PERSONAl, IQueryBuilder::PARAM_INT)));
+ $query->andWhere($builder->expr()->eq('m.type', $builder->expr()->literal(self::MOUNT_TYPE_PERSONAL, IQueryBuilder::PARAM_INT)));
return $this->getMountsFromQuery($query);
}
@@ -266,7 +229,7 @@ class DBConfigService {
'priority' => $builder->createNamedParameter($priority, IQueryBuilder::PARAM_INT),
'type' => $builder->createNamedParameter($type, IQueryBuilder::PARAM_INT)
]);
- $query->execute();
+ $query->executeStatement();
return $query->getLastInsertId();
}
@@ -279,19 +242,22 @@ class DBConfigService {
$builder = $this->connection->getQueryBuilder();
$query = $builder->delete('external_mounts')
->where($builder->expr()->eq('mount_id', $builder->createNamedParameter($mountId, IQueryBuilder::PARAM_INT)));
- $query->execute();
+ $query->executeStatement();
+ $builder = $this->connection->getQueryBuilder();
$query = $builder->delete('external_applicable')
->where($builder->expr()->eq('mount_id', $builder->createNamedParameter($mountId, IQueryBuilder::PARAM_INT)));
- $query->execute();
+ $query->executeStatement();
+ $builder = $this->connection->getQueryBuilder();
$query = $builder->delete('external_config')
->where($builder->expr()->eq('mount_id', $builder->createNamedParameter($mountId, IQueryBuilder::PARAM_INT)));
- $query->execute();
+ $query->executeStatement();
+ $builder = $this->connection->getQueryBuilder();
$query = $builder->delete('external_options')
->where($builder->expr()->eq('mount_id', $builder->createNamedParameter($mountId, IQueryBuilder::PARAM_INT)));
- $query->execute();
+ $query->executeStatement();
}
/**
@@ -305,7 +271,7 @@ class DBConfigService {
->set('mount_point', $builder->createNamedParameter($newMountPoint))
->where($builder->expr()->eq('mount_id', $builder->createNamedParameter($mountId, IQueryBuilder::PARAM_INT)));
- $query->execute();
+ $query->executeStatement();
}
/**
@@ -319,7 +285,7 @@ class DBConfigService {
->set('auth_backend', $builder->createNamedParameter($newAuthBackend))
->where($builder->expr()->eq('mount_id', $builder->createNamedParameter($mountId, IQueryBuilder::PARAM_INT)));
- $query->execute();
+ $query->executeStatement();
}
/**
@@ -345,7 +311,7 @@ class DBConfigService {
->set('value', $builder->createNamedParameter($value, IQueryBuilder::PARAM_STR))
->where($builder->expr()->eq('mount_id', $builder->createNamedParameter($mountId, IQueryBuilder::PARAM_INT)))
->andWhere($builder->expr()->eq('key', $builder->createNamedParameter($key, IQueryBuilder::PARAM_STR)));
- $query->execute();
+ $query->executeStatement();
}
}
@@ -368,7 +334,7 @@ class DBConfigService {
->set('value', $builder->createNamedParameter(json_encode($value), IQueryBuilder::PARAM_STR))
->where($builder->expr()->eq('mount_id', $builder->createNamedParameter($mountId, IQueryBuilder::PARAM_INT)))
->andWhere($builder->expr()->eq('key', $builder->createNamedParameter($key, IQueryBuilder::PARAM_STR)));
- $query->execute();
+ $query->executeStatement();
}
}
@@ -397,11 +363,11 @@ class DBConfigService {
$query = $query->andWhere($builder->expr()->eq('value', $builder->createNamedParameter($value, IQueryBuilder::PARAM_STR)));
}
- $query->execute();
+ $query->executeStatement();
}
private function getMountsFromQuery(IQueryBuilder $query) {
- $result = $query->execute();
+ $result = $query->executeQuery();
$mounts = $result->fetchAll();
$uniqueMounts = [];
foreach ($mounts as $mount) {
@@ -452,7 +418,7 @@ class DBConfigService {
->from($table)
->where($builder->expr()->in('mount_id', $placeHolders));
- $result = $query->execute();
+ $result = $query->executeQuery();
$rows = $result->fetchAll();
$result->closeCursor();