[imp] auto create folder
Michael M Slusarz
slusarz at horde.org
Fri May 13 18:49:10 UTC 2011
Quoting Laurent Foucher <laurent.foucher at iut-tlse3.fr>:
> I would like auto-create on the first login. To do that, with your
> advice, i have just write the following script
> in imp/config/hooks.php :
>
> public function appinitialized()
> {
> $vars = Horde_Variables::getDefaultVariables();
> $imp_folder = $GLOBALS['injector']->getInstance('IMP_Folder');
> $imaptree = $GLOBALS['injector']->getInstance('IMP_Imap_Tree');
> $folder_list = isset($vars->folder_list)
> ? array_map(array('IMP_Mailbox', 'formFrom'), $vars->folder_list)
> : array();
> //
> $folder_options = array(
> 'sent_mail_folder', 'drafts_folder', 'trash_folder',
> 'spam_folder'
> );
> //
> foreach ($folder_options as $this_folder) {
> $folder_to_create = Horde_Api::getPreference('imp',$this_folder);
> Horde::logMessage(sprintf('FOLDER : %s', $folder_to_create),
> 'NOTICE');
> try {
> $imaptree->createMailboxName(
> $folder_list[0],
>
> Horde_String::convertCharset($folder_to_create, 'UTF-8', 'UTF7-IMAP')
> )->create();
> } catch (Horde_Exception $e) {
> $notification->push($e);
> }
> }
> }
Since this is an issue that comes up a bit, I've gone ahead and made
an autocreate login task in imp which will appear in v 5.0.4. It will
need to be activated in IMP's configuration file - it is disabled by
default.
michael
___________________________________
Michael Slusarz [slusarz at horde.org]
More information about the imp
mailing list