aboutsummaryrefslogtreecommitdiff
path: root/db/migrations/1.83_tic1992_privacydefaults.php
blob: 6cf7b0eb8f461020b984de67fc5ec5dd97f8a1a2 (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
<?php

class tic1992PrivacyDefaults extends Migration
{

    static $config_entries = [
        // Private chat room visible per default?
        [
            'name'        => 'CHAT_VISIBILITY_DEFAULT',
            'type'        => 'boolean',
            'value'       => 1,
            'description' => 'Ist der private Chatraum sichtbar, falls der Nutzer nichts anderes eingestellt hat?'
        ],
        // E-Mail address visible per default?
        [
            'name'        => 'EMAIL_VISIBILITY_DEFAULT',
            'type'        => 'boolean',
            'value'       => 1,
            'description' => 'Ist die eigene Emailadresse sichtbar, falls der Nutzer nichts anderes eingestellt hat?'
        ],
        // Private chat room visible per default?
        [
            'name'        => 'ONLINE_VISIBILITY_DEFAULT',
            'type'        => 'boolean',
            'value'       => 1,
            'description' => 'Sind Nutzer sichtbar in der Wer ist online-Liste, falls sie nichts anderes eingestellt haben?'
        ],
        // Private chat room visible per default?
        [
            'name'        => 'SEARCH_VISIBILITY_DEFAULT',
            'type'        => 'boolean',
            'value'       => 1,
            'description' => 'Sind Nutzer auffindbar in der Personensuche, falls sie nichts anderes eingestellt haben?'
        ]
    ];

    function description()
    {
        return 'add default privacy settings';
    }

    function up()
    {
        $db = DBManager::get();
        $query = $db->prepare("INSERT INTO `config` (`config_id`, `parent_id`, `field`, `value`, `is_default`, `type`, `range`, `section`, `position`, `mkdate`, `chdate`, `description`, `comment`, `message_template`) VALUES (MD5(?), '', ?, ?, '1', ?, 'global', 'privacy', '0', UNIX_TIMESTAMP(), UNIX_TIMESTAMP(), ?, '', '')");

        // insert new configuration entries
        foreach (self::$config_entries as $entry) {
            $query->execute([$entry['name'], $entry['name'], $entry['value'], $entry['type'], $entry['description']]);
        }

        // remove old default entry with user id 'studip'
        $db->exec("DELETE FROM `user_visibility` WHERE `user_id`='studip'");

    }

    function down()
    {
        $db = DBManager::get();
        $query = $db->prepare("DELETE FROM `config` WHERE `field` = ?");

        foreach (self::$config_entries as $entry) {
            $query->execute([$entry['name']]);
        }

        // insert default values
        $db->exec("INSERT INTO `user_visibility` VALUES ('studip', 1, 1, 1, 1, '', 0, ".time().")");

    }
}
?>