[imp] auto create folder

Laurent Foucher laurent.foucher at iut-tlse3.fr
Mon May 16 06:32:25 UTC 2011


Michael M Slusarz <slusarz at horde.org> a écrit :

> 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.
>
Thanks a lot for this hack. Tested and seems to work perfectly.

-- 
- Laurent Foucher
< I U T 'A'  Paul Sabatier >
laurent.foucher at iut-tlse3.fr
Enseignant/Chargé de mission Systèmes & Réseau

----------------------------------------------------------------
This message was sent using IMP, the Internet Messaging Program.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-keys
Size: 1703 bytes
Desc: Cl? publique PGP
URL: <http://lists.horde.org/archives/imp/attachments/20110516/0673d065/attachment.bin>


More information about the imp mailing list