diff options
| author | Thomas Hackl <hackl@data-quest.de> | 2023-06-28 13:27:46 +0000 |
|---|---|---|
| committer | Thomas Hackl <hackl@data-quest.de> | 2023-06-28 13:27:46 +0000 |
| commit | 559ab723fabd4d10f26e7df631808e4cb8d91c9b (patch) | |
| tree | 91ef8cf94eba86973baf3efabca1cdbb8bf6826b /db | |
| parent | b7f0f8bcaad8fefd96fd3e6316377eda53929ad3 (diff) | |
Resolve "Neuentwicklung Verzeichnisstrukturen"
Closes #1664, #2693, and #2692
Merge request studip/studip!1081
Diffstat (limited to 'db')
| -rw-r--r-- | db/migrations/5.4.6_tree_changes.php | 66 |
1 files changed, 66 insertions, 0 deletions
diff --git a/db/migrations/5.4.6_tree_changes.php b/db/migrations/5.4.6_tree_changes.php new file mode 100644 index 0000000..94d015c --- /dev/null +++ b/db/migrations/5.4.6_tree_changes.php @@ -0,0 +1,66 @@ +<? + +final class TreeChanges extends Migration +{ + + const FIELDS = [ + 'RANGE_TREE_PERM', + 'SEM_TREE_PERM' + ]; + + public function description() + { + return 'Removes old sem_- and range_tree permission settings and institute assignments for sem_tree entries'; + } + + protected function up() + { + // Remove config fields for special permissions concerning sem_- and range_tree administration. + DBManager::get()->execute( + "DELETE FROM `config_values` WHERE `field` IN (:fields)", + ['fields' => self::FIELDS] + ); + DBManager::get()->execute( + "DELETE FROM `config` WHERE `field` IN (:fields)", + ['fields' => self::FIELDS] + ); + + // "Transfer" names from assigned institutes to sem_tree entries. + $stmt = DBManager::get()->prepare("UPDATE `sem_tree` SET `name` = :name WHERE `studip_object_id` = :inst"); + $query = "SELECT DISTINCT `Institut_id`, `Name` FROM `Institute` WHERE `Institut_id` IN ( + SELECT DISTINCT `studip_object_id` FROM `sem_tree` + )"; + foreach (DBManager::get()->fetchAll($query) as $institute) { + $stmt->execute(['name' => $institute['Name'], 'inst' => $institute['Institut_id']]); + } + // Remove institute assignments for sem_tree entries. + DBManager::get()->exec("ALTER TABLE `sem_tree` DROP `studip_object_id`"); + } + + protected function down() + { + // Restore config entries to their defaults. + DBManager::get()->exec("INSERT IGNORE INTO `config` + ( `config_id` , `parent_id` , `field` , `value` , + `is_default` , `type` , `range` , `section` , + `position` , `mkdate` , `chdate` , `description` , + `comment` , `message_template` ) + VALUES ( + MD5( 'RANGE_TREE_ADMIN_PERM' ) , '', 'RANGE_TREE_ADMIN_PERM', + 'admin', '1', 'string', 'global', '', '0', + UNIX_TIMESTAMP( ) , UNIX_TIMESTAMP( ) , + 'mit welchem Status darf die Einrichtungshierarchie bearbeitet werden (admin oder root)', '', '' + ), ( + MD5( 'SEM_TREE_ADMIN_PERM' ) , '', 'SEM_TREE_ADMIN_PERM', + 'admin', '1', 'string', 'global', '', '0', UNIX_TIMESTAMP( ) , + UNIX_TIMESTAMP( ) , 'mit welchem Status darf die Veranstaltungshierarchie bearbeitet werden (admin oder root)', '', '' + )"); + + // Add database column for sem_tree institute assignments. + DBManager::get()->exec("ALTER TABLE `sem_tree` ADD + `studip_object_id` CHAR(32) CHARACTER SET latin1 COLLATE latin1_bin NULL DEFAULT NULL AFTER `name`"); + // Add index for studip_object_id. + DBManager::get()->exec("ALTER TABLE `sem_tree` ADD INDEX `studip_object_id` (`studip_object_id`)"); + } + +} |
