aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCôme Chilliet <come.chilliet@nextcloud.com>2022-01-18 15:48:57 +0100
committerCôme Chilliet <come.chilliet@nextcloud.com>2022-01-24 11:16:44 +0100
commitb0e6a102639b4ed0439fe74b4ee0c363252d7223 (patch)
tree6afdf92e48ea1190819835f1cc895585d06c249e
parenta6eb7dc676dd18ad153fc920f9b13e802974c94f (diff)
downloadnextcloud-server-b0e6a102639b4ed0439fe74b4ee0c363252d7223.tar.gz
nextcloud-server-b0e6a102639b4ed0439fe74b4ee0c363252d7223.zip
Use the new function in user:setting occ command
instead of direct database queries Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
-rw-r--r--core/Command/User/Setting.php28
-rw-r--r--core/register_command.php2
2 files changed, 8 insertions, 22 deletions
diff --git a/core/Command/User/Setting.php b/core/Command/User/Setting.php
index 04488cdeff1..87fb6905de9 100644
--- a/core/Command/User/Setting.php
+++ b/core/Command/User/Setting.php
@@ -27,7 +27,6 @@ namespace OC\Core\Command\User;
use OC\Core\Command\Base;
use OCP\IConfig;
-use OCP\IDBConnection;
use OCP\IUser;
use OCP\IUserManager;
use Symfony\Component\Console\Input\InputArgument;
@@ -42,19 +41,14 @@ class Setting extends Base {
/** @var IConfig */
protected $config;
- /** @var IDBConnection */
- protected $connection;
-
/**
* @param IUserManager $userManager
* @param IConfig $config
- * @param IDBConnection $connection
*/
- public function __construct(IUserManager $userManager, IConfig $config, IDBConnection $connection) {
+ public function __construct(IUserManager $userManager, IConfig $config) {
parent::__construct();
$this->userManager = $userManager;
$this->config = $config;
- $this->connection = $connection;
}
protected function configure() {
@@ -247,26 +241,18 @@ class Setting extends Base {
}
protected function getUserSettings($uid, $app) {
- $query = $this->connection->getQueryBuilder();
- $query->select('*')
- ->from('preferences')
- ->where($query->expr()->eq('userid', $query->createNamedParameter($uid)));
-
+ $settings = $this->config->getAllUserValues($uid);
if ($app !== '') {
- $query->andWhere($query->expr()->eq('appid', $query->createNamedParameter($app)));
- }
-
- $result = $query->execute();
- $settings = [];
- while ($row = $result->fetch()) {
- $settings[$row['appid']][$row['configkey']] = $row['configvalue'];
+ if (isset($settings[$app])) {
+ $settings = [$app => $settings[$app]];
+ } else {
+ $settings = [];
+ }
}
$user = $this->userManager->get($uid);
$settings['settings']['display_name'] = $user->getDisplayName();
- $result->closeCursor();
-
return $settings;
}
}
diff --git a/core/register_command.php b/core/register_command.php
index 3cff363e46f..c7d3b073b91 100644
--- a/core/register_command.php
+++ b/core/register_command.php
@@ -184,7 +184,7 @@ if (\OC::$server->getConfig()->getSystemValue('installed', false)) {
$application->add(new OC\Core\Command\User\LastSeen(\OC::$server->getUserManager()));
$application->add(\OC::$server->get(\OC\Core\Command\User\Report::class));
$application->add(new OC\Core\Command\User\ResetPassword(\OC::$server->getUserManager()));
- $application->add(new OC\Core\Command\User\Setting(\OC::$server->getUserManager(), \OC::$server->getConfig(), \OC::$server->getDatabaseConnection()));
+ $application->add(new OC\Core\Command\User\Setting(\OC::$server->getUserManager(), \OC::$server->getConfig()));
$application->add(new OC\Core\Command\User\ListCommand(\OC::$server->getUserManager(), \OC::$server->getGroupManager()));
$application->add(new OC\Core\Command\User\Info(\OC::$server->getUserManager(), \OC::$server->getGroupManager()));
$application->add(new OC\Core\Command\User\AddAppPassword(\OC::$server->get(\OCP\IUserManager::class), \OC::$server->get(\OC\Authentication\Token\IProvider::class), \OC::$server->get(\OCP\Security\ISecureRandom::class), \OC::$server->get(\OCP\Security\ICrypto::class)));