[dev] Folder-based preferences for IMP
Jan Schneider
jan at horde.org
Wed Aug 10 03:34:23 PDT 2005
Zitat von brook davis <brook at linuxbox.com>:
> Hi all,
>
> I'm (still) trying to implement some more advanced folder maintenance
> tasks, on a per folder basis. I'm having problems with setting the
> necessary $_prefs, however. I'm basically doing the following in
> imp/config/prefs.php:
>
> if(isset($_SESSION['imp'])){
> require_once IMP_BASE . '/lib/Folder.php';
> require_once IMP_BASE . '/lib/IMAP.php';
> IMP::checkAuthentication(OP_HALFOPEN, true);
>
> $folders=imap_list($_SESSION['imp']['stream'],IMP::serverString(),"*");
>
> foreach($folders as $i => $folder){
> $f=explode("}",$folder);
> $f[1]=str_replace(".","-",$f[1]);
> $prefGroups['logintasks']['members'][] = 'f_maint_'.$f[1];
> $_prefs['f_maint_'.$f[1]] = array(
> 'value' => 30,
> 'locked' => false,
> 'shared' => false,
> 'type' => 'number',
> 'desc' => _("purge ".$f[1])." how often?");
> }
> }
This is far too much logic for a configuration file.
> This results in all of the fields getting spilled out on the preferences
> page, as I would expect. The problem I am running into, is that the
> values never get saved, due to the conditional enclosure, i am
> supposing. The first time this file is included, if I omit the
> conditional, i get an error regarding an undefined imp index in
> $_SESSION, which makes sense, as I haven't logged into IMP yet.
> However, this is problematic, as the prefs.php file does get loaded upon
> initial Horde login, which leaves me setting IMP preferences without
> having the imp variable to acquire my folder list with.
>
> Can anyone think of a workaround for this? I am sure there is a simple
> way to dynamically add preferences during the actual imp session, but i
> need a push in the right direction. Perhaps prefs.php is not the best
> place to do this? what is causing the variables not to get set, and
> furthermore, why are they being printed to screen, but not retaining the
> values on form submission?
You should create "special" and "implicit" preferences for the prefs
UI. See one of the folder preferences (Sent-mail/Draft/Trash) for
examples.
Jan.
--
Do you need professional PHP or Horde consulting?
http://horde.org/consulting/
More information about the dev
mailing list