diff --git a/com.woltlab.wcf/templates/userNotice.tpl b/com.woltlab.wcf/templates/userNotice.tpl
index c1c913080e4..ce12649ed79 100644
--- a/com.woltlab.wcf/templates/userNotice.tpl
+++ b/com.woltlab.wcf/templates/userNotice.tpl
@@ -27,15 +27,27 @@
{hascontent}
{content}
{foreach from=$__wcf->getNoticeHandler()->getVisibleNotices() item='notice'}
-
- {if $notice->isDismissible}
-
- {/if}
-
- {@$notice}
-
+ {if $notice->isCustom()}
+
+ {if $notice->isDismissible}
+
+ {/if}
+
+ {@$notice}
+
+ {else}
+
+ {if $notice->isDismissible}
+
+ {/if}
+
+ {@$notice}
+
+ {/if}
{/foreach}
{/content}
diff --git a/wcfsetup/install/files/acp/templates/noticeAdd.tpl b/wcfsetup/install/files/acp/templates/noticeAdd.tpl
index ab1fbd34ed7..7d17c0207a8 100644
--- a/wcfsetup/install/files/acp/templates/noticeAdd.tpl
+++ b/wcfsetup/install/files/acp/templates/noticeAdd.tpl
@@ -78,12 +78,11 @@
{foreach from=$availableCssClassNames item=className}
- {if $className == 'custom'}
-
- {else}
-
- {/if}
+
{/foreach}
+
+
+
{if $errorField == 'cssClassName'}
{if $errorType == 'empty'}
diff --git a/wcfsetup/install/files/lib/acp/form/NoticeAddForm.class.php b/wcfsetup/install/files/lib/acp/form/NoticeAddForm.class.php
index badbb22ac9f..3af09f4395a 100644
--- a/wcfsetup/install/files/lib/acp/form/NoticeAddForm.class.php
+++ b/wcfsetup/install/files/lib/acp/form/NoticeAddForm.class.php
@@ -2,6 +2,7 @@
namespace wcf\acp\form;
+use wcf\data\notice\Notice;
use wcf\data\notice\NoticeAction;
use wcf\data\notice\NoticeEditor;
use wcf\data\object\type\ObjectType;
@@ -29,19 +30,6 @@ class NoticeAddForm extends AbstractForm
*/
public $activeMenuItem = 'wcf.acp.menu.link.notice.add';
- /**
- * list pf pre-defined CSS class names
- * @var string[]
- */
- public $availableCssClassNames = [
- 'info',
- 'success',
- 'warning',
- 'error',
-
- 'custom',
- ];
-
/**
* name of the chosen CSS class name
* @var string
@@ -106,7 +94,7 @@ public function assignVariables()
WCF::getTPL()->assign([
'action' => 'add',
- 'availableCssClassNames' => $this->availableCssClassNames,
+ 'availableCssClassNames' => Notice::TYPES,
'cssClassName' => $this->cssClassName,
'customCssClassName' => $this->customCssClassName,
'isDisabled' => $this->isDisabled,
@@ -297,8 +285,6 @@ public function validate()
// validate class name
if (empty($this->cssClassName)) {
throw new UserInputException('cssClassName');
- } elseif (!\in_array($this->cssClassName, $this->availableCssClassNames)) {
- throw new UserInputException('cssClassName', 'invalid');
} elseif ($this->cssClassName == 'custom') {
if (empty($this->cssClassName)) {
throw new UserInputException('cssClassName');
@@ -306,6 +292,8 @@ public function validate()
if (!Regex::compile('^-?[_a-zA-Z]+[_a-zA-Z0-9-]+$')->match($this->customCssClassName)) {
throw new UserInputException('cssClassName', 'invalid');
}
+ } elseif (!\in_array($this->cssClassName, Notice::TYPES)) {
+ throw new UserInputException('cssClassName', 'invalid');
}
foreach ($this->groupedConditionObjectTypes as $groupedObjectTypes) {
diff --git a/wcfsetup/install/files/lib/acp/form/NoticeEditForm.class.php b/wcfsetup/install/files/lib/acp/form/NoticeEditForm.class.php
index 38843baf597..ec99b99d166 100644
--- a/wcfsetup/install/files/lib/acp/form/NoticeEditForm.class.php
+++ b/wcfsetup/install/files/lib/acp/form/NoticeEditForm.class.php
@@ -70,7 +70,7 @@ public function readData()
I18nHandler::getInstance()->setOptions('notice', 1, $this->notice->notice, 'wcf.notice.notice.notice\d+');
$this->cssClassName = $this->notice->cssClassName;
- if (!\in_array($this->cssClassName, $this->availableCssClassNames)) {
+ if (!\in_array($this->cssClassName, Notice::TYPES)) {
$this->customCssClassName = $this->cssClassName;
$this->cssClassName = 'custom';
}
diff --git a/wcfsetup/install/files/lib/data/notice/Notice.class.php b/wcfsetup/install/files/lib/data/notice/Notice.class.php
index c587e9f669e..81cadf923c1 100644
--- a/wcfsetup/install/files/lib/data/notice/Notice.class.php
+++ b/wcfsetup/install/files/lib/data/notice/Notice.class.php
@@ -28,6 +28,13 @@
*/
class Notice extends DatabaseObject implements IRouteController
{
+ /**
+ * Available notice types.
+ * @var string[]
+ * @since 6.1
+ */
+ const TYPES = ['info', 'success', 'warning', 'error'];
+
/**
* true if the active user has dismissed the notice
* @var bool
@@ -127,4 +134,12 @@ public function isDismissed()
return $this->isDismissed;
}
+
+ /**
+ * @since 6.1
+ */
+ public function isCustom(): bool
+ {
+ return !\in_array($this->cssClassName, self::TYPES);
+ }
}