[imp] Patch: IMP CVS-HEAD quota reporting

Michael Cochrane mike@graftonhall.co.nz
Tue, 23 Jul 2002 15:22:47 +0100


I have a different patch that covers some of the same issues with the units in a
slightly nicer way....  this will probably get wrapped weird but it multiplies
all the values in courier.php and cyrus.php byt 1024 to get them to bytes... 

as other qouta driver (like the 'awk' method and my mdaemon one) will be able to
calculate quotas in bytes so why loose precision earlier than need be... 

- Mike :-)

Index: imp/lib/Quota/courier.php
===================================================================
RCS file: /repository/imp/lib/Quota/courier.php,v
retrieving revision 1.1
diff -I$Horde -I$Revision -I$Date -r1.1 courier.php
50c50
<                 return $this->_quotaHTML($quota['usage'], $quota['limit']);
---
>                 return $this->_quotaHTML($quota['usage'] * 1024,
$quota['limit'] * 1024);
Index: imp/lib/Quota/cyrus.php
===================================================================
RCS file: /repository/imp/lib/Quota/cyrus.php,v
retrieving revision 1.1
diff -I$Horde -I$Revision -I$Date -r1.1 cyrus.php
56c56
<                 return $this->_quotaHTML($quota['usage'], $quota['limit']);
---
>                 return $this->_quotaHTML($quota['usage'] * 1024,
$quota['limit'] * 1024);



Quoting Leena Heino <Leena.Heino@uta.fi>:

> This patch fixes:
> - In Cyrus IMAP if user has unlimited mailquota then getquota returns
> empty values.
> - Quota values should be calculated to MB not GB
> - Adds text "Quota status:" before quota usage values.
> 
> --- imp/lib/Quota.php.orig	Mon Jul 22 20:03:07 2002
> +++ imp/lib/Quota.php	Tue Jul 23 16:53:28 2002
> @@ -102,10 +102,14 @@
>       */
>      function _quotaHtml($used, $total)
>      {
> -        $used = $used / (1024 * 1024.0);
> -        $total = $total / (1024 * 1024.0);
> +	if ($used != "" && total != "") {
> +            $used = $used / 1024.0;
> +            $total = $total / 1024.0;
> +            $percent = ($used * 100) / $total;
> +	} else {
> +            $percent = 0;
> +        }
> 
> -        $percent = ($used * 100) / $total;
>          if ($percent >= 90) {
>              $class = 'quotaalert';
>          } elseif ($percent >= 75) {
> @@ -114,7 +118,11 @@
>              $class = 'control';
>          }
> 
> -        $message = sprintf("%.2fMB / %.2fMB  (%.2f%%)", $used, $total,
> $percent);
> +	if ($used != "" && total != "") {
> +            $message = sprintf(_("Quota status:")) . sprintf(" %.2fMB /
> %.2fMB  (%.2f%%)", $used, $total, $percent);
> +	} else {
> +            $message = sprintf(_("Quota status: NO LIMIT"));
> +        }
> 
>          include IMP_TEMPLATES . '/quota/quota.inc';
>      }
> 
> -- 
>   -- Leena Heino (liinu at uta.fi)
> 
> 
> -- 
> IMP mailing list
> Frequently Asked Questions: http://horde.org/faq/
> To unsubscribe, mail: imp-unsubscribe@lists.horde.org


-- 

Everybody is somebody else's weirdo.
signature from Siglets.com

-------------------------------------------------------------------------
This mail sent from Mike's CVS HEAD install of IMP: http://horde.org/imp/