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
|
<?
final class TreeChanges extends Migration
{
const FIELDS = [
'RANGE_TREE_PERM',
'SEM_TREE_PERM'
];
public function description()
{
return 'Removes old sem_- and range_tree permission settings and institute assignments for sem_tree entries';
}
protected function up()
{
// Remove config fields for special permissions concerning sem_- and range_tree administration.
DBManager::get()->execute(
"DELETE FROM `config_values` WHERE `field` IN (:fields)",
['fields' => self::FIELDS]
);
DBManager::get()->execute(
"DELETE FROM `config` WHERE `field` IN (:fields)",
['fields' => self::FIELDS]
);
// "Transfer" names from assigned institutes to sem_tree entries.
$stmt = DBManager::get()->prepare("UPDATE `sem_tree` SET `name` = :name WHERE `studip_object_id` = :inst");
$query = "SELECT DISTINCT `Institut_id`, `Name` FROM `Institute` WHERE `Institut_id` IN (
SELECT DISTINCT `studip_object_id` FROM `sem_tree`
)";
foreach (DBManager::get()->fetchAll($query) as $institute) {
$stmt->execute(['name' => $institute['Name'], 'inst' => $institute['Institut_id']]);
}
}
protected function down()
{
// Restore config entries to their defaults.
DBManager::get()->exec("INSERT IGNORE INTO `config`
( `field`, `value`, `type`, `range`, `section`, `mkdate`, `chdate`, `description`)
VALUES (
'RANGE_TREE_ADMIN_PERM', 'root', 'string', 'global', 'permissions',
UNIX_TIMESTAMP(), UNIX_TIMESTAMP(),
'mit welchem Status darf die Einrichtungshierarchie bearbeitet werden (admin oder root)'
), (
'SEM_TREE_ADMIN_PERM', 'root', 'string', 'global', 'permissions',
UNIX_TIMESTAMP(), UNIX_TIMESTAMP() ,
'mit welchem Status darf die Veranstaltungshierarchie bearbeitet werden (admin oder root)'
)");
}
}
|