aboutsummaryrefslogtreecommitdiff
path: root/db/migrations/1.212_refactor_config_local.php
blob: 81eb682ffe0685b43dcf834c4c3ebaa633b3df27 (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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
<?php

class RefactorConfigLocal extends Migration
{

    public function description()
    {
        return 'Inserts some entries from the config_local.inc.php and config.inc.php into database.';
    }

    public function up()
    {
        $global_boolean_parameter = [
            "UNI_NAME_CLEAN" => [
                'description' => "Name der Stud.IP-Installation bzw. Hochschule.",
                'type' => "string",
                'default' => "Stud.IP"
            ],
            "STUDIP_INSTALLATION_ID" => [
                'description' => "Unique identifier for installation",
                'type' => "string",
                'default' => "demo-installation"
            ],
            "MEDIA_CACHE_MAX_LENGTH" => [
                'description' => "Maximale Größe von Dateien, die im Media-Cache gecached werden (in Bytes)?",
                'type' => "integer",
                'default' => 1000000
            ],
            "MEDIA_CACHE_LIFETIME" => [
                'description' => "Wieviele Sekunden soll gecached werden?",
                'type' => "integer",
                'default' => 86400
            ],
            "MEDIA_CACHE_MAX_FILES" => [
                'description' => "Wieviele Dateien sollen maximal gecached werden?",
                'type' => "integer",
                'default' => 3000
            ],
            "XSLT_ENABLE" => [
                'description' => "Soll Export mit XSLT angeschaltet sein?",
                'type' => "boolean",
                'default' => 1
            ],
            "FOP_ENABLE" => [
                'description' => "Soll Export mit FOP erlaubt sein?",
                'type' => "boolean",
                'default' => 1
            ],
            "EXTERN_SRI_ENABLE" => [
                'description' => "Allow the usage of SRI-interface (Stud.IP Remote Include)",
                'type' => "boolean",
                'default' => 1
            ],
            "EXTERN_SRI_ENABLE_BY_ROOT" => [
                'description' => "Only root allows the usage of SRI-interface for specific institutes",
                'type' => "boolean",
                'default' => 0
            ],
            "EXTERN_ALLOW_ACCESS_WITHOUT_CONFIG" => [
                'description' => "Free access to external pages (without the need of a configuration), independent of SRI settings above",
                'type' => "boolean",
                'default' => 0
            ],
            "SOAP_ENABLE" => [
                'description' => "Schaltet die SOAP-Schnittstelle an.",
                'type' => "boolean",
                'default' => 0
            ],
            "SOAP_USE_PHP5" => [
                'description' => "Sollen PHP-Bibliotheken für SOAP verwendet werden?",
                'type' => "boolean",
                'default' => 0
            ],
            "ALLOW_SELFASSIGN_STUDYCOURSE" => [
                'description' => "If true, students are allowed to set or change their studycourse (studiengang)",
                'type' => "boolean",
                'default' => 1
            ],
            "SHOW_TERMS_ON_FIRST_LOGIN" => [
                'description' => "If true, the user has to accept the terms on his first login (this feature makes only sense, if you use disable ENABLE_SELF_REGISTRATION).",
                'type' => "boolean",
                'default' => 0
            ],
            "CONVERT_IDNA_URL" => [
                'description' => "If true, urls with german \"umlauts\" are converted",
                'type' => "boolean",
                'default' => 1
            ],
            "USER_VISIBILITY_CHECK" => [
                'description' => "Enable presentation of visibility decision texts for users after first login. see lib/include/header.php and lib/user_visible.inc.php for further info",
                'type' => "boolean",
                'default' => 0
            ],
            "USERNAME_REGULAR_EXPRESSION" => [
                'description' => "Regex for allowed characters in usernames",
                'type' => "string",
                'default' => '/^([a-zA-Z0-9_@.-]{4,})$/'
            ],
            "DEFAULT_TIMEZONE" => [
                'description' => "What timezone should be used (default: Europe/Berlin)?",
                'type' => "string",
                'default' => 'Europe/Berlin'
            ],
            "DEFAULT_LANGUAGE" => [
                'description' => "Which language should we use if we can gather no information from user?",
                'type' => "string",
                'default' => 'de_DE'
            ],
            "ALLOW_CHANGE_USERNAME" => [
                'description' => "If true, users are allowed to change their username",
                'type' => "boolean",
                'section' => "permissions",
                'default' => 1
            ],
            "ALLOW_CHANGE_EMAIL" => [
                'description' => "If true, users are allowed to change their email",
                'type' => "boolean",
                'section' => "permissions",
                'default' => 1
            ],
            "ALLOW_CHANGE_NAME" => [
                'description' => "If true, users are allowed to change their name",
                'type' => "boolean",
                'section' => "permissions",
                'default' => 1
            ],
            "ALLOW_CHANGE_TITLE" => [
                'description' => "If true, users are allowed to change their titles",
                'type' => "boolean",
                'section' => "permissions",
                'default' => 1
            ],
            "ENABLE_SELF_REGISTRATION" => [
                'description' => "Should it be possible for an user to register himself",
                'type' => "boolean",
                'section' => "permissions",
                'default' => 1
            ],
            "ENABLE_REQUEST_NEW_PASSWORD_BY_USER" => [
                'description' => "If true, users are able to request a new password themselves",
                'type' => "boolean",
                'section' => "permissions",
                'default' => 1
            ],
            "PHPASS_USE_PORTABLE_HASH" => [
                'description' => "PHPASS_USE_PORTABLE_HASH",
                'type' => "boolean",
                'default' => 0
            ],
            "WEBSERVICES_ENABLE" => [
                'description' => "Schaltet die Webservice-Schnittstelle an.",
                'type' => "boolean",
                'default' => 0
            ],
            "ENABLE_FREE_ACCESS" => [
                'description' => "If true, courses with public access are available",
                'type' => "boolean",
                'default' => 1
            ],
        ];

        $stmt_value = DBManager::get()->prepare("
            INSERT IGNORE INTO config
                (config_id, field, value, is_default, type, `range`, section, mkdate, chdate, description)
            VALUES
                (:config_id, :name, :value, '0', :type, :range, :section, UNIX_TIMESTAMP(), UNIX_TIMESTAMP(), :description)
        ");
        $stmt_default = DBManager::get()->prepare("
            INSERT IGNORE INTO config
                (config_id, field, value, is_default, type, `range`, section, mkdate, chdate, description)
            VALUES
                (:config_id, :name, :value, '1', :type, :range, :section, UNIX_TIMESTAMP(), UNIX_TIMESTAMP(), :description)
        ");

        foreach ($global_boolean_parameter as $name => $data) {
            $option = [
                'config_id'   => md5($name),
                'name'        => $name,
                'type'        => $data['type'],
                'value'       => $data['default'],
                'range'       => 'global',
                'section'     => $data['section'] ?: 'global',
                'description' => $data['description']
            ];
            $stmt_default->execute($option);
            if (isset($GLOBALS[$name]) && $GLOBALS[$name] != $option['value']) {
                $option['config_id'] = md5($name . '___VALUE');
                $option['value'] = $GLOBALS[$name];
                $stmt_value->execute($option);
            }
        }
    }
}