From f15a95b4dedb520a41102f19b96185daa09741b4 Mon Sep 17 00:00:00 2001 From: Shish Date: Sun, 3 Nov 2019 19:49:52 +0000 Subject: [PATCH] more version --- ext/artists/main.php | 6 ++---- ext/blocks/main.php | 4 ++-- ext/comment/main.php | 18 +++++++++--------- ext/favorites/main.php | 8 ++++---- ext/handle_video/main.php | 6 ------ ext/image_hash_ban/main.php | 4 ++-- ext/log_db/main.php | 6 +++--- ext/not_a_tag/main.php | 4 ++-- ext/notes/main.php | 5 ++--- ext/numeric_score/main.php | 8 ++++---- ext/pools/main.php | 8 ++++---- ext/relationships/main.php | 10 ++++------ ext/report_image/main.php | 4 ++-- ext/source_history/main.php | 12 ++++++------ ext/tag_history/main.php | 12 ++++++------ ext/tips/main.php | 5 ++--- ext/wiki/main.php | 8 ++++---- 17 files changed, 58 insertions(+), 70 deletions(-) diff --git a/ext/artists/main.php b/ext/artists/main.php index 062c8df5..e38edd23 100644 --- a/ext/artists/main.php +++ b/ext/artists/main.php @@ -60,7 +60,7 @@ class Artists extends Extension { global $config, $database; - if ($config->get_int("ext_artists_version") < 1) { + if ($this->get_version("ext_artists_version") < 1) { $database->create_table("artists", " id SCORE_AIPK, user_id INTEGER NOT NULL, @@ -104,9 +104,7 @@ class Artists extends Extension $database->execute("ALTER TABLE images ADD COLUMN author VARCHAR(255) NULL"); $config->set_int("artistsPerPage", 20); - $config->set_int("ext_artists_version", 1); - - log_info("artists", "extension installed"); + $this->set_version("ext_artists_version", 1); } } diff --git a/ext/blocks/main.php b/ext/blocks/main.php index 1641548e..bfb477c2 100644 --- a/ext/blocks/main.php +++ b/ext/blocks/main.php @@ -5,7 +5,7 @@ class Blocks extends Extension public function onDatabaseUpgrade(DatabaseUpgradeEvent $event) { global $config, $database; - if ($config->get_int("ext_blocks_version") < 1) { + if ($this->get_version("ext_blocks_version") < 1) { $database->create_table("blocks", " id SCORE_AIPK, pages VARCHAR(128) NOT NULL, @@ -15,7 +15,7 @@ class Blocks extends Extension content TEXT NOT NULL "); $database->execute("CREATE INDEX blocks_pages_idx ON blocks(pages)", []); - $config->set_int("ext_blocks_version", 1); + $this->set_version("ext_blocks_version", 1); } } diff --git a/ext/comment/main.php b/ext/comment/main.php index 0a65afd6..c19938ea 100644 --- a/ext/comment/main.php +++ b/ext/comment/main.php @@ -103,9 +103,9 @@ class CommentList extends Extension public function onDatabaseUpgrade(DatabaseUpgradeEvent $event) { global $config, $database; - if ($config->get_int("ext_comments_version") < 3) { + if ($this->get_version("ext_comments_version") < 3) { // shortcut to latest - if ($config->get_int("ext_comments_version") < 1) { + if ($this->get_version("ext_comments_version") < 1) { $database->create_table("comments", " id SCORE_AIPK, image_id INTEGER NOT NULL, @@ -119,11 +119,11 @@ class CommentList extends Extension $database->execute("CREATE INDEX comments_image_id_idx ON comments(image_id)", []); $database->execute("CREATE INDEX comments_owner_id_idx ON comments(owner_id)", []); $database->execute("CREATE INDEX comments_posted_idx ON comments(posted)", []); - $config->set_int("ext_comments_version", 3); + $this->set_version("ext_comments_version", 3); } // the whole history - if ($config->get_int("ext_comments_version") < 1) { + if ($this->get_version("ext_comments_version") < 1) { $database->create_table("comments", " id SCORE_AIPK, image_id INTEGER NOT NULL, @@ -133,17 +133,17 @@ class CommentList extends Extension comment TEXT NOT NULL "); $database->execute("CREATE INDEX comments_image_id_idx ON comments(image_id)", []); - $config->set_int("ext_comments_version", 1); + $this->set_version("ext_comments_version", 1); } - if ($config->get_int("ext_comments_version") == 1) { + if ($this->get_version("ext_comments_version") == 1) { $database->Execute("CREATE INDEX comments_owner_ip ON comments(owner_ip)"); $database->Execute("CREATE INDEX comments_posted ON comments(posted)"); - $config->set_int("ext_comments_version", 2); + $this->set_version("ext_comments_version", 2); } - if ($config->get_int("ext_comments_version") == 2) { - $config->set_int("ext_comments_version", 3); + if ($this->get_version("ext_comments_version") == 2) { + $this->set_version("ext_comments_version", 3); $database->Execute("ALTER TABLE comments ADD FOREIGN KEY (image_id) REFERENCES images(id) ON DELETE CASCADE"); $database->Execute("ALTER TABLE comments ADD FOREIGN KEY (owner_id) REFERENCES users(id) ON DELETE RESTRICT"); } diff --git a/ext/favorites/main.php b/ext/favorites/main.php index 10f4f784..52334994 100644 --- a/ext/favorites/main.php +++ b/ext/favorites/main.php @@ -202,7 +202,7 @@ class Favorites extends Extension global $config; global $database; - if ($config->get_int("ext_favorites_version") < 1) { + if ($this->get_version("ext_favorites_version") < 1) { $database->Execute("ALTER TABLE images ADD COLUMN favorites INTEGER NOT NULL DEFAULT 0"); $database->Execute("CREATE INDEX images__favorites ON images(favorites)"); $database->create_table("user_favorites", " @@ -214,10 +214,10 @@ class Favorites extends Extension FOREIGN KEY (image_id) REFERENCES images(id) ON DELETE CASCADE "); $database->execute("CREATE INDEX user_favorites_image_id_idx ON user_favorites(image_id)", []); - $config->set_int("ext_favorites_version", 2); + $this->set_version("ext_favorites_version", 2); } - if ($config->get_int("ext_favorites_version") < 2) { + if ($this->get_version("ext_favorites_version") < 2) { log_info("favorites", "Cleaning user favourites"); $database->Execute("DELETE FROM user_favorites WHERE user_id NOT IN (SELECT id FROM users)"); $database->Execute("DELETE FROM user_favorites WHERE image_id NOT IN (SELECT id FROM images)"); @@ -225,7 +225,7 @@ class Favorites extends Extension log_info("favorites", "Adding foreign keys to user favourites"); $database->Execute("ALTER TABLE user_favorites ADD FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE;"); $database->Execute("ALTER TABLE user_favorites ADD FOREIGN KEY (image_id) REFERENCES images(id) ON DELETE CASCADE;"); - $config->set_int("ext_favorites_version", 2); + $this->set_version("ext_favorites_version", 2); } } diff --git a/ext/handle_video/main.php b/ext/handle_video/main.php index d5220d31..f91fd43c 100644 --- a/ext/handle_video/main.php +++ b/ext/handle_video/main.php @@ -15,12 +15,6 @@ class VideoFileHandler extends DataHandlerExtension { global $config; - if ($config->get_int("ext_handle_video_version") < 1) { - // This used to set the ffmpeg path. It does not do this anymore, that is now in the base graphic extension. - $config->set_int("ext_handle_video_version", 1); - log_info("handle_video", "extension installed"); - } - $config->set_default_bool('video_playback_autoplay', true); $config->set_default_bool('video_playback_loop', true); } diff --git a/ext/image_hash_ban/main.php b/ext/image_hash_ban/main.php index 01242973..5ebf8142 100644 --- a/ext/image_hash_ban/main.php +++ b/ext/image_hash_ban/main.php @@ -27,14 +27,14 @@ class ImageBan extends Extension public function onDatabaseUpgrade(DatabaseUpgradeEvent $event) { global $config, $database; - if ($config->get_int("ext_imageban_version") < 1) { + if ($this->get_version("ext_imageban_version") < 1) { $database->create_table("image_bans", " id SCORE_AIPK, hash CHAR(32) NOT NULL, date TIMESTAMP DEFAULT CURRENT_TIMESTAMP, reason TEXT NOT NULL "); - $config->set_int("ext_imageban_version", 1); + $this->set_version("ext_imageban_version", 1); } } diff --git a/ext/log_db/main.php b/ext/log_db/main.php index 73a77c36..9105ae15 100644 --- a/ext/log_db/main.php +++ b/ext/log_db/main.php @@ -12,7 +12,7 @@ class LogDatabase extends Extension { global $config, $database; - if ($config->get_int("ext_log_database_version") < 1) { + if ($this->get_version("ext_log_database_version") < 1) { $database->create_table("score_log", " id SCORE_AIPK, date_sent TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, @@ -23,7 +23,7 @@ class LogDatabase extends Extension message TEXT NOT NULL "); //INDEX(section) - $config->set_int("ext_log_database_version", 1); + $this->set_version("ext_log_database_version", 1); } } @@ -141,7 +141,7 @@ class LogDatabase extends Extension $username = ($user && $user->name) ? $user->name : "null"; // not installed yet... - if ($config->get_int("ext_log_database_version") < 1) { + if ($this->get_version("ext_log_database_version") < 1) { return; } diff --git a/ext/not_a_tag/main.php b/ext/not_a_tag/main.php index b142158c..bcd55bd5 100644 --- a/ext/not_a_tag/main.php +++ b/ext/not_a_tag/main.php @@ -10,12 +10,12 @@ class NotATag extends Extension public function onDatabaseUpgrade(DatabaseUpgradeEvent $event) { global $config, $database; - if ($config->get_int("ext_notatag_version") < 1) { + if ($this->get_version("ext_notatag_version") < 1) { $database->create_table("untags", " tag VARCHAR(128) NOT NULL PRIMARY KEY, redirect VARCHAR(255) NOT NULL "); - $config->set_int("ext_notatag_version", 1); + $this->set_version("ext_notatag_version", 1); } } diff --git a/ext/notes/main.php b/ext/notes/main.php index 651967e9..11cbdcca 100644 --- a/ext/notes/main.php +++ b/ext/notes/main.php @@ -7,7 +7,7 @@ class Notes extends Extension global $config, $database; // shortcut to latest - if ($config->get_int("ext_notes_version") < 1) { + if ($this->get_version("ext_notes_version") < 1) { $database->Execute("ALTER TABLE images ADD COLUMN notes INTEGER NOT NULL DEFAULT 0"); $database->create_table("notes", " id SCORE_AIPK, @@ -59,8 +59,7 @@ class Notes extends Extension $config->set_int("notesRequestsPerPage", 20); $config->set_int("notesHistoriesPerPage", 20); - $config->set_int("ext_notes_version", 1); - log_info("notes", "extension installed"); + $this->set_version("ext_notes_version", 1); } } diff --git a/ext/numeric_score/main.php b/ext/numeric_score/main.php index 6c4fd1bf..c4825590 100644 --- a/ext/numeric_score/main.php +++ b/ext/numeric_score/main.php @@ -300,7 +300,7 @@ class NumericScore extends Extension global $database; global $config; - if ($config->get_int("ext_numeric_score_version") < 1) { + if ($this->get_version("ext_numeric_score_version") < 1) { $database->execute("ALTER TABLE images ADD COLUMN numeric_score INTEGER NOT NULL DEFAULT 0"); $database->execute("CREATE INDEX images__numeric_score ON images(numeric_score)"); $database->create_table("numeric_score_votes", " @@ -312,11 +312,11 @@ class NumericScore extends Extension FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE "); $database->execute("CREATE INDEX numeric_score_votes_image_id_idx ON numeric_score_votes(image_id)", []); - $config->set_int("ext_numeric_score_version", 1); + $this->set_version("ext_numeric_score_version", 1); } - if ($config->get_int("ext_numeric_score_version") < 2) { + if ($this->get_version("ext_numeric_score_version") < 2) { $database->execute("CREATE INDEX numeric_score_votes__user_votes ON numeric_score_votes(user_id, score)"); - $config->set_int("ext_numeric_score_version", 2); + $this->set_version("ext_numeric_score_version", 2); } } diff --git a/ext/pools/main.php b/ext/pools/main.php index e87bdf5d..6846006e 100644 --- a/ext/pools/main.php +++ b/ext/pools/main.php @@ -81,7 +81,7 @@ class Pools extends Extension global $config, $database; // Create the database tables - if ($config->get_int("ext_pools_version") < 1) { + if ($this->get_version("ext_pools_version") < 1) { $database->create_table("pools", " id SCORE_AIPK, user_id INTEGER NOT NULL, @@ -110,16 +110,16 @@ class Pools extends Extension FOREIGN KEY (pool_id) REFERENCES pools(id) ON UPDATE CASCADE ON DELETE CASCADE, FOREIGN KEY (user_id) REFERENCES users(id) ON UPDATE CASCADE ON DELETE CASCADE "); - $config->set_int("ext_pools_version", 3); + $this->set_version("ext_pools_version", 3); log_info("pools", "extension installed"); } - if ($config->get_int("ext_pools_version") < 2) { + if ($this->get_version("ext_pools_version") < 2) { $database->Execute("ALTER TABLE pools ADD UNIQUE INDEX (title);"); $database->Execute("ALTER TABLE pools ADD lastupdated TIMESTAMP NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP;"); - $config->set_int("ext_pools_version", 3); // skip 2 + $this->set_version("ext_pools_version", 3); // skip 2 } } diff --git a/ext/relationships/main.php b/ext/relationships/main.php index c211592f..bc209150 100644 --- a/ext/relationships/main.php +++ b/ext/relationships/main.php @@ -23,19 +23,17 @@ class Relationships extends Extension global $config, $database; // Create the database tables - if ($config->get_int("ext_relationships_version") < 1) { + if ($this->get_version("ext_relationships_version") < 1) { $database->execute("ALTER TABLE images ADD parent_id INT"); $database->execute($database->scoreql_to_sql("ALTER TABLE images ADD has_children SCORE_BOOL DEFAULT SCORE_BOOL_N NOT NULL")); $database->execute("CREATE INDEX images__parent_id ON images(parent_id)"); - $config->set_int("ext_relationships_version", 1); - log_info("relationships", "extension installed"); + $this->set_version("ext_relationships_version", 1); } - if ($config->get_int("ext_relationships_version") < 2) { + if ($this->get_version("ext_relationships_version") < 2) { $database->execute("CREATE INDEX images__has_children ON images(has_children)"); - $config->set_int("ext_relationships_version", 2); - log_info("relationships", "extension updated"); + $this->set_version("ext_relationships_version", 2); } } diff --git a/ext/report_image/main.php b/ext/report_image/main.php index 179f7269..f6911d02 100644 --- a/ext/report_image/main.php +++ b/ext/report_image/main.php @@ -176,7 +176,7 @@ class ReportImage extends Extension { global $database, $config; - if ($config->get_int("ext_report_image_version") < 1) { + if ($this->get_version("ext_report_image_version") < 1) { $database->create_table("image_reports", " id SCORE_AIPK, image_id INTEGER NOT NULL, @@ -185,7 +185,7 @@ class ReportImage extends Extension FOREIGN KEY (image_id) REFERENCES images(id) ON DELETE CASCADE, FOREIGN KEY (reporter_id) REFERENCES users(id) ON DELETE CASCADE "); - $config->set_int("ext_report_image_version", 1); + $this->set_version("ext_report_image_version", 1); } } diff --git a/ext/source_history/main.php b/ext/source_history/main.php index c4f50a5c..8bbd5ebe 100644 --- a/ext/source_history/main.php +++ b/ext/source_history/main.php @@ -94,7 +94,7 @@ class SourceHistory extends Extension { global $database, $config; - if ($config->get_int("ext_source_history_version") < 1) { + if ($this->get_version("ext_source_history_version") < 1) { $database->create_table("source_histories", " id SCORE_AIPK, image_id INTEGER NOT NULL, @@ -106,18 +106,18 @@ class SourceHistory extends Extension FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE "); $database->execute("CREATE INDEX source_histories_image_id_idx ON source_histories(image_id)", []); - $config->set_int("ext_source_history_version", 3); + $this->set_version("ext_source_history_version", 3); } - if ($config->get_int("ext_source_history_version") == 1) { + if ($this->get_version("ext_source_history_version") == 1) { $database->Execute("ALTER TABLE source_histories ADD COLUMN user_id INTEGER NOT NULL"); $database->Execute("ALTER TABLE source_histories ADD COLUMN date_set DATETIME NOT NULL"); - $config->set_int("ext_source_history_version", 2); + $this->set_version("ext_source_history_version", 2); } - if ($config->get_int("ext_source_history_version") == 2) { + if ($this->get_version("ext_source_history_version") == 2) { $database->Execute("ALTER TABLE source_histories ADD COLUMN user_ip CHAR(15) NOT NULL"); - $config->set_int("ext_source_history_version", 3); + $this->set_version("ext_source_history_version", 3); } } diff --git a/ext/tag_history/main.php b/ext/tag_history/main.php index 9a25d223..bd0e1bd0 100644 --- a/ext/tag_history/main.php +++ b/ext/tag_history/main.php @@ -95,7 +95,7 @@ class TagHistory extends Extension { global $database, $config; - if ($config->get_int("ext_tag_history_version") < 1) { + if ($this->get_version("ext_tag_history_version") < 1) { $database->create_table("tag_histories", " id SCORE_AIPK, image_id INTEGER NOT NULL, @@ -107,18 +107,18 @@ class TagHistory extends Extension FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE "); $database->execute("CREATE INDEX tag_histories_image_id_idx ON tag_histories(image_id)", []); - $config->set_int("ext_tag_history_version", 3); + $this->set_version("ext_tag_history_version", 3); } - if ($config->get_int("ext_tag_history_version") == 1) { + if ($this->get_version("ext_tag_history_version") == 1) { $database->Execute("ALTER TABLE tag_histories ADD COLUMN user_id INTEGER NOT NULL"); $database->Execute("ALTER TABLE tag_histories ADD COLUMN date_set TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP"); - $config->set_int("ext_tag_history_version", 2); + $this->set_version("ext_tag_history_version", 2); } - if ($config->get_int("ext_tag_history_version") == 2) { + if ($this->get_version("ext_tag_history_version") == 2) { $database->Execute("ALTER TABLE tag_histories ADD COLUMN user_ip CHAR(15) NOT NULL"); - $config->set_int("ext_tag_history_version", 3); + $this->set_version("ext_tag_history_version", 3); } } diff --git a/ext/tips/main.php b/ext/tips/main.php index c794bfa6..14ce130c 100644 --- a/ext/tips/main.php +++ b/ext/tips/main.php @@ -6,7 +6,7 @@ class Tips extends Extension { global $config, $database; - if ($config->get_int("ext_tips_version") < 1) { + if ($this->get_version("ext_tips_version") < 1) { $database->create_table("tips", " id SCORE_AIPK, enable SCORE_BOOL NOT NULL DEFAULT SCORE_BOOL_N, @@ -21,8 +21,7 @@ class Tips extends Extension ["Y", "coins.png", "Do you like this extension? Please support us for developing new ones. Donate through paypal."] ); - $config->set_int("ext_tips_version", 1); - log_info("tips", "extension installed"); + $this->set_version("ext_tips_version", 1); } } diff --git a/ext/wiki/main.php b/ext/wiki/main.php index 70a6e5bf..fee37eed 100644 --- a/ext/wiki/main.php +++ b/ext/wiki/main.php @@ -77,7 +77,7 @@ class Wiki extends Extension { global $database, $config; - if ($config->get_int("ext_wiki_version", 0) < 1) { + if ($this->get_version("ext_wiki_version", 0) < 1) { $database->create_table("wiki_pages", " id SCORE_AIPK, owner_id INTEGER NOT NULL, @@ -90,12 +90,12 @@ class Wiki extends Extension UNIQUE (title, revision), FOREIGN KEY (owner_id) REFERENCES users(id) ON DELETE RESTRICT "); - $config->set_int("ext_wiki_version", 2); + $this->set_version("ext_wiki_version", 2); } - if ($config->get_int("ext_wiki_version") < 2) { + if ($this->get_version("ext_wiki_version") < 2) { $database->Execute("ALTER TABLE wiki_pages ADD COLUMN locked ENUM('Y', 'N') DEFAULT 'N' NOT NULL AFTER REVISION"); - $config->set_int("ext_wiki_version", 2); + $this->set_version("ext_wiki_version", 2); } }