aboutsummaryrefslogtreecommitdiff
path: root/db/migrations/5.5.16_add_tooltip_fields_for_login.php
blob: a375b3ffcf82145e00361e8b8e9a02df32eff148 (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
<?php


class AddTooltipFieldsForLogin extends Migration
{
    public function description()
    {
        return 'Creates config for login username and password tooltip texts';
    }

    public function up()
    {
        $query = 'INSERT INTO `config` (`field`, `value`, `type`, `section`, `range`, `description`, `mkdate`, `chdate`)
                  VALUES (:name, :value, :type, :section, :range, :description, UNIX_TIMESTAMP(), UNIX_TIMESTAMP())';
        $statement = DBManager::get()->prepare($query);
        $statement->execute([
            'name'          => 'USERNAME_TOOLTIP_TEXT',
            'value'         => '',
            'type'          => 'i18n',
            'section'       => 'Loginseite',
            'range'         => 'global',
            'description'   => 'Text für den Tooltip des Benutzernamens auf der Loginseite'
        ]);

        $statement->execute([
            'name'          => 'PASSWORD_TOOLTIP_TEXT',
            'value'         => '',
            'type'          => 'i18n',
            'section'       => 'Loginseite',
            'range'         => 'global',
            'description'   => 'Text für den Tooltip des Benutzernamens auf der Loginseite'
        ]);

    }

    public function down()
    {
        $query = "DELETE `config`, `config_values`, `i18n`
                  FROM `config`
                  LEFT JOIN `config_values` USING (`field`)
                  LEFT JOIN `i18n`
                    ON `table` = 'config'
                        AND `field` = 'value'
                        AND `object_id` = MD5(`config`.`field`)
                  WHERE `field` IN (
                       'USERNAME_TOOLTIP_TEXT',
                       'PASSWORD_TOOLTIP_TEXT'
                  )";
        DBManager::get()->exec($query);
    }
}