Skip to content

Commit 7484f00

Browse files
committed
fix(lexicon): using userconfig on value set in lexicon
Signed-off-by: Maxence Lange <[email protected]>
1 parent b39fb71 commit 7484f00

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

apps/provisioning_api/lib/Controller/UsersController.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212

1313
use InvalidArgumentException;
1414
use OC\Authentication\Token\RemoteWipe;
15+
use OC\Core\AppInfo\ConfigLexicon;
1516
use OC\Group\Group;
1617
use OC\KnownUser\KnownUserService;
1718
use OC\User\Backend;
@@ -32,6 +33,7 @@
3233
use OCP\AppFramework\OCS\OCSForbiddenException;
3334
use OCP\AppFramework\OCS\OCSNotFoundException;
3435
use OCP\AppFramework\OCSController;
36+
use OCP\Config\IUserConfig;
3537
use OCP\EventDispatcher\IEventDispatcher;
3638
use OCP\Files\IRootFolder;
3739
use OCP\Group\ISubAdmin;
@@ -81,6 +83,7 @@ public function __construct(
8183
private IEventDispatcher $eventDispatcher,
8284
private IPhoneNumberUtil $phoneNumberUtil,
8385
private IAppManager $appManager,
86+
private readonly IUserConfig $userConfig,
8487
) {
8588
parent::__construct(
8689
$appName,
@@ -1116,19 +1119,19 @@ public function editUser(string $userId, string $key, string $value): DataRespon
11161119
if (!in_array($value, $languagesCodes, true) && $value !== 'en') {
11171120
throw new OCSException($this->l10n->t('Invalid language'), 101);
11181121
}
1119-
$this->config->setUserValue($targetUser->getUID(), 'core', 'lang', $value);
1122+
$this->userConfig->setValueString($targetUser->getUID(), 'core', ConfigLexicon::USER_LANGUAGE, $value);
11201123
break;
11211124
case self::USER_FIELD_LOCALE:
11221125
if (!$this->l10nFactory->localeExists($value)) {
11231126
throw new OCSException($this->l10n->t('Invalid locale'), 101);
11241127
}
1125-
$this->config->setUserValue($targetUser->getUID(), 'core', 'locale', $value);
1128+
$this->userConfig->setValueString($targetUser->getUID(), 'core', ConfigLexicon::USER_LOCALE, $value);
11261129
break;
11271130
case self::USER_FIELD_TIMEZONE:
11281131
if (!in_array($value, \DateTimeZone::listIdentifiers())) {
11291132
throw new OCSException($this->l10n->t('Invalid timezone'), 101);
11301133
}
1131-
$this->config->setUserValue($targetUser->getUID(), 'core', 'timezone', $value);
1134+
$this->userConfig->setValueString($targetUser->getUID(), 'core', ConfigLexicon::USER_TIMEZONE, $value);
11321135
break;
11331136
case self::USER_FIELD_FIRST_DAY_OF_WEEK:
11341137
$intValue = (int)$value;

lib/private/L10N/Factory.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,10 @@
88
*/
99
namespace OC\L10N;
1010

11+
use OC\Core\AppInfo\ConfigLexicon;
1112
use OCP\App\AppPathNotFoundException;
1213
use OCP\App\IAppManager;
14+
use OCP\Config\IUserConfig;
1315
use OCP\ICache;
1416
use OCP\ICacheFactory;
1517
use OCP\IConfig;
@@ -71,6 +73,7 @@ class Factory implements IFactory {
7173
];
7274

7375
private ICache $cache;
76+
private IUserConfig $userConfig;
7477

7578
public function __construct(
7679
protected IConfig $config,
@@ -200,7 +203,8 @@ public function findLanguage(?string $appId = null): string {
200203
// Try to get the language from the Request
201204
$lang = $this->getLanguageFromRequest($appId);
202205
if ($userId !== null && $appId === null && !$userLang) {
203-
$this->config->setUserValue($userId, 'core', 'lang', $lang);
206+
$userConfig = \OCP\Server::get(IUserConfig::class);
207+
$userConfig->setValueString($userId, 'core', ConfigLexicon::USER_LANGUAGE, $lang);
204208
}
205209
return $lang;
206210
} catch (LanguageNotFoundException $e) {

0 commit comments

Comments
 (0)