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