aboutsummaryrefslogtreecommitdiff
path: root/db
diff options
context:
space:
mode:
authorDavid Siegfried <david.siegfried@uni-vechta.de>2024-12-04 12:02:06 +0100
committerDavid Siegfried <david.siegfried@uni-vechta.de>2024-12-04 14:30:40 +0100
commitfcc7482d7d002ae4dcfd095d68ed25d68d0e0adc (patch)
tree459f52a42a239e5594538c62589642ab6dccd227 /db
parent96fa5cdec8a36b7fd6330cbe6580ec6b7f21d3b2 (diff)
Resolve "Sprachauswahl für Originalfassung der Modul(teil)-Deskriptoren", fixes #4261
Diffstat (limited to 'db')
-rw-r--r--db/migrations/6.0.36_step_4261.php50
1 files changed, 50 insertions, 0 deletions
diff --git a/db/migrations/6.0.36_step_4261.php b/db/migrations/6.0.36_step_4261.php
new file mode 100644
index 0000000..0e5fe39
--- /dev/null
+++ b/db/migrations/6.0.36_step_4261.php
@@ -0,0 +1,50 @@
+<?php
+
+final class Step4261 extends Migration
+{
+ public function description()
+ {
+ return 'Add field to module table to store original language.';
+ }
+
+ protected function up()
+ {
+ $db = DBManager::get();
+
+ // retrieve default language from config
+ $config_language = $db->fetchColumn(
+ "SELECT `value` FROM `config` WHERE `field` = 'DEFAULT_LANGUAGE'"
+ );
+ $default_language = $config_language ?? array_keys($GLOBALS['CONTENT_LANGUAGES'])[0] ?? 'de_DE';
+ $db->execute(
+ 'ALTER TABLE `mvv_modul`
+ ADD `original_language` VARCHAR(10) NOT NULL DEFAULT ? COLLATE latin1_bin AFTER `verantwortlich`',
+ [$default_language]
+ );
+
+ $query = "INSERT INTO `config` (`field`, `value`, `type`, `range`, `section`, `mkdate`, `chdate`, `description`)
+ VALUES ('MVV_DEFAULT_LANGUAGE', ?, 'string', 'global', 'mvv', UNIX_TIMESTAMP(), UNIX_TIMESTAMP(), ?)";
+ $db->execute($query,
+ [
+ $default_language,
+ 'Code der Inhalts-Sprache, die als Original-Sprache der Deskriptoren für Module und Modulteile vorausgewählt ist.',
+ ]
+ );
+ }
+
+ protected function down()
+ {
+ $db = DBManager::get();
+
+ $db->exec(
+ "ALTER TABLE `mvv_modul`
+ DROP COLUMN `original_language`"
+ );
+
+ $query = "DELETE `config`, `config_values`
+ FROM `config`
+ LEFT JOIN `config_values` USING (`field`)
+ WHERE `field` = 'MVV_DEFAULT_LANGUAGE'";
+ $db->exec($query);
+ }
+}