aboutsummaryrefslogtreecommitdiff
path: root/db/migrations/5.2.2_oer_material_suggestion.php
blob: 14ff1c5a22118c963ae4fac7cc99c12d16752d05 (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
<?php
class OerMaterialSuggestion extends Migration
{
    public function description()
    {
        return "Adds config option to enable suggestions";
    }

    public function up()
    {
        $query = "INSERT IGNORE INTO `config`
                  SET `field` = :field,
                      `value` = :value,
                      `type` = :type,
                      `range` = :range,
                      `section` = :section,
                      `mkdate` = UNIX_TIMESTAMP(),
                      `chdate` = UNIX_TIMESTAMP(),
                      `description` = :description";
        $config_statement = DBManager::get()->prepare($query);

        $config_statement->execute([
            ':field'       => 'OER_ENABLE_SUGGESTIONS',
            ':value'       => '1',
            ':type'        => 'boolean',
            ':range'       => 'global',
            ':section'     => 'OERCampus',
            ':description' => 'Studierendenvorschläge erlauben?',
        ]);
    }

    public function down()
    {
        $query = "DELETE `config`, `config_values`
                  FROM `config`
                  LEFT JOIN `config_values` USING (`field`)
                  WHERE `field` = 'OER_ENABLE_SUGGESTIONS'";
        DBManager::get()->exec($query);
    }

}