xref: /dokuwiki/conf/mysql.conf.php.example (revision 3ff230f7a83037178c07da3e76b11633d3e76e3f)
1<?php
2/*
3  This is an example configuration for the mysql auth module.
4
5  This SQL statements are optimized for following table structure.
6  If you use a different one you have to change them accordingly.
7  See comments of every statement for details.
8
9  TABLE users
10      uid   login   pass   firstname   lastname   email
11
12  TABLE groups
13      gid   name
14
15  TABLE usergroup
16      uid   gid
17
18  To use this configuration you have to copy them to local.php
19  or at least include this file in local.php.
20 */
21
22
23/* Normally password encryptionis done by DokuWiki (recommended) but for
24 * some reasons it might be usefull to let the database do the encryption.
25 * Set 'encryptPass' to '1' and the cleartext password is forwarded to
26 * the database, otherwise the encrypted one.
27 */
28$conf['auth']['mysql']['encryptPass'] = 0;
29
30/* Multiple table operations will be protected by locks. This array tolds
31 * the module which tables to lock. If you use any aliases for table names
32 * these array must also contain these aliases. Any unamed alias will cause
33 * a warning suring operation. See the example below.
34 */
35$conf['auth']['mysql']['TablesToLock']= array("users", "users AS u","groups", "groups AS g", "usergroup", "usergroup AS ug");
36
37/* This statement should return the database index of a given user name.
38 * The module will access the index with the name 'id' so a alias might be
39 * necessary.
40 * following patters will be replaced:
41 *   %u    user name
42 */
43$conf['auth']['mysql']['getUserID']   = "SELECT uid AS id FROM users WHERE login='%u'";
44
45/* This statement should return the database index of a given group name.
46 * The module will access the index with the name 'id' so a alias might be
47 * necessary.
48 * following patters will be replaced:
49 *   %g    group name
50 */
51$conf['auth']['mysql']['getGroupID']  = "SELECT gid AS id FROM groups WHERE name='%g'";
52
53/* This statement is used to grant or deny access to the wiki. The result should
54 * be a table with exact one line containing at least the password of the user.
55 * If the result table is empty or contains more than one row, access will be denied.
56 * The module access the password as 'pass' so a alias might be necessary.
57 * following patters will be replaced:
58 *   %u    user name
59 *   %p    encrypted or clear text password (depends on 'encryptPass')
60 *   %g    default group name
61 */
62$conf['auth']['mysql']['checkPass']   = "SELECT pass
63                                         FROM usergroup AS ug
64                                         JOIN users AS u ON u.uid=ug.uid
65                                         JOIN groups AS g ON g.gid=ug.gid
66                                         WHERE login='%u'
67                                         AND name='%g'";
68
69$conf['auth']['mysql']['getGroups']   = "SELECT name as `group`
70                                         FROM groups g, users u, usergroup ug
71                                         WHERE u.uid = ug.uid
72                                         AND g.gid = ug.gid
73                                         AND u.login='%u'";
74$conf['auth']['mysql']['getUserInfo'] = "SELECT pass, CONCAT(firstname,' ',lastname) AS name, email AS mail
75                                         FROM users
76                                         WHERE login='%u'";
77$conf['auth']['mysql']['getUsers']    = "SELECT DISTINCT login AS user
78                                         FROM users AS u
79                                         LEFT JOIN usergroup AS ug ON u.uid=ug.uid
80                                         LEFT JOIN groups AS g ON ug.gid=g.gid";
81
82$conf['auth']['mysql']['SortOrder']   = "ORDER BY login";
83$conf['auth']['mysql']['FilterLogin'] = "login LIKE '%s'";
84$conf['auth']['mysql']['FilterName']  = "CONCAT(firstname,' ',lastname) LIKE '%s'";
85$conf['auth']['mysql']['FilterEmail'] = "email LIKE '%s'";
86$conf['auth']['mysql']['FilterGroup'] = "name LIKE '%s'";
87
88$conf['auth']['mysql']['addUser']     = "INSERT INTO users
89                                         (login, pass, email, firstname, lastname)
90                                         VALUES ('%u', '%p', '%e',
91                                         SUBSTRING_INDEX('%n',' ', 1),
92                                         SUBSTRING_INDEX('%n',' ', -1))";
93$conf['auth']['mysql']['delUser']     = "DELETE FROM users
94                                         WHERE uid='%uid'";
95$conf['auth']['mysql']['addGroup']    = "INSERT INTO groups (name)
96                                         VALUES ('%g')";
97$conf['auth']['mysql']['delGroup']    = "DELETE FROM groups
98                                         WHERE gid='%gid'";
99$conf['auth']['mysql']['addUserGroup']= "INSERT INTO usergroup (uid, gid)
100                                         VALUES ('%uid', '%gid')";
101$conf['auth']['mysql']['delUserGroup']= "DELETE FROM usergroup
102                                         WHERE uid='%uid'
103                                         AND gid='%gid'";
104$conf['auth']['mysql']['delUserRefs'] = "DELETE FROM usergroup
105                                         WHERE uid='%uid'";
106?>
107