Skip to content

Commit 5b4f190

Browse files
committed
feat(user-prefs): renaming to IUserConfig
Signed-off-by: Maxence Lange <[email protected]>
1 parent 6afc855 commit 5b4f190

12 files changed

Lines changed: 559 additions & 543 deletions

File tree

lib/composer/composer/autoload_classmap.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
'NCU\\Config\\Exceptions\\IncorrectTypeException' => $baseDir . '/lib/unstable/Config/Exceptions/IncorrectTypeException.php',
1111
'NCU\\Config\\Exceptions\\TypeConflictException' => $baseDir . '/lib/unstable/Config/Exceptions/TypeConflictException.php',
1212
'NCU\\Config\\Exceptions\\UnknownKeyException' => $baseDir . '/lib/unstable/Config/Exceptions/UnknownKeyException.php',
13-
'NCU\\Config\\IUserPreferences' => $baseDir . '/lib/unstable/Config/IUserPreferences.php',
13+
'NCU\\Config\\IUserConfig' => $baseDir . '/lib/unstable/Config/IUserConfig.php',
1414
'NCU\\Config\\ValueType' => $baseDir . '/lib/unstable/Config/ValueType.php',
1515
'OCP\\Accounts\\IAccount' => $baseDir . '/lib/public/Accounts/IAccount.php',
1616
'OCP\\Accounts\\IAccountManager' => $baseDir . '/lib/public/Accounts/IAccountManager.php',
@@ -1123,7 +1123,7 @@
11231123
'OC\\Comments\\Manager' => $baseDir . '/lib/private/Comments/Manager.php',
11241124
'OC\\Comments\\ManagerFactory' => $baseDir . '/lib/private/Comments/ManagerFactory.php',
11251125
'OC\\Config' => $baseDir . '/lib/private/Config.php',
1126-
'OC\\Config\\UserPreferences' => $baseDir . '/lib/private/Config/UserPreferences.php',
1126+
'OC\\Config\\UserConfig' => $baseDir . '/lib/private/Config/UserConfig.php',
11271127
'OC\\Console\\Application' => $baseDir . '/lib/private/Console/Application.php',
11281128
'OC\\Console\\TimestampFormatter' => $baseDir . '/lib/private/Console/TimestampFormatter.php',
11291129
'OC\\ContactsManager' => $baseDir . '/lib/private/ContactsManager.php',

lib/composer/composer/autoload_static.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ class ComposerStaticInit749170dad3f5e7f9ca158f5a9f04f6a2
5151
'NCU\\Config\\Exceptions\\IncorrectTypeException' => __DIR__ . '/../../..' . '/lib/unstable/Config/Exceptions/IncorrectTypeException.php',
5252
'NCU\\Config\\Exceptions\\TypeConflictException' => __DIR__ . '/../../..' . '/lib/unstable/Config/Exceptions/TypeConflictException.php',
5353
'NCU\\Config\\Exceptions\\UnknownKeyException' => __DIR__ . '/../../..' . '/lib/unstable/Config/Exceptions/UnknownKeyException.php',
54-
'NCU\\Config\\IUserPreferences' => __DIR__ . '/../../..' . '/lib/unstable/Config/IUserPreferences.php',
54+
'NCU\\Config\\IUserConfig' => __DIR__ . '/../../..' . '/lib/unstable/Config/IUserConfig.php',
5555
'NCU\\Config\\ValueType' => __DIR__ . '/../../..' . '/lib/unstable/Config/ValueType.php',
5656
'OCP\\Accounts\\IAccount' => __DIR__ . '/../../..' . '/lib/public/Accounts/IAccount.php',
5757
'OCP\\Accounts\\IAccountManager' => __DIR__ . '/../../..' . '/lib/public/Accounts/IAccountManager.php',
@@ -1164,7 +1164,7 @@ class ComposerStaticInit749170dad3f5e7f9ca158f5a9f04f6a2
11641164
'OC\\Comments\\Manager' => __DIR__ . '/../../..' . '/lib/private/Comments/Manager.php',
11651165
'OC\\Comments\\ManagerFactory' => __DIR__ . '/../../..' . '/lib/private/Comments/ManagerFactory.php',
11661166
'OC\\Config' => __DIR__ . '/../../..' . '/lib/private/Config.php',
1167-
'OC\\Config\\UserPreferences' => __DIR__ . '/../../..' . '/lib/private/Config/UserPreferences.php',
1167+
'OC\\Config\\UserConfig' => __DIR__ . '/../../..' . '/lib/private/Config/UserConfig.php',
11681168
'OC\\Console\\Application' => __DIR__ . '/../../..' . '/lib/private/Console/Application.php',
11691169
'OC\\Console\\TimestampFormatter' => __DIR__ . '/../../..' . '/lib/private/Console/TimestampFormatter.php',
11701170
'OC\\ContactsManager' => __DIR__ . '/../../..' . '/lib/private/ContactsManager.php',

lib/private/AllConfig.php

Lines changed: 48 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@
77
namespace OC;
88

99
use NCU\Config\Exceptions\TypeConflictException;
10-
use NCU\Config\IUserPreferences;
10+
use NCU\Config\IUserConfig;
1111
use NCU\Config\ValueType;
12-
use OC\Config\UserPreferences;
12+
use OC\Config\UserConfig;
1313
use OCP\Cache\CappedMemoryCache;
1414
use OCP\IConfig;
1515
use OCP\IDBConnection;
@@ -230,20 +230,20 @@ public function deleteAppValues($appName) {
230230
*
231231
* @throws \OCP\PreConditionNotMetException if a precondition is specified and is not met
232232
* @throws \UnexpectedValueException when trying to store an unexpected value
233-
* @deprecated 31.0.0 - use {@see IUserPreferences} directly
234-
* @see IUserPreferences::getValueString
235-
* @see IUserPreferences::getValueInt
236-
* @see IUserPreferences::getValueFloat
237-
* @see IUserPreferences::getValueArray
238-
* @see IUserPreferences::getValueBool
233+
* @deprecated 31.0.0 - use {@see IUserConfig} directly
234+
* @see IUserConfig::getValueString
235+
* @see IUserConfig::getValueInt
236+
* @see IUserConfig::getValueFloat
237+
* @see IUserConfig::getValueArray
238+
* @see IUserConfig::getValueBool
239239
*/
240240
public function setUserValue($userId, $appName, $key, $value, $preCondition = null) {
241241
if (!is_int($value) && !is_float($value) && !is_string($value)) {
242242
throw new \UnexpectedValueException('Only integers, floats and strings are allowed as value');
243243
}
244244

245-
/** @var UserPreferences $userPreferences */
246-
$userPreferences = \OCP\Server::get(IUserPreferences::class);
245+
/** @var UserConfig $userPreferences */
246+
$userPreferences = \OCP\Server::get(IUserConfig::class);
247247
if ($preCondition !== null) {
248248
try {
249249
if ($userPreferences->getValueMixed($userId, $appName, $key) !== (string)$preCondition) {
@@ -265,19 +265,19 @@ public function setUserValue($userId, $appName, $key, $value, $preCondition = nu
265265
* @param mixed $default the default value to be returned if the value isn't set
266266
*
267267
* @return string
268-
* @deprecated 31.0.0 - use {@see IUserPreferences} directly
269-
* @see IUserPreferences::getValueString
270-
* @see IUserPreferences::getValueInt
271-
* @see IUserPreferences::getValueFloat
272-
* @see IUserPreferences::getValueArray
273-
* @see IUserPreferences::getValueBool
268+
* @deprecated 31.0.0 - use {@see IUserConfig} directly
269+
* @see IUserConfig::getValueString
270+
* @see IUserConfig::getValueInt
271+
* @see IUserConfig::getValueFloat
272+
* @see IUserConfig::getValueArray
273+
* @see IUserConfig::getValueBool
274274
*/
275275
public function getUserValue($userId, $appName, $key, $default = '') {
276276
if ($userId === null || $userId === '') {
277277
return $default;
278278
}
279-
/** @var UserPreferences $userPreferences */
280-
$userPreferences = \OCP\Server::get(IUserPreferences::class);
279+
/** @var UserConfig $userPreferences */
280+
$userPreferences = \OCP\Server::get(IUserConfig::class);
281281
// because $default can be null ...
282282
if (!$userPreferences->hasKey($userId, $appName, $key)) {
283283
return $default;
@@ -290,11 +290,12 @@ public function getUserValue($userId, $appName, $key, $default = '') {
290290
*
291291
* @param string $userId the userId of the user that we want to store the value under
292292
* @param string $appName the appName that we stored the value under
293+
*
293294
* @return string[]
294-
* @deprecated 31.0.0 - use {@see IUserPreferences::getKeys} directly
295+
* @deprecated 31.0.0 - use {@see IUserConfig::getKeys} directly
295296
*/
296297
public function getUserKeys($userId, $appName) {
297-
return \OCP\Server::get(IUserPreferences::class)->getKeys($userId, $appName);
298+
return \OCP\Server::get(IUserConfig::class)->getKeys($userId, $appName);
298299
}
299300

300301
/**
@@ -303,52 +304,56 @@ public function getUserKeys($userId, $appName) {
303304
* @param string $userId the userId of the user that we want to store the value under
304305
* @param string $appName the appName that we stored the value under
305306
* @param string $key the key under which the value is being stored
306-
* @deprecated 31.0.0 - use {@see IUserPreferences::deletePreference} directly
307+
*
308+
* @deprecated 31.0.0 - use {@see IUserConfig::deleteUserConfig} directly
307309
*/
308310
public function deleteUserValue($userId, $appName, $key) {
309-
\OCP\Server::get(IUserPreferences::class)->deletePreference($userId, $appName, $key);
311+
\OCP\Server::get(IUserConfig::class)->deleteUserConfig($userId, $appName, $key);
310312
}
311313

312314
/**
313315
* Delete all user values
314316
*
315317
* @param string $userId the userId of the user that we want to remove all values from
316-
* @deprecated 31.0.0 - use {@see IUserPreferences::deleteAllPreferences} directly
318+
*
319+
* @deprecated 31.0.0 - use {@see IUserConfig::deleteAllUserConfig} directly
317320
*/
318321
public function deleteAllUserValues($userId) {
319322
if ($userId === null) {
320323
return;
321324
}
322-
\OCP\Server::get(IUserPreferences::class)->deleteAllPreferences($userId);
325+
\OCP\Server::get(IUserConfig::class)->deleteAllUserConfig($userId);
323326
}
324327

325328
/**
326329
* Delete all user related values of one app
327330
*
328331
* @param string $appName the appName of the app that we want to remove all values from
329-
* @deprecated 31.0.0 - use {@see IUserPreferences::deleteApp} directly
332+
*
333+
* @deprecated 31.0.0 - use {@see IUserConfig::deleteApp} directly
330334
*/
331335
public function deleteAppFromAllUsers($appName) {
332-
\OCP\Server::get(IUserPreferences::class)->deleteApp($appName);
336+
\OCP\Server::get(IUserConfig::class)->deleteApp($appName);
333337
}
334338

335339
/**
336340
* Returns all user configs sorted by app of one user
337341
*
338342
* @param ?string $userId the user ID to get the app configs from
343+
*
339344
* @psalm-return array<string, array<string, string>>
340345
* @return array[] - 2 dimensional array with the following structure:
341346
* [ $appId =>
342347
* [ $key => $value ]
343348
* ]
344-
* @deprecated 31.0.0 - use {@see IUserPreferences::getAllValues} directly
349+
* @deprecated 31.0.0 - use {@see IUserConfig::getAllValues} directly
345350
*/
346351
public function getAllUserValues(?string $userId): array {
347352
if ($userId === null || $userId === '') {
348353
return [];
349354
}
350355

351-
$values = \OCP\Server::get(IUserPreferences::class)->getAllValues($userId);
356+
$values = \OCP\Server::get(IUserConfig::class)->getAllValues($userId);
352357
$result = [];
353358
foreach ($values as $app => $list) {
354359
foreach ($list as $key => $value) {
@@ -364,11 +369,12 @@ public function getAllUserValues(?string $userId): array {
364369
* @param string $appName app to get the value for
365370
* @param string $key the key to get the value for
366371
* @param array $userIds the user IDs to fetch the values for
372+
*
367373
* @return array Mapped values: userId => value
368-
* @deprecated 31.0.0 - use {@see IUserPreferences::getValuesByUsers} directly
374+
* @deprecated 31.0.0 - use {@see IUserConfig::getValuesByUsers} directly
369375
*/
370376
public function getUserValueForUsers($appName, $key, $userIds) {
371-
return \OCP\Server::get(IUserPreferences::class)->getValuesByUsers($appName, $key, ValueType::MIXED, $userIds);
377+
return \OCP\Server::get(IUserConfig::class)->getValuesByUsers($appName, $key, ValueType::MIXED, $userIds);
372378
}
373379

374380
/**
@@ -377,11 +383,14 @@ public function getUserValueForUsers($appName, $key, $userIds) {
377383
* @param string $appName the app to get the user for
378384
* @param string $key the key to get the user for
379385
* @param string $value the value to get the user for
380-
* @return array<string> of user IDs
381-
* @deprecated 31.0.0 - use {@see IUserPreferences::searchUsersByValueString} directly
386+
*
387+
* @return list<string> of user IDs
388+
* @deprecated 31.0.0 - use {@see IUserConfig::searchUsersByValueString} directly
382389
*/
383390
public function getUsersForUserValue($appName, $key, $value) {
384-
return iterator_to_array(\OCP\Server::get(IUserPreferences::class)->searchUsersByValueString($appName, $key, $value));
391+
/** @var list<string> $result */
392+
$result = iterator_to_array(\OCP\Server::get(IUserConfig::class)->searchUsersByValueString($appName, $key, $value));
393+
return $result;
385394
}
386395

387396
/**
@@ -390,15 +399,18 @@ public function getUsersForUserValue($appName, $key, $value) {
390399
* @param string $appName the app to get the user for
391400
* @param string $key the key to get the user for
392401
* @param string $value the value to get the user for
393-
* @return array<string> of user IDs
394-
* @deprecated 31.0.0 - use {@see IUserPreferences::searchUsersByValueString} directly
402+
*
403+
* @return list<string> of user IDs
404+
* @deprecated 31.0.0 - use {@see IUserConfig::searchUsersByValueString} directly
395405
*/
396406
public function getUsersForUserValueCaseInsensitive($appName, $key, $value) {
397407
if ($appName === 'settings' && $key === 'email') {
398408
return $this->getUsersForUserValue($appName, $key, strtolower($value));
399409
}
400410

401-
return iterator_to_array(\OCP\Server::get(IUserPreferences::class)->searchUsersByValueString($appName, $key, $value, true));
411+
/** @var list<string> $result */
412+
$result = iterator_to_array(\OCP\Server::get(IUserConfig::class)->searchUsersByValueString($appName, $key, $value, true));
413+
return $result;
402414
}
403415

404416
public function getSystemConfig() {

0 commit comments

Comments
 (0)