[imp] Cyrus Quota patch, take #3

Richard.Heggs at nottinghamcity.gov.uk Richard.Heggs at nottinghamcity.gov.uk
Mon Dec 29 04:18:40 PST 2003


Here we go again :)

On Fri Sep 26 12:36:16 PDT 2003, Etienne Goyer wrote:

  "3. Wrong assumption regarding mailbox name in imp/lib/Quota/cyrus.php.
  The code was assuming a standard namespace (user<sep><mailbox>) and
  break on Cyrus server that use altnamespace.  I tested my patch with
  both standard namespace and altnamespace, and it worked for me.
  However, since my system have the imap_get_quotaroot function available,
  I did no tried the alternate path of using the imap_get_quota function
  instead so I don't know how it react in this circumstance.  To be
  checked, I suppose."

I don't have imap_get_quotaroot(), which is why Etienne's patch didn't work
for me :)  What confused me is the phrase "standard namespace".  Someone
patiently explained to me that there are two distinct concepts in Cyrus:
namespace and hierarchy.  Namespace is concerned with how the mailbox and
folders are presented, and hierarchy relates (more or less) to how the
server stores them.

imap_get_quota() works with the hierarchy rather than the namespace, so
'user.' *must* be there, otherwise Cyrus sulks.

However, it is conceivable that someone may have a Cyrus configuration that
does not use the default 'user.' hierarchy for personal mailboxes.  Imp
should allow for this.  The attached patch adds an optional 'userhierarchy'
attribute that can be specified in the quota params.  This defaults to
'user.' if not specified.

Patch includes changes to lib/Quota/cyrus.php as above, and some
explanatory
comments in config/servers.php.dist.

Tested and works for me with Cyrus 2.1.15 (default namespace).  It should
work with altnamespace, too, because imap_get_quota() doesn't seem to care
about namespaces.

Richard


----------------------------------------------------------------
This message was sent using IMP, the Internet Messaging Program.

######################################################################
This e-mail (and any attachments) is confidential and may contain personal
views which are not the views of Nottingham City Council unless specifically
stated. If you have received it in error, please delete it from your system,
do not use, copy or disclose the information in any way nor act in reliance
on it and notify the sender immediately. Please note that Nottingham City
Council monitors e-mails sent or received. Further communication will
signify your consent to this.
######################################################################
-------------- next part --------------
--- servers.php.dist    3 Oct 2003 14:14:20 -0000       1.36
+++ servers.php.dist    29 Dec 2003 12:07:03 -0000
@@ -163,7 +163,11 @@
         'driver' => 'cyrus',
         'params' => array(
             'login' => 'admin',
-            'password' => 'admin_pass'
+            'password' => 'admin_pass',
+// The 'userhierarchy' parameter defaults to 'user.'
+// If you are using a nonstandard hierarchy for personal mailboxes,
+// you will need to set it here.
+//         'userhierarchy' => 'personal.'
         )
     ),
     'acl' => array(
--- cyrus.php   30 Sep 2003 18:33:34 -0000      1.17
+++ cyrus.php   29 Dec 2003 12:11:24 -0000
@@ -33,6 +33,9 @@
         if (!array_key_exists('password', $this->_params)) {
             $this->_params['password'] = '';
         }
+        if (!array_key_exists('userhierarchy', $this->_params)) {
+           $this->_params['userhierarchy'] = 'user.';
+       }

         /* Get the delimiter for the folder. */
         require_once IMP_BASE . '/lib/Folder.php';
@@ -59,7 +62,7 @@
         } else {
             $stream = @imap_open(IMP::serverString(), $this->_params['login'], $this->_params['password'], OP_HALFOPEN);
             if ($stream !== false) {
-                $quota = @imap_get_quota($stream, 'INBOX');
+                $quota = @imap_get_quota($stream, $this->_params['userhierarchy'].$_SESSION['imp']['user']);
                 @imap_close($stream);
             }
         }


More information about the imp mailing list