[dev] Folder-based preferences for IMP

brook davis brook at linuxbox.com
Mon Aug 8 12:15:15 PDT 2005


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 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?

Any and all help is greatly appreciated.

Thanks,

Brook


More information about the dev mailing list