diff --git a/public-legacy/forum/posting.php b/public-legacy/forum/posting.php index ccfc3bc..668952d 100644 --- a/public-legacy/forum/posting.php +++ b/public-legacy/forum/posting.php @@ -169,11 +169,6 @@ if(!empty($_POST)) { } else { $isEditingTopic = empty($topicInfo) || ($mode === 'edit' && $originalPostInfo->getId() == $postInfo->getId()); - if(is_string($topicType)) - $topicType = ForumTopicInfo::TYPE_ALIASES[$topicType] ?? ForumTopicInfo::TYPE_DISCUSSION; - else - $topicType = (int)$topicType; - if($mode === 'create') { $postTimeout = $cfg->getInteger('forum.posting.timeout', 5); if($postTimeout > 0) { @@ -192,7 +187,7 @@ if(!empty($_POST)) { if($isEditingTopic) { $originalTopicTitle = $topicInfo?->getTitle() ?? null; $topicTitleChanged = $topicTitle !== $originalTopicTitle; - $originalTopicType = (int)($topicInfo?->getType() ?? 0); + $originalTopicType = $topicInfo?->getTypeString() ?? 'discussion'; $topicTypeChanged = $topicType !== null && $topicType !== $originalTopicType; $topicTitleLengths = $cfg->getValues([ @@ -329,14 +324,6 @@ try { $selectedParser = Parser::BBCODE; } -// this sucks, fix it! -$topicTypeName = match($topicType ?? $topicInfo?->getType() ?? null) { - default => 'discussion', - ForumTopicInfo::TYPE_STICKY => 'sticky', - ForumTopicInfo::TYPE_ANNOUNCE => 'announce', - ForumTopicInfo::TYPE_GLOBAL => 'global', -}; - Template::render('forum.posting', [ 'posting_breadcrumbs' => $forum->getCategoryAncestry($categoryInfo), 'global_accent_colour' => $forum->getCategoryColour($categoryInfo), @@ -348,7 +335,6 @@ Template::render('forum.posting', [ 'posting_notices' => $notices, 'posting_mode' => $mode, 'posting_types' => $topicTypes, - 'posting_type_selected' => $topicTypeName, 'posting_defaults' => [ 'title' => $topicTitle ?? null, 'type' => $topicType ?? null, diff --git a/src/Forum/ForumTopicInfo.php b/src/Forum/ForumTopicInfo.php index 2a6c976..88a3f42 100644 --- a/src/Forum/ForumTopicInfo.php +++ b/src/Forum/ForumTopicInfo.php @@ -65,6 +65,15 @@ class ForumTopicInfo { return $this->type; } + public function getTypeString(): string { + return match($this->type) { + self::TYPE_GLOBAL => 'global', + self::TYPE_ANNOUNCE => 'announce', + self::TYPE_STICKY => 'sticky', + default => 'discussion', + }; + } + public function isDiscussion(): bool { return $this->type === self::TYPE_DISCUSSION; } diff --git a/templates/forum/posting.twig b/templates/forum/posting.twig index e3c9d51..16c7866 100644 --- a/templates/forum/posting.twig +++ b/templates/forum/posting.twig @@ -152,7 +152,7 @@ {% if is_opening and posting_types|length > 1 %} {% endif %}