[dev] [imp-patch] default mailbox for create folder

Francois Marier francois at nit.ca
Mon Aug 9 12:04:43 PDT 2004


On Fri, Aug 06, 2004 at 09:56:49PM -0400, Chuck Hagenbuch wrote:
> I'd rather solve the problem in another way - either by parsing
> NAMESPACE information, or by revising our 'folders' and 'namespace'
> configuration options to be clearer (and potentially adding more
> options if necessary) to allow the admin tell IMP where folders
> can/should be created.

I just noticed the 'namespace' server option in
imp/config/servers.php.  Instead of hardcoding the inbox name, I
changed my latest patch to use "$imp['namespace']".  Is that what you
meant by parsing the namespace info ?

Or maybe what's ugly about it is the fact that on an error, it tries
the create folder operation again but with a prefix ?  I guess a
better way to do this would be to parse the folder before trying it
and see if it starts with one of the top-level folders.  Is there a
way we can get a list of all top-level folders ?

Francois
-------------- next part --------------
diff -rpuN -X ../ignorelist ../build/imp/lib/Folder.php imp/lib/Folder.php
--- ../build/imp/lib/Folder.php	Sun Jun 13 22:55:04 2004
+++ imp/lib/Folder.php	Mon Aug  9 14:12:42 2004
@@ -425,9 +425,14 @@ class IMP_Folder {
 
         /* Attempt to create the mailbox */
         if (!imap_createmailbox($stream, IMP::serverString($folder))) {
-            $notification->push(sprintf(_("The folder \"%s\" was not created. This is what the server said"), IMP::displayFolder($folder)) .
-                            ': ' . imap_last_error(), 'horde.error');
-            return false;
+            $oldfolder = $folder;
+            $folder = $imp['namespace'] . $folder;
+            if (!imap_createmailbox($stream, IMP::serverString($folder))) {
+                $folder = $oldfolder;
+                $notification->push(sprintf(_("The folder \"%s\" was not created. This is what the server said"), IMP::displayFolder($folder)) .
+                                    ': ' . imap_last_error(), 'horde.error');
+                return false;
+            }
         }
 
         /* Reset the folder cache. */


More information about the dev mailing list