diff --git a/ext/blotter/main.php b/ext/blotter/main.php index 5a043a99..08adf4bd 100644 --- a/ext/blotter/main.php +++ b/ext/blotter/main.php @@ -15,9 +15,9 @@ class Blotter extends Extension public function onDatabaseUpgrade(DatabaseUpgradeEvent $event) { - global $config, $database; + global $database; - if ($config->get_int("blotter_version", 0) < 1) { + if ($this->get_version("blotter_version") < 1) { $database->create_table("blotter", " id SCORE_AIPK, entry_date TIMESTAMP DEFAULT CURRENT_TIMESTAMP, @@ -30,11 +30,11 @@ class Blotter extends Extension ["text"=>"Installed the blotter extension!", "important"=>true] ); log_info("blotter", "Installed tables for blotter extension."); - $config->set_int("blotter_version", 2); + $this->set_version("blotter_version", 2); } - if ($config->get_int("blotter_version") < 2) { + if ($this->get_version("blotter_version") < 2) { $database->standardise_boolean("blotter", "important"); - $config->set_int("blotter_version", 2); + $this->set_version("blotter_version", 2); } } diff --git a/ext/et_server/main.php b/ext/et_server/main.php index 97c2726b..eafa942e 100644 --- a/ext/et_server/main.php +++ b/ext/et_server/main.php @@ -35,17 +35,16 @@ class ETServer extends Extension public function onDatabaseUpgrade(DatabaseUpgradeEvent $event) { - global $config, $database; + global $database; // shortcut to latest - if ($config->get_int("et_server_version") < 1) { + if ($this->get_version("et_server_version") < 1) { $database->create_table("registration", " id SCORE_AIPK, responded TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, data TEXT NOT NULL, "); - $config->set_int("et_server_version", 1); - log_info("et_server", "extension installed"); + $this->set_version("et_server_version", 1); } } } diff --git a/ext/forum/main.php b/ext/forum/main.php index 5539e6d8..b2aac68f 100644 --- a/ext/forum/main.php +++ b/ext/forum/main.php @@ -18,7 +18,7 @@ class Forum extends Extension // shortcut to latest - if ($config->get_int("forum_version") < 1) { + if ($this->get_version("forum_version") < 1) { $database->create_table("forum_threads", " id SCORE_AIPK, sticky BOOLEAN NOT NULL DEFAULT FALSE, @@ -47,17 +47,16 @@ class Forum extends Extension $config->set_int("forumMaxCharsPerPost", 512); - $config->set_int("forum_version", 3); - log_info("forum", "extension installed"); + $this->set_version("forum_version", 3); } - if ($config->get_int("forum_version") < 2) { + if ($this->get_version("forum_version") < 2) { $database->execute("ALTER TABLE forum_threads ADD FOREIGN KEY (user_id) REFERENCES users(id) ON UPDATE CASCADE ON DELETE RESTRICT"); $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); + $this->set_version("forum_version", 2); } - if ($config->get_int("forum_version") < 3) { + if ($this->get_version("forum_version") < 3) { $database->standardise_boolean("forum_threads", "sticky"); - $config->set_int("forum_version", 3); + $this->set_version("forum_version", 3); } } diff --git a/ext/pm/main.php b/ext/pm/main.php index fb72fea5..2d0ba333 100644 --- a/ext/pm/main.php +++ b/ext/pm/main.php @@ -62,10 +62,10 @@ class PrivMsg extends Extension public function onDatabaseUpgrade(DatabaseUpgradeEvent $event) { - global $config, $database; + global $database; // shortcut to latest - if ($config->get_int("pm_version") < 1) { + if ($this->get_version("pm_version") < 1) { $database->create_table("private_message", " id SCORE_AIPK, from_id INTEGER NOT NULL, @@ -79,26 +79,22 @@ class PrivMsg extends Extension FOREIGN KEY (to_id) REFERENCES users(id) ON DELETE CASCADE "); $database->execute("CREATE INDEX private_message__to_id ON private_message(to_id)"); - $config->set_int("pm_version", 3); - log_info("pm", "extension installed"); + $this->set_version("pm_version", 3); } - if ($config->get_int("pm_version") < 2) { + if ($this->get_version("pm_version") < 2) { log_info("pm", "Adding foreign keys to private messages"); $database->execute("delete from private_message where to_id not in (select id from users);"); $database->execute("delete from private_message where from_id not in (select id from users);"); $database->execute("ALTER TABLE private_message ADD FOREIGN KEY (from_id) REFERENCES users(id) ON DELETE CASCADE, ADD FOREIGN KEY (to_id) REFERENCES users(id) ON DELETE CASCADE;"); - $config->set_int("pm_version", 2); - log_info("pm", "extension upgraded"); + $this->set_version("pm_version", 2); } - if ($config->get_int("pm_version") < 3) { - log_info("pm", "Updating is_read boolean"); + if ($this->get_version("pm_version") < 3) { $database->standardise_boolean("private_message", "is_read", true); - $config->set_int("pm_version", 3); - log_info("pm", "extension upgraded"); + $this->set_version("pm_version", 3); } } diff --git a/ext/upgrade/main.php b/ext/upgrade/main.php index 0974631e..753d901d 100644 --- a/ext/upgrade/main.php +++ b/ext/upgrade/main.php @@ -24,7 +24,7 @@ class Upgrade extends Extension file_put_contents("data/index.php", "get_int("db_version") < 1) { + if ($this->get_version("db_version") < 1) { $this->set_version("db_version", 2); }