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
|
<?php
/**
* @author Kai Rechtern <kairechtern@gmail.com>
*/
class CourseNumberFormatConfig extends Migration
{
/**
* new config options to install
*/
private $options = [
[
'name' => 'COURSE_NUMBER_FORMAT',
'description' => 'Erlaubt das Eintragen eines regulären Ausdrucks zur Validierung einer Veranstaltungsnummer. Im Kommentarfeld kann ein entsprechender Hilfetext hinterlegt werden.',
'section' => 'global',
'type' => 'string',
'value' => ''
]
];
/**
* short description of this migration
*/
public function description()
{
return 'Adds the config entry "COURSE_NUMBER_FORMAT". This allows '
. 'restricting newly entered course numbers to a fixed format.';
}
/**
* perform this migration
*/
public function up()
{
$db = DBManager::get();
$stmt = $db->prepare("
INSERT INTO config
(config_id, field, value, is_default, type, section, mkdate, chdate, description)
VALUES
(MD5(:name), :name, :value, 1, :type, :section, UNIX_TIMESTAMP(), UNIX_TIMESTAMP(), :description)
");
foreach ($this->options as $option) {
$stmt->execute($option);
}
}
/**
* revert this migration
*/
public function down()
{
$db = DBManager::get();
$stmt = $db->prepare("DELETE FROM config WHERE field = :name");
foreach ($this->options as $option) {
$stmt->execute(['name' => $option['name']]);
}
}
}
|