Skip to content

Commit fca6085

Browse files
authored
Merge pull request #59719 from nextcloud/fix/visibilityNormalization
2 parents 5a728a4 + 206ef49 commit fca6085

1 file changed

Lines changed: 10 additions & 1 deletion

File tree

core/Db/ProfileConfig.php

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
use JsonSerializable;
1313
use OCP\AppFramework\Db\Entity;
14+
use OCP\Profile\IProfileManager;
1415
use OCP\Profile\ParameterDoesNotExistException;
1516
use function json_decode;
1617
use function json_encode;
@@ -68,7 +69,7 @@ public function setVisibilityMap(array $visibilityMap): void {
6869
foreach ($visibilityMap as $paramId => $visibility) {
6970
$config[$paramId] = array_merge(
7071
$config[$paramId] ?: [],
71-
['visibility' => $visibility],
72+
['visibility' => $this->normalizeVisibility($visibility)],
7273
);
7374
}
7475

@@ -103,4 +104,12 @@ public function jsonSerialize(): array {
103104
'config' => $this->getConfigArray(),
104105
];
105106
}
107+
108+
private function normalizeVisibility(string $visibility): string {
109+
return match(strtolower($visibility)) {
110+
IProfileManager::VISIBILITY_SHOW => IProfileManager::VISIBILITY_SHOW,
111+
IProfileManager::VISIBILITY_SHOW_USERS_ONLY => IProfileManager::VISIBILITY_SHOW_USERS_ONLY,
112+
default => IProfileManager::VISIBILITY_HIDE,
113+
};
114+
}
106115
}

0 commit comments

Comments
 (0)