[imp] Set a default value and lock "msgflags" in IMP

Michael M Slusarz slusarz at horde.org
Fri Apr 27 20:15:25 UTC 2012


Quoting Sebastian Arcus <shop at open-t.co.uk>:

> I would like to set a default value for "msgflags" in IMP and lock  
> it for all users. More precisely, I want to reset the colour of all  
> flags to white, except the "Unread" flag. What I've worked out so  
> far using the documentation and help in prefs files:
>
> 1. The file to use is imp/config/prefs.local.php (I'm hoping this  
> will still work for setting defaults, although I'm using SQL for  
> preferences storage).
>
>
> 2. I think the section I need to amend is:
>
> // This array contains the list of flags created by the user through the
> // flags UI, and any modifications to the built-in system flags.
> $_prefs['msgflags'] = array(
>     // 'value' = serialize(array())
>     'value' => 'a:0:{}'
> );
>
>
> 3. To lock it I will modify it like so:
>
> // This array contains the list of flags created by the user through the
> // flags UI, and any modifications to the built-in system flags.
> $_prefs['msgflags'] = array(
>     locked => true,
>     // 'value' = serialize(array())
>     'value' => 'a:0:{}'
> );
>
>
> What I can't seem to figure out is the syntax to be used in the  
> 'value' field. I've googled, but so far I've drawn a blank in terms  
> of how to assign colours to the individual flags in this array.

'msgflags' contains IMP_Flag_Base objects, but ONLY if they differ  
from the base objects.

To store using the msgflags preference, you can do something like this  
(which needs to be run in the IMP environment):

$msgflags = array();
foreach ($GLOBALS['injector']->getInstance('IMP_Flags') as $val) {
     if (!($val instanceof IMP_Flag_Imap_Seen)) {
         $val->bgcolor = '#fff';
         $msgflags[] = $val;
     }
}
$pref_value = serialize($msgflags);

Take the string value of $pref_value and use this as the 'value' field  
of the locked 'msgflags' preference.

Optionally, you can just directly hack the Flag objects and replace  
the default bgcolor values with '#fff' instead.

michael

___________________________________
Michael Slusarz [slusarz at horde.org]



More information about the imp mailing list