diff options
| author | Peter Thienel <thienel@data-quest.de> | 2024-12-04 09:03:16 +0000 |
|---|---|---|
| committer | David Siegfried <david.siegfried@uni-vechta.de> | 2024-12-04 09:03:16 +0000 |
| commit | 8e5f91deb6a3019c08f28101732b246381cfe65b (patch) | |
| tree | 204a61f1edb4661320525c5ebef5fa2625e17cf3 /db | |
| parent | 7bbe0174bcd1903897a640a7f2cbaa6774e5f3fe (diff) | |
Resolve "Sprachauswahl für Originalfassung der Modul(teil)-Deskriptoren"
Closes #4261
Merge request studip/studip!3091
Diffstat (limited to 'db')
| -rw-r--r-- | db/migrations/6.0.36_step_4261.php | 50 |
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); + } +} |
