summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
Diffstat (limited to 'app')
-rw-r--r--app/Elements/RestrictionNotice.php13
1 files changed, 12 insertions, 1 deletions
diff --git a/app/Elements/RestrictionNotice.php b/app/Elements/RestrictionNotice.php
index 2b3fd6491c..75df0cd38e 100644
--- a/app/Elements/RestrictionNotice.php
+++ b/app/Elements/RestrictionNotice.php
@@ -53,6 +53,13 @@ class RestrictionNotice extends AbstractElement
public const RESTRICTION_CONFIDENTIAL = 'confidential';
public const RESTRICTION_LOCKED = 'locked';
+ // Store the locked value after the privacy value.
+ private const CANONICAL = [
+ self::RESTRICTION_LOCKED . ', ' . self::RESTRICTION_NONE => self::RESTRICTION_NONE . ', ' . self::RESTRICTION_LOCKED,
+ self::RESTRICTION_LOCKED . ', ' . self::RESTRICTION_PRIVACY => self::RESTRICTION_PRIVACY . ', ' . self::RESTRICTION_LOCKED,
+ self::RESTRICTION_LOCKED . ', ' . self::RESTRICTION_CONFIDENTIAL => self::RESTRICTION_CONFIDENTIAL . ', ' . self::RESTRICTION_LOCKED,
+ ];
+
/**
* Convert a value to a canonical form.
*
@@ -62,7 +69,11 @@ class RestrictionNotice extends AbstractElement
*/
public function canonical(string $value): string
{
- return strtolower(parent::canonical($value));
+ $value = strtolower(parent::canonical($value));
+ $value = trim($value, ', ');
+ $value = preg_replace('/[, ]+/', ', ', $value);
+
+ return self::CANONICAL[$value] ?? $value;
}
/**