aboutsummaryrefslogtreecommitdiff
path: root/db/migrations/1.241_step_00320_config_search_navigation.php
blob: fde26ce6aa64afd521ad2378aae19e394c254db9 (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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
<?php
class StEP00320ConfigSearchNavigation extends Migration
{

    function description()
    {
        return 'Adds configuration options of public visibility and navigation for '
        . 'course and module search to global config';
    }

    function up()
    {

        $standard_navigation_options = [
            'courses' => [
                'visible' => true,
                'target'  => 'sidebar'
            ],
            'semtree' => [
                'visible' => true,
                'target'  => 'sidebar'
            ],
            'rangetree' => [
                'visible' => true,
                'target'  => 'sidebar'
            ],
            'module' => [
                'visible' => true,
                'target'  => 'sidebar'
            ]
        ];

        $stmt = DBManager::get()->prepare("INSERT INTO `config`
            (`field`, `value`, `type`, `range`, `section`, `mkdate`, `chdate`, `description`)
            VALUES
            (:name, :value, :type, 'global', 'coursesearch', UNIX_TIMESTAMP(), UNIX_TIMESTAMP(), :desc)
            ON DUPLICATE KEY UPDATE `chdate`=VALUES(`chdate`)");

        $stmt->execute([
                'name' => 'COURSE_SEARCH_NAVIGATION_OPTIONS',
                'value' => json_encode($standard_navigation_options),
                'type' => 'array',
                'desc' => 'Aktivierung und Reihenfolge der Navigationsoptionen in der Veranstaltungssuche'
            ]);
        $stmt->execute([
                'name' => 'COURSE_SEARCH_IS_VISIBLE_NOBODY',
                'value' => false,
                'type' => 'boolean',
                'desc' => 'Soll die Veranstaltungssuche auch für nobody (ohne Anmeldung) sichtbar sein?'
            ]);

    }

    function down()
    {
        DBManager::get()->exec("DELETE FROM `config` WHERE `field` IN (
            'COURSE_SEARCH_NAVIGATION_OPTIONS',
            'COURSE_SEARCH_IS_VISIBLE_NOBODY')"
        );
    }

}