From: Michael M Slusarz Date: Wed, 1 Sep 2010 08:31:52 +0000 (-0600) Subject: Add option to use message count limit for maildir quota X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=f7a841309b4256444d8bb07d9ef64ac15215d712;p=horde.git Add option to use message count limit for maildir quota --- diff --git a/imp/config/servers.php.dist b/imp/config/servers.php.dist index a69e58540..dcd01ea49 100644 --- a/imp/config/servers.php.dist +++ b/imp/config/servers.php.dist @@ -181,7 +181,11 @@ * * DRIVER: 'maildir' * Use Maildir++ quota files to handle quotas. - * PARAMS: 'path' - [string] The path to the user's Maildir + * PARAMS: 'msg_count' - [boolean] Display information on the + * message limit rather than the storage + * limit? The storage limit information is + * displayed by default. + * 'path' - [string] The path to the user's Maildir * directory. You may use the two-character * sequence "~U" to represent the user's account * name, and the actual username will be diff --git a/imp/lib/Quota/Maildir.php b/imp/lib/Quota/Maildir.php index 885e59972..ed6e2bbde 100644 --- a/imp/lib/Quota/Maildir.php +++ b/imp/lib/Quota/Maildir.php @@ -1,9 +1,7 @@ + * 'msg_count' - (boolean) Display information on the message limit rather + * than the storage limit? + * DEFAULT: false * 'path' - (string) The path to the user's Maildir directory. You may use * the two-character sequence "~U" to represent the user's * account name, and the actual username will be substituted in @@ -36,6 +36,7 @@ class IMP_Quota_Maildir extends IMP_Quota_Base public function __construct($params = array()) { parent::__construct(array_merge(array( + 'msg_count' => false, 'path' => '', 'username' => '' ), $params)); @@ -45,13 +46,15 @@ class IMP_Quota_Maildir extends IMP_Quota_Base * Returns quota information (used/allocated), in bytes. * * @return array An array with the following keys: - * 'limit' = Maximum quota allowed - * 'usage' = Currently used portion of quota (in bytes) + *
+     * 'limit' = Maximum quota allowed.
+     * 'usage' = Currently used portion of quota (in bytes).
+     * 
* @throws IMP_Exception */ public function getQuota() { - $storage_limit = $message_limit = $storage_used = $message_used = 0; + $limit = $used = 0; // Get the full path to the quota file. $full = $this->_params['path'] . '/maildirsize'; @@ -80,34 +83,36 @@ class IMP_Quota_Maildir extends IMP_Quota_Base $v2 = 0; } - if ($t1 == 'S') { - $storage_limit = $v1; - } - if ($t1 == 'C') { - $message_limit = $v1; - } - if ($t2 == 'S') { - $storage_limit = $v2; - } - if ($t2 == 'C') { - $message_limit = $v2; + if ($this->_params['msg_count']) { + if ($t1 == 'C') { + $limit = $v1; + } + if ($t2 == 'C') { + $limit = $v2; + } + } else { + if ($t1 == 'S') { + $limit = $v1; + } + if ($t2 == 'S') { + $limit = $v2; + } } } else { // Any line other than the first line. // The quota used is the sum of all lines found. list($storage, $message) = sscanf(trim($line), '%ld %d'); - if (!is_null($storage)) { - $storage_used += $storage; - } - if (!is_null($message)) { - $message_used += $message; + if ($this->_params['msg_count'] && !is_null($message)) { + $used += $message; + } elseif (!$this->_params['msg_count'] && !is_null($storage)) { + $used += $storage; } } } return array( - 'limit' => $storage_limit, - 'usage' => $storage_used + 'limit' => $limit, + 'usage' => $used ); }