From b0e6a102639b4ed0439fe74b4ee0c363252d7223 Mon Sep 17 00:00:00 2001 From: Côme Chilliet Date: Tue, 18 Jan 2022 15:48:57 +0100 Subject: Use the new function in user:setting occ command MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit instead of direct database queries Signed-off-by: Côme Chilliet --- core/Command/User/Setting.php | 28 +++++++--------------------- 1 file changed, 7 insertions(+), 21 deletions(-) (limited to 'core/Command') 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; } } -- cgit v1.2.3