[imp] Re: Initial folders and settings for all users

Craig White craigwhite at azapple.com
Thu Mar 3 23:17:09 PST 2005


On Thu, 2005-03-03 at 08:39 +0000, Áncor González Sosa wrote:
> I have a server with both Courier-IMAP and Postfix configured to get users 
> from a MySQL database and have IMP installed with IMAP authentication. 
> Everything worked with a straigthforward installation.
> 
> Now, I have to create all the user accounts. I will do it with a command-line 
> PHP script and I want all user to have the same initial preferences and 
> folders. My user creation script should:
> 
> 1) Create the sent-mail ("Enviados"), deleted ("Papelera"), "Spam" and Drafts 
> ("Borradores") folders.
> 2) Create the default identity with the user name, surname and address
> 3) Set-up a filter for DSPAM marked messages
> 4) Set any other IMP/Horde preference
> 
> It seems that (2) and (3) can be achieved with a hook as seen in
> http://wiki.horde.org/display.php?referrer=HowTo&page=CustomizingPreferences#toc5
> 
----
Because I have written up instructions for usage no to send to OP - I
have uploaded the 'def_user' package to bugs.horde.org

http://bugs.horde.org/ticket/?id=1487

This may be of interest to some - it may not - I guess this is yet to be
determined. I haven't finished the 'horde-utils' that I am working on
yet which I would think would be an important add-on for implementation
of this into an existing setup.

The instructions included with the package uploaded per above...

This is a preliminary implementation of a 'default_user' for horde
preferences. This implementation uses the custom 'hooks.php' to
implement. I think that ultimately, it would make sense to move this out
of hooks.php and give it it's own methodology but for the present time,
this is the simplest way to accomplish this.

The purpose of the 'default_user' is to designate ONE particular user
and his settings. I have chosen the 'first' name listed in the HORDE
CONFIGURATION -> Authentication -> "Which users should be treated as
administrators (root, super-user) by Horde?" - You can override this
setting by following the instructions in the accompanying file called
'def_user_connect.php'

This 'default_user' can set up all sorts of various preferences using
the GUI implementation of setting preferences and these preferences can
be 'adopted' by any other users at first login.

NOTE: User preferences are automatically written to preferences backend
as soon as they log in so any further changes to the 'default_user' are
not going to be incorporated by users who have already logged in and set
their preferences. For this purpose, I am creating a horde-utils module
to 'selectively' remove all users preferences for a particular
attribute.

HOW TO MAKE IT WORK...

There are 3 files that make up this package...
def_user.php
def_user_connect.php
def_user_instructions.txt (this file).

- Put the 2 php files in horde/config subdirectory. Give them the same
owner/group membership as the other files in this directory such as
conf.php and hooks.php.

- At the bottom of hooks.php, insert the following 2 lines...

include '/var/www/html/horde/config/def_user_connect.php';
include '/var/www/html/horde/config/def_user.php';

be sure to change the paths as appropriate for your installation.

- Change the setup in def_user_connect.php if you don't want the
'default_user' to be the first listed in 'admins' per above.

- the reason that I have chosen this method is to provide easy
implementation to hooks.php without 'junking' up the file and obviously,
to turn this off, all you need do is to remove those lines from
hooks.php. Also note that if you have any other 'custom hooks' in this
file, they should be acted upon first since their order in hooks.php
would come first.

- Specific attribute settings in various
'prefs.php' (horde/config/prefs.php - horde/imp/config/prefs.php -
horde/kronolith/config/prefs.php - horde/turba/config/prefs.php - all
you need to do to implement is to add the line
'hook' => 'true';

for example...to incorporate the categories and category_colors of
horde/config/prefs.php from the Administrator to any new user, edit the
appropriate sections like this...

// categories
$_prefs['categories'] = array(
    'value' => '',
    'hook' => true,    ## <- NOTE:
    'locked' => false,
    'shared' => true,
    'type' => 'implicit'
);

// category colors
$_prefs['category_colors'] = array(
    'value' => '',
    'hook' => true,   ## <- NOTE:
    'locked' => false,
    'shared' => true,
    'type' => 'implicit'
);

VERY IMPORTANT THINGS TO CONSIDER...

- some settings aren't appropriate for this such as 'default identity'
settings since you wouldn't want everybody to have their default
identity to have Administrator at mydomain.com for an email reply address.
Consider what's in these settings.

- existing users that have already created their preferences won't
absorb changes - that is why I am writing the 'horde-utils' quasi-
application

- This is only tested with MySQL setup that I am using though it does
use the pear DB abstraction so I would presume it to work with all SQL
backends.

- I have tested with some of the settings in horde/config/prefs.php,
horde/imp/config/prefs.php, horde/kronolith/config/prefs.php and
horde/turba/config/prefs.php - the turba prefs didn't seem to respond as
expected. I have included turba/config/prefs.php -
mnemo/config/prefs.php - nag/config/prefs.php for completeness but
turba's didn't seem to work and I've not tried any nag or mnemo prefs
yet.

- The only way to clear out specific attributes for existing users until
I get a working horde-utils quasi-module would be to directly delete
them from your SQL db - something like (untested)

DELETE ALL WHERE pref_uid != "Administrator" \
AND pref_name = "NAME_OF_ATTRIBUTE";\
| mysql horde -u horde -p

You might want to try this first...just to make sure...

SELECT ALL WHERE pref_uid != "Administrator" \
AND pref_name = "NAME_OF_ATTRIBUTE";\
| mysql horde -u horde -p

- I assume no responsibility for usage or loss of data, this is only my
best effort at accomplishing a specific task and usage of the HORDE
product and it is only offered as my desire to try to give something
back. It is possible that the code and methodology could be improved
upon.

Craig

ps - the instructions which I uploaded had the following mistakes
(corrected in the body of this message)...

I neglected to put the semi-colons at the end of these lines...

include '/var/www/html/horde/config/def_user_connect.php';
include '/var/www/html/horde/config/def_user.php';

I had single quotes around the word true - which shouldn't be used...and
they should be...

    'hook' => true,



More information about the imp mailing list