mirror of
https://github.com/nextcloud/server.git
synced 2026-05-28 04:32:30 -04:00
fix(profile): normalize profile visibility
Signed-off-by: Benjamin Gaussorgues <benjamin.gaussorgues@nextcloud.com>
This commit is contained in:
parent
0c98c47940
commit
affe49d87c
1 changed files with 10 additions and 1 deletions
|
|
@ -11,6 +11,7 @@ namespace OC\Core\Db;
|
|||
|
||||
use JsonSerializable;
|
||||
use OCP\AppFramework\Db\Entity;
|
||||
use OCP\Profile\IProfileManager;
|
||||
use OCP\Profile\ParameterDoesNotExistException;
|
||||
use function json_decode;
|
||||
use function json_encode;
|
||||
|
|
@ -68,7 +69,7 @@ class ProfileConfig extends Entity implements JsonSerializable {
|
|||
foreach ($visibilityMap as $paramId => $visibility) {
|
||||
$config[$paramId] = array_merge(
|
||||
$config[$paramId] ?: [],
|
||||
['visibility' => $visibility],
|
||||
['visibility' => $this->normalizeVisibility($visibility)],
|
||||
);
|
||||
}
|
||||
|
||||
|
|
@ -103,4 +104,12 @@ class ProfileConfig extends Entity implements JsonSerializable {
|
|||
'config' => $this->getConfigArray(),
|
||||
];
|
||||
}
|
||||
|
||||
private function normalizeVisibility(string $visibility): string {
|
||||
return match(strtolower($visibility)) {
|
||||
IProfileManager::VISIBILITY_SHOW => IProfileManager::VISIBILITY_SHOW,
|
||||
IProfileManager::VISIBILITY_SHOW_USERS_ONLY => IProfileManager::VISIBILITY_SHOW_USERS_ONLY,
|
||||
default => IProfileManager::VISIBILITY_HIDE,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue