aboutsummaryrefslogtreecommitdiff
path: root/db/migrations/1.64_step_00199_forced_course_grouping.php
blob: 4fad4ef8dcc843c64bafa90fb2577b80c999cc2d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
<?php
class Step00199ForcedCourseGrouping extends Migration
{

    static $config_entries = [
        [
            'name'        => 'MY_COURSES_FORCE_GROUPING',
            'type'        => 'string',
            'value'       => 'sem_number',
            'description' => 'Legt fest, ob die persönliche Veranstaltungsübersicht systemweit zwangsgruppiert werden soll, wenn keine eigene Gruppierung eingestellt ist. Werte: not_grouped, sem_number, sem_tree_id, sem_status, gruppe, dozent_id.'
        ]
    ];

    function description()
    {
        return 'add configuration entry for forced grouping of My courses for all users who haven\'t grouped for themselves';
    }

    function up()
    {
        $db = DBManager::get();
        $query = $db->prepare("INSERT IGNORE INTO `config` (`config_id`, `parent_id`, `field`, `value`, `is_default`, `type`, `range`, `section`, `position`, `mkdate`, `chdate`, `description`, `comment`, `message_template`) VALUES (MD5(?), '', ?, ?, '1', ?, 'global', '', '0', UNIX_TIMESTAMP(), UNIX_TIMESTAMP(), ?, '', '')");

        // insert new configuration entries
        foreach (self::$config_entries as $entry) {
            $query->execute([$entry['name'], $entry['name'], $entry['value'], $entry['type'], $entry['description']]);
        }
    }

    function down()
    {
        $db = DBManager::get();
        $query = $db->prepare("DELETE FROM `config` WHERE `config_id` = MD5(?)");

        foreach (self::$config_entries as $entry) {
            $query->execute([md5($entry['name'])]);
        }
    }
}
?>