From 68cdfc21eed1115ecdb439ae973156e480a583b5 Mon Sep 17 00:00:00 2001 From: Shish Date: Mon, 26 Oct 2020 20:15:34 +0000 Subject: [PATCH] booleanise forum --- ext/forum/main.php | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/ext/forum/main.php b/ext/forum/main.php index a3e4ed95..5539e6d8 100644 --- a/ext/forum/main.php +++ b/ext/forum/main.php @@ -21,7 +21,7 @@ class Forum extends Extension if ($config->get_int("forum_version") < 1) { $database->create_table("forum_threads", " id SCORE_AIPK, - sticky SCORE_BOOL NOT NULL DEFAULT SCORE_BOOL_N, + sticky BOOLEAN NOT NULL DEFAULT FALSE, title VARCHAR(255) NOT NULL, user_id INTEGER NOT NULL, date TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, @@ -41,13 +41,13 @@ class Forum extends Extension "); $database->execute("CREATE INDEX forum_posts_date_idx ON forum_posts(date)", []); - $config->set_int("forum_version", 2); $config->set_int("forumTitleSubString", 25); $config->set_int("forumThreadsPerPage", 15); $config->set_int("forumPostsPerPage", 15); $config->set_int("forumMaxCharsPerPost", 512); + $config->set_int("forum_version", 3); log_info("forum", "extension installed"); } if ($config->get_int("forum_version") < 2) { @@ -55,6 +55,10 @@ class Forum extends Extension $database->execute("ALTER TABLE forum_posts ADD FOREIGN KEY (user_id) REFERENCES users(id) ON UPDATE CASCADE ON DELETE RESTRICT"); $config->set_int("forum_version", 2); } + if ($config->get_int("forum_version") < 3) { + $database->standardise_boolean("forum_threads", "sticky"); + $config->set_int("forum_version", 3); + } } public function onSetupBuilding(SetupBuildingEvent $event) @@ -306,11 +310,7 @@ class Forum extends Extension private function save_new_thread(User $user) { $title = html_escape($_POST["title"]); - $sticky = !empty($_POST["sticky"]) ? html_escape($_POST["sticky"]) : "N"; - - if ($sticky == "") { - $sticky = "N"; - } + $sticky = !empty($_POST["sticky"]); global $database; $database->execute(