From 64ccc32e408b7c551d066159811062c82e40eba3 Mon Sep 17 00:00:00 2001 From: Elmar Ludwig <elmar.ludwig@uni-osnabrueck.de> Date: Tue, 8 Feb 2022 13:12:32 +0000 Subject: [PATCH] drop unused help system settings, fixes #655 --- cli/Commands/HelpContent/Migrate.php | 14 ---- .../1.150_help_tours_and_content.php | 2 +- db/migrations/5.1.20_drop_help_settings.php | 64 +++++++++++++++++++ lib/models/HelpContent.class.php | 3 - 4 files changed, 65 insertions(+), 18 deletions(-) create mode 100644 db/migrations/5.1.20_drop_help_settings.php diff --git a/cli/Commands/HelpContent/Migrate.php b/cli/Commands/HelpContent/Migrate.php index 8ab790a00f1..00a620b0d61 100644 --- a/cli/Commands/HelpContent/Migrate.php +++ b/cli/Commands/HelpContent/Migrate.php @@ -94,20 +94,6 @@ class Migrate extends Command } } - if (count($count)) { - if (!\Config::get()->getValue('HELP_CONTENT_CURRENT_VERSION')) { - \Config::get()->create('HELP_CONTENT_CURRENT_VERSION', [ - 'value' => $version, - 'is_default' => 0, - 'type' => 'string', - 'range' => 'global', - 'section' => 'global', - 'description' => _('Aktuelle Version der Helpbar-Einträge in Stud.IP'), - ]); - } else { - \Config::get()->store('HELP_CONTENT_CURRENT_VERSION', $version); - } - } $io->success('help content added for ' . count($count) . ' routes.'); return Command::SUCCESS; } diff --git a/db/migrations/1.150_help_tours_and_content.php b/db/migrations/1.150_help_tours_and_content.php index bb33622c42d..a0a046a28f2 100644 --- a/db/migrations/1.150_help_tours_and_content.php +++ b/db/migrations/1.150_help_tours_and_content.php @@ -25,7 +25,7 @@ class HelpToursAndContent extends Migration 'type' => 'string', 'range' => 'global', 'section' => 'global', - 'description' => _('Aktuelle Version der Helpbar-Einträge in Stud.IP') + 'description' => 'Aktuelle Version der Helpbar-Einträge in Stud.IP' ]); } else { Config::get()->store('HELP_CONTENT_CURRENT_VERSION', $version); diff --git a/db/migrations/5.1.20_drop_help_settings.php b/db/migrations/5.1.20_drop_help_settings.php new file mode 100644 index 00000000000..041837702b4 --- /dev/null +++ b/db/migrations/5.1.20_drop_help_settings.php @@ -0,0 +1,64 @@ +<?php + +class DropHelpSettings extends Migration +{ + public function description() + { + return 'Drop unused help system settings'; + } + + public function up() + { + $settings = [ + 'EXTERNAL_HELP', + 'EXTERNAL_HELP_LOCATIONID', + 'EXTERNAL_HELP_URL', + 'HELP_CONTENT_CURRENT_VERSION' + ]; + // remove config entries + $query = 'DELETE `config`, `config_values` + FROM `config` LEFT JOIN `config_values` USING (`field`) + WHERE `field` IN (?)'; + DBManager::get()->execute($query, [$settings]); + } + + public function down() + { + // create config entries + $query = 'INSERT INTO `config` (`field`, `value`, `type`, `range`, `section`, `mkdate`, `chdate`, `description`) + VALUES (:name, :value, :type, :range, :section, UNIX_TIMESTAMP(), UNIX_TIMESTAMP(), :description)'; + $statement = DBManager::get()->prepare($query); + $statement->execute([ + ':name' => 'EXTERNAL_HELP', + ':description' => 'Schaltet das externe Hilfesystem ein', + ':section' => '', + ':range' => 'global', + ':type' => 'boolean', + ':value' => '1' + ]); + $statement->execute([ + ':name' => 'EXTERNAL_HELP_LOCATIONID', + ':description' => 'Eine eindeutige ID zur Identifikation der gewünschten Hilfeseiten, leer bedeutet Standardhilfe', + ':section' => '', + ':range' => 'global', + ':type' => 'string', + ':value' => 'default' + ]); + $statement->execute([ + ':name' => 'EXTERNAL_HELP_URL', + ':description' => 'URL Template für das externe Hilfesystem', + ':section' => '', + ':range' => 'global', + ':type' => 'string', + ':value' => 'https://hilfe.studip.de/index.php/%s' + ]); + $statement->execute([ + ':name' => 'HELP_CONTENT_CURRENT_VERSION', + ':description' => 'Aktuelle Version der Helpbar-Einträge in Stud.IP', + ':section' => 'global', + ':range' => 'global', + ':type' => 'string', + ':value' => '3.1' + ]); + } +} diff --git a/lib/models/HelpContent.class.php b/lib/models/HelpContent.class.php index 5a45970ddf7..ccac2a2b94d 100644 --- a/lib/models/HelpContent.class.php +++ b/lib/models/HelpContent.class.php @@ -59,9 +59,6 @@ class HelpContent extends SimpleORMap { if (!$language) { $language = mb_substr(Config::get()->DEFAULT_LANGUAGE, 0, 2); } - $version = Config::get()->getValue('HELP_CONTENT_CURRENT_VERSION'); - if (!$version) - return []; $route = get_route($route); $query = "SELECT * FROM help_content -- GitLab