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 | |
4dccdc01 |
20 | For this to work you must have the PEAR classes installed, these are |
21 | part of PHP. Once these are installed you must have sure the directory |
22 | containg them is a part of your PHP include path. See the PHP |
23 | documentation for information on how to do that. |
24 | Under Mandrake Linux the PEAR classes are installed as part of the |
25 | php-devel package and under FreeBSD they are installed as part of |
26 | the mod_php4 or php4 port/package. I'm afraid I have no information on |
27 | other systems at the present time. |
6ff1c690 |
28 | |
29 | |
30 | Configuring addressbooks in database |
31 | ------------------------------------ |
32 | |
33 | First you need to create a database and a table to store the data in. |
34 | Create a database user with access to read and write in that table. |
35 | |
36 | For MySQL you would normally do something like: |
37 | |
38 | (from the command line) |
39 | # mysqladmin create squirrelmail |
40 | |
41 | (from the mysql client) |
42 | mysql> GRANT select,insert,update,delete ON squirrelmail.* |
588f1ca4 |
43 | TO squirreluser@localhost IDENTIFIED BY 'sqpassword'; |
6ff1c690 |
44 | |
45 | The table structure should be similar to this (for MySQL): |
46 | |
47 | CREATE TABLE address ( |
1e63b430 |
48 | owner varchar(128) DEFAULT '' NOT NULL, |
6ff1c690 |
49 | nickname varchar(16) DEFAULT '' NOT NULL, |
50 | firstname varchar(128) DEFAULT '' NOT NULL, |
51 | lastname varchar(128) DEFAULT '' NOT NULL, |
52 | email varchar(128) DEFAULT '' NOT NULL, |
53 | label varchar(255), |
54 | PRIMARY KEY (owner,nickname), |
55 | KEY firstname (firstname,lastname) |
56 | ); |
57 | |
58 | |
4f40a59d |
59 | Next, edit your configuration so that the address book DSN (Data Source |
60 | Name) is specified, this can be done using either conf.pl or via the |
61 | administration plugin. The DSN should look something like: |
6ff1c690 |
62 | |
63 | $addrbook_dsn = 'mysql://squirreluser:sqpassword@localhost/squirrelmail'; |
64 | |
65 | From now on all users' personal addressbooks will be stored in a |
66 | database. |
67 | |
68 | |
69 | |
70 | Configuring preferences in database |
71 | ----------------------------------- |
72 | |
73 | There is no easy way to do this yet. You will have to remove |
74 | functions/prefs.php and replace it with functions/db_prefs.php. Then |
75 | edit the new functions/prefs.php (db_prefs.php) and change the $DSN to |
76 | point to a database you create (can be the same you use for |
77 | addressbooks). Create a table similar to this (for MySQL): |
78 | |
79 | CREATE TABLE userprefs ( |
1e63b430 |
80 | user varchar(128) DEFAULT '' NOT NULL, |
6ff1c690 |
81 | prefkey varchar(64) DEFAULT '' NOT NULL, |
1e63b430 |
82 | prefval BLOB DEFAULT '' NOT NULL, |
6ff1c690 |
83 | PRIMARY KEY (user,prefkey) |
84 | ); |
85 | |
86 | |
87 | Default preferences can be set by altering the $default array in |
88 | prefs.php (db_prefs.php). |
89 | |