aboutsummaryrefslogtreecommitdiff
path: root/db/migrations/1.316_admin_related_inst.php
blob: f9e5a625b799651ae20befed0e3d3b1db32b7564 (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
<?php

class AdminRelatedInst extends Migration
{
    public function description()
    {
        return 'Add config option to enable admin access to courses of related institutes';
    }

    public function up()
    {
        $query = "INSERT INTO `config` (`field`, `value`, `type`, `range`, `section`, `mkdate`, `chdate`, `description`)
                  VALUES (:name, :value, :type, :range, :section, UNIX_TIMESTAMP(), UNIX_TIMESTAMP(), :description)";

        $statement = DBManager::get()->prepare($query);
        $statement->execute([
            ':name'        => 'ALLOW_ADMIN_RELATED_INST',
            ':description' => 'Admins beteiligter Einrichtungen haben die gleiche Rechte an Veranstaltungen wie die Heimateinrichtung',
            ':section'     => 'global',
            ':range'       => 'global',
            ':type'        => 'boolean',
            ':value'       => '0'
        ]);
    }

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