6ff1c690 |
1 | $Id$ |
2 | |
3 | |
4 | Storing private addressbooks and preferences in a database |
5 | ========================================================== |
6 | |
7 | |
8 | On sites with many users you might want to store your user data in a |
1e63b430 |
9 | database instead of in files. This document describes how to configure |
6ff1c690 |
10 | SquirrelMail to do this. |
11 | |
12 | Methods for storing both personal addressbooks and user preferences in |
1e63b430 |
13 | a database is included as a part of the distribution. |
6ff1c690 |
14 | |
15 | |
16 | |
17 | Configuring PEAR DB |
18 | ------------------- |
19 | |
20 | To work you must install the PEAR classes that is a part of PHP. Make |
21 | sure the directory where the PEAR files are located is a part of your |
22 | include path. See the PHP documentation for info on how to do that. |
23 | |
24 | |
25 | |
26 | Configuring addressbooks in database |
27 | ------------------------------------ |
28 | |
29 | First you need to create a database and a table to store the data in. |
30 | Create a database user with access to read and write in that table. |
31 | |
32 | For MySQL you would normally do something like: |
33 | |
34 | (from the command line) |
35 | # mysqladmin create squirrelmail |
36 | |
37 | (from the mysql client) |
38 | mysql> GRANT select,insert,update,delete ON squirrelmail.* |
39 | TO squrreluser@localhost IDENTIFIED BY 'sqpassword'; |
40 | |
41 | The table structure should be similar to this (for MySQL): |
42 | |
43 | CREATE TABLE address ( |
1e63b430 |
44 | owner varchar(128) DEFAULT '' NOT NULL, |
6ff1c690 |
45 | nickname varchar(16) DEFAULT '' NOT NULL, |
46 | firstname varchar(128) DEFAULT '' NOT NULL, |
47 | lastname varchar(128) DEFAULT '' NOT NULL, |
48 | email varchar(128) DEFAULT '' NOT NULL, |
49 | label varchar(255), |
50 | PRIMARY KEY (owner,nickname), |
51 | KEY firstname (firstname,lastname) |
52 | ); |
53 | |
54 | |
4f40a59d |
55 | Next, edit your configuration so that the address book DSN (Data Source |
56 | Name) is specified, this can be done using either conf.pl or via the |
57 | administration plugin. The DSN should look something like: |
6ff1c690 |
58 | |
59 | $addrbook_dsn = 'mysql://squirreluser:sqpassword@localhost/squirrelmail'; |
60 | |
61 | From now on all users' personal addressbooks will be stored in a |
62 | database. |
63 | |
64 | |
65 | |
66 | Configuring preferences in database |
67 | ----------------------------------- |
68 | |
69 | There is no easy way to do this yet. You will have to remove |
70 | functions/prefs.php and replace it with functions/db_prefs.php. Then |
71 | edit the new functions/prefs.php (db_prefs.php) and change the $DSN to |
72 | point to a database you create (can be the same you use for |
73 | addressbooks). Create a table similar to this (for MySQL): |
74 | |
75 | CREATE TABLE userprefs ( |
1e63b430 |
76 | user varchar(128) DEFAULT '' NOT NULL, |
6ff1c690 |
77 | prefkey varchar(64) DEFAULT '' NOT NULL, |
1e63b430 |
78 | prefval BLOB DEFAULT '' NOT NULL, |
6ff1c690 |
79 | PRIMARY KEY (user,prefkey) |
80 | ); |
81 | |
82 | |
83 | Default preferences can be set by altering the $default array in |
84 | prefs.php (db_prefs.php). |
85 | |