diff --git a/lib/AppConstants.php b/lib/AppConstants.php index e2be724..dbd34d7 100644 --- a/lib/AppConstants.php +++ b/lib/AppConstants.php @@ -6,4 +6,14 @@ namespace OCA\PrideFlags; abstract class AppConstants { public const APP_ID = 'pride_flags'; + public enum Variants: string { + case PRIDE = "Pride"; + case TRANS = "Trans Pride"; + case PAN = "Pansexual Pride"; + case BI = "Bisexual Pride"; + case ASEXUAL = "Asexual Pride"; + case LESBIAN = "Lesbian Pride"; + case NONBINARY = "Non-binary Pride"; + case NONE = "No customisation"; + } } diff --git a/lib/Settings/AppSettings.php b/lib/Settings/AppSettings.php index 158112b..cb1cd6b 100644 --- a/lib/Settings/AppSettings.php +++ b/lib/Settings/AppSettings.php @@ -18,11 +18,16 @@ class AppSettings { } public function setStringSetting($userId, string $key, string $value): void { - $this->config->setUserValue(AppConstants::APP_ID, $userId, $key, $value); + // Check for valid Variant here + if (AppConstants\Variants::tryFrom($value) != null) { + $this->config->setUserValue(AppConstants::APP_ID, $userId, $key, $value); + } } public function setAppStringSetting(string $key, string $value): void { - $this->config->setAppValue(AppConstants::APP_ID, $key, $value); + if (AppConstants\Variants::tryFrom($value) != null) { + $this->config->setAppValue(AppConstants::APP_ID, $key, $value); + } } public function getAll($userId): array { diff --git a/templates/settings.php b/templates/settings.php index 91529d7..1182d08 100644 --- a/templates/settings.php +++ b/templates/settings.php @@ -1,5 +1,8 @@