1<?php
2/**
3 * Django application config
4 *
5 */
6/** @noinspection SqlResolve */
7$data = array(
8    'passcrypt' => 'djangopbkdf2_sha256',
9    'conf' => array(
10        'select-user' => '
11            SELECT id AS uid,
12                   username AS "user",
13                   CONCAT_WS(\' \', first_name, last_name) AS name,
14                   password AS hash,
15                   email AS mail
16              FROM auth_user
17             WHERE username = :user
18        ',
19        'select-user-groups' => '
20            SELECT G.name AS "group"
21              FROM auth_group G, auth_user_groups UG
22             WHERE UG.user_id = :uid
23               AND UG.group_id = G.id
24        ',
25        'select-groups' => '
26            SELECT id AS gid, name AS "group"
27              FROM auth_group
28        ',
29        'insert-user' => '
30            INSERT INTO auth_user
31                   (password, is_superuser, username, first_name, last_name, email, is_staff, is_active, date_joined)
32                   VALUES (:hash, false, :user, SPLIT_PART(:name,\' \',1), SPLIT_PART(:name,\' \',2), :mail, false, true, NOW())
33        ',
34        'delete-user' => '
35            DELETE FROM auth_user_user_permissions
36             WHERE user_id = :uid
37            ;
38            DELETE FROM auth_user
39             WHERE id = :uid
40        ',
41        'list-users' => '
42            SELECT DISTINCT U.username AS "user"
43              FROM auth_user U, auth_user_groups UG, auth_group G
44             WHERE U.id = UG.user_id
45               AND G.id = UG.group_id
46               AND G.name LIKE :group
47               AND U.username LIKE :user
48               AND CONCAT_WS(\' \', U.first_name, U.last_name) LIKE :name
49               AND U.email LIKE :mail
50          ORDER BY username
51             LIMIT :limit
52            OFFSET :start
53        ',
54        'count-users' => '
55            SELECT COUNT(DISTINCT U.username) AS count
56              FROM auth_user U, auth_user_groups UG, auth_group G
57             WHERE U.id = UG.user_id
58               AND G.id = UG.group_id
59               AND G.name LIKE :group
60               AND U.username LIKE :user
61               AND CONCAT_WS(\' \', U.first_name, U.last_name) LIKE :name
62               AND U.email LIKE :mail
63        ',
64        'update-user-info' => '
65            UPDATE auth_user
66               SET first_name = SPLIT_PART(:name,\' \',1),
67                   last_name = SPLIT_PART(:name,\' \',2),
68                   email = :mail
69             WHERE id = :uid
70        ',
71        'update-user-login' => '
72            UPDATE auth_user
73               SET username = :newlogin
74             WHERE id = :uid
75        ',
76        'update-user-pass' => '
77            UPDATE auth_user
78               SET password = :hash
79             WHERE id = :uid
80        ',
81        'insert-group' => '
82            INSERT INTO auth_group (name) VALUES (:group)
83        ',
84        'join-group' => '
85            INSERT INTO auth_user_groups (user_id, group_id) VALUES (:uid, :gid)
86        ',
87        'leave-group' => '
88            DELETE FROM auth_user_groups
89             WHERE user_id = :uid
90               AND group_id = :gid
91        ',
92    ),
93    'users' => array(
94        array(
95            'user' => 'test-billing',
96            'pass' => 'P4zzW0rd!',
97            'name' => 'Joana Gröschel',
98            'mail' => 'jg@billing.com',
99            'grps' =>
100                array(
101                    0 => 'Billing',
102                ),
103        ),
104        array(
105            'user' => 'test-kunde',
106            'pass' => 'P4zzW0rd!',
107            'name' => 'Niels Buchberger',
108            'mail' => 'ng@kunde.com',
109            'grps' =>
110                array(
111                    0 => 'Kunden',
112                ),
113        ),
114        array(
115            'user' => 'test-mitarbeiter',
116            'pass' => 'P4zzW0rd!',
117            'name' => 'Claus Wernke',
118            'mail' => 'cw@mitarbeiter.com',
119            'grps' =>
120                array(
121                    0 => 'Mitarbeiter',
122                ),
123        ),
124        array(
125            'user' => 'test-projektleiter',
126            'pass' => 'P4zzW0rd!',
127            'name' => 'Sascha Weiher',
128            'mail' => 'sw@projektleiter.com',
129            'grps' =>
130                array(
131                    0 => 'Projektleiter',
132                ),
133        ),
134    ),
135);
136
137// passwords in the dump use the newest format, we need PHP support for that
138if(!function_exists('hash_pbkdf2') || !in_array('sha256', hash_algos())){
139    $data = 'missing pbkdf2 hash support to check passwords - django test has to be skipped';
140}
141