-
-
Notifications
You must be signed in to change notification settings - Fork 4.7k
IUserConfig #47658
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
IUserConfig #47658
Changes from 1 commit
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
65e24f7
feat(user-prefs): IUserPreferences
ArtificialOwl e73513b
fix(user-prefs): adding sensitive and indexed as flags
ArtificialOwl 7c04818
feat(user-prefs): iterator instead of array on search
ArtificialOwl 6afc855
feat(user-prefs): switching to NCU/
ArtificialOwl 5b4f190
feat(user-prefs): renaming to IUserConfig
ArtificialOwl File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev
Previous commit
feat(user-prefs): renaming to IUserConfig
Signed-off-by: Maxence Lange <[email protected]>
- Loading branch information
commit 5b4f1904c0867b14237c5fcfb3e27e936f35ca0b
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -7,9 +7,9 @@ | |
| namespace OC; | ||
|
|
||
| use NCU\Config\Exceptions\TypeConflictException; | ||
| use NCU\Config\IUserPreferences; | ||
| use NCU\Config\IUserConfig; | ||
| use NCU\Config\ValueType; | ||
| use OC\Config\UserPreferences; | ||
| use OC\Config\UserConfig; | ||
| use OCP\Cache\CappedMemoryCache; | ||
| use OCP\IConfig; | ||
| use OCP\IDBConnection; | ||
|
|
@@ -230,20 +230,20 @@ public function deleteAppValues($appName) { | |
| * | ||
| * @throws \OCP\PreConditionNotMetException if a precondition is specified and is not met | ||
| * @throws \UnexpectedValueException when trying to store an unexpected value | ||
| * @deprecated 31.0.0 - use {@see IUserPreferences} directly | ||
| * @see IUserPreferences::getValueString | ||
| * @see IUserPreferences::getValueInt | ||
| * @see IUserPreferences::getValueFloat | ||
| * @see IUserPreferences::getValueArray | ||
| * @see IUserPreferences::getValueBool | ||
| * @deprecated 31.0.0 - use {@see IUserConfig} directly | ||
| * @see IUserConfig::getValueString | ||
| * @see IUserConfig::getValueInt | ||
| * @see IUserConfig::getValueFloat | ||
| * @see IUserConfig::getValueArray | ||
| * @see IUserConfig::getValueBool | ||
| */ | ||
| public function setUserValue($userId, $appName, $key, $value, $preCondition = null) { | ||
| if (!is_int($value) && !is_float($value) && !is_string($value)) { | ||
| throw new \UnexpectedValueException('Only integers, floats and strings are allowed as value'); | ||
| } | ||
|
|
||
| /** @var UserPreferences $userPreferences */ | ||
| $userPreferences = \OCP\Server::get(IUserPreferences::class); | ||
| /** @var UserConfig $userPreferences */ | ||
| $userPreferences = \OCP\Server::get(IUserConfig::class); | ||
| if ($preCondition !== null) { | ||
| try { | ||
| if ($userPreferences->getValueMixed($userId, $appName, $key) !== (string)$preCondition) { | ||
|
||
|
|
@@ -265,19 +265,19 @@ public function setUserValue($userId, $appName, $key, $value, $preCondition = nu | |
| * @param mixed $default the default value to be returned if the value isn't set | ||
| * | ||
| * @return string | ||
| * @deprecated 31.0.0 - use {@see IUserPreferences} directly | ||
| * @see IUserPreferences::getValueString | ||
| * @see IUserPreferences::getValueInt | ||
| * @see IUserPreferences::getValueFloat | ||
| * @see IUserPreferences::getValueArray | ||
| * @see IUserPreferences::getValueBool | ||
| * @deprecated 31.0.0 - use {@see IUserConfig} directly | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same for all methods |
||
| * @see IUserConfig::getValueString | ||
| * @see IUserConfig::getValueInt | ||
| * @see IUserConfig::getValueFloat | ||
| * @see IUserConfig::getValueArray | ||
| * @see IUserConfig::getValueBool | ||
| */ | ||
| public function getUserValue($userId, $appName, $key, $default = '') { | ||
| if ($userId === null || $userId === '') { | ||
| return $default; | ||
| } | ||
| /** @var UserPreferences $userPreferences */ | ||
| $userPreferences = \OCP\Server::get(IUserPreferences::class); | ||
| /** @var UserConfig $userPreferences */ | ||
| $userPreferences = \OCP\Server::get(IUserConfig::class); | ||
| // because $default can be null ... | ||
| if (!$userPreferences->hasKey($userId, $appName, $key)) { | ||
| return $default; | ||
|
|
@@ -290,11 +290,12 @@ public function getUserValue($userId, $appName, $key, $default = '') { | |
| * | ||
| * @param string $userId the userId of the user that we want to store the value under | ||
| * @param string $appName the appName that we stored the value under | ||
| * | ||
| * @return string[] | ||
| * @deprecated 31.0.0 - use {@see IUserPreferences::getKeys} directly | ||
| * @deprecated 31.0.0 - use {@see IUserConfig::getKeys} directly | ||
| */ | ||
| public function getUserKeys($userId, $appName) { | ||
| return \OCP\Server::get(IUserPreferences::class)->getKeys($userId, $appName); | ||
| return \OCP\Server::get(IUserConfig::class)->getKeys($userId, $appName); | ||
| } | ||
|
|
||
| /** | ||
|
|
@@ -303,52 +304,56 @@ public function getUserKeys($userId, $appName) { | |
| * @param string $userId the userId of the user that we want to store the value under | ||
| * @param string $appName the appName that we stored the value under | ||
| * @param string $key the key under which the value is being stored | ||
| * @deprecated 31.0.0 - use {@see IUserPreferences::deletePreference} directly | ||
| * | ||
| * @deprecated 31.0.0 - use {@see IUserConfig::deleteUserConfig} directly | ||
| */ | ||
| public function deleteUserValue($userId, $appName, $key) { | ||
| \OCP\Server::get(IUserPreferences::class)->deletePreference($userId, $appName, $key); | ||
| \OCP\Server::get(IUserConfig::class)->deleteUserConfig($userId, $appName, $key); | ||
| } | ||
|
|
||
| /** | ||
| * Delete all user values | ||
| * | ||
| * @param string $userId the userId of the user that we want to remove all values from | ||
| * @deprecated 31.0.0 - use {@see IUserPreferences::deleteAllPreferences} directly | ||
| * | ||
| * @deprecated 31.0.0 - use {@see IUserConfig::deleteAllUserConfig} directly | ||
| */ | ||
| public function deleteAllUserValues($userId) { | ||
| if ($userId === null) { | ||
| return; | ||
| } | ||
| \OCP\Server::get(IUserPreferences::class)->deleteAllPreferences($userId); | ||
| \OCP\Server::get(IUserConfig::class)->deleteAllUserConfig($userId); | ||
| } | ||
|
|
||
| /** | ||
| * Delete all user related values of one app | ||
| * | ||
| * @param string $appName the appName of the app that we want to remove all values from | ||
| * @deprecated 31.0.0 - use {@see IUserPreferences::deleteApp} directly | ||
| * | ||
| * @deprecated 31.0.0 - use {@see IUserConfig::deleteApp} directly | ||
| */ | ||
| public function deleteAppFromAllUsers($appName) { | ||
| \OCP\Server::get(IUserPreferences::class)->deleteApp($appName); | ||
| \OCP\Server::get(IUserConfig::class)->deleteApp($appName); | ||
| } | ||
|
|
||
| /** | ||
| * Returns all user configs sorted by app of one user | ||
| * | ||
| * @param ?string $userId the user ID to get the app configs from | ||
| * | ||
| * @psalm-return array<string, array<string, string>> | ||
| * @return array[] - 2 dimensional array with the following structure: | ||
| * [ $appId => | ||
| * [ $key => $value ] | ||
| * ] | ||
| * @deprecated 31.0.0 - use {@see IUserPreferences::getAllValues} directly | ||
| * @deprecated 31.0.0 - use {@see IUserConfig::getAllValues} directly | ||
| */ | ||
| public function getAllUserValues(?string $userId): array { | ||
| if ($userId === null || $userId === '') { | ||
| return []; | ||
| } | ||
|
|
||
| $values = \OCP\Server::get(IUserPreferences::class)->getAllValues($userId); | ||
| $values = \OCP\Server::get(IUserConfig::class)->getAllValues($userId); | ||
| $result = []; | ||
| foreach ($values as $app => $list) { | ||
| foreach ($list as $key => $value) { | ||
|
|
@@ -364,11 +369,12 @@ public function getAllUserValues(?string $userId): array { | |
| * @param string $appName app to get the value for | ||
| * @param string $key the key to get the value for | ||
| * @param array $userIds the user IDs to fetch the values for | ||
| * | ||
| * @return array Mapped values: userId => value | ||
| * @deprecated 31.0.0 - use {@see IUserPreferences::getValuesByUsers} directly | ||
| * @deprecated 31.0.0 - use {@see IUserConfig::getValuesByUsers} directly | ||
| */ | ||
| public function getUserValueForUsers($appName, $key, $userIds) { | ||
| return \OCP\Server::get(IUserPreferences::class)->getValuesByUsers($appName, $key, ValueType::MIXED, $userIds); | ||
| return \OCP\Server::get(IUserConfig::class)->getValuesByUsers($appName, $key, ValueType::MIXED, $userIds); | ||
| } | ||
|
|
||
| /** | ||
|
|
@@ -377,11 +383,14 @@ public function getUserValueForUsers($appName, $key, $userIds) { | |
| * @param string $appName the app to get the user for | ||
| * @param string $key the key to get the user for | ||
| * @param string $value the value to get the user for | ||
| * @return array<string> of user IDs | ||
| * @deprecated 31.0.0 - use {@see IUserPreferences::searchUsersByValueString} directly | ||
| * | ||
| * @return list<string> of user IDs | ||
| * @deprecated 31.0.0 - use {@see IUserConfig::searchUsersByValueString} directly | ||
| */ | ||
| public function getUsersForUserValue($appName, $key, $value) { | ||
| return iterator_to_array(\OCP\Server::get(IUserPreferences::class)->searchUsersByValueString($appName, $key, $value)); | ||
| /** @var list<string> $result */ | ||
| $result = iterator_to_array(\OCP\Server::get(IUserConfig::class)->searchUsersByValueString($appName, $key, $value)); | ||
| return $result; | ||
| } | ||
|
|
||
| /** | ||
|
|
@@ -390,15 +399,18 @@ public function getUsersForUserValue($appName, $key, $value) { | |
| * @param string $appName the app to get the user for | ||
| * @param string $key the key to get the user for | ||
| * @param string $value the value to get the user for | ||
| * @return array<string> of user IDs | ||
| * @deprecated 31.0.0 - use {@see IUserPreferences::searchUsersByValueString} directly | ||
| * | ||
| * @return list<string> of user IDs | ||
| * @deprecated 31.0.0 - use {@see IUserConfig::searchUsersByValueString} directly | ||
| */ | ||
| public function getUsersForUserValueCaseInsensitive($appName, $key, $value) { | ||
| if ($appName === 'settings' && $key === 'email') { | ||
| return $this->getUsersForUserValue($appName, $key, strtolower($value)); | ||
| } | ||
|
|
||
| return iterator_to_array(\OCP\Server::get(IUserPreferences::class)->searchUsersByValueString($appName, $key, $value, true)); | ||
| /** @var list<string> $result */ | ||
| $result = iterator_to_array(\OCP\Server::get(IUserConfig::class)->searchUsersByValueString($appName, $key, $value, true)); | ||
| return $result; | ||
| } | ||
|
|
||
| public function getSystemConfig() { | ||
|
|
||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
https://docs.nextcloud.com/server/latest/developer_manual/digging_deeper/api.html#php-unstable-api
So you can not deprecate this and neither the public interface.