[imp] Patch: IMP CVS-HEAD quota reporting

Leena Heino Leena.Heino@uta.fi
Tue, 23 Jul 2002 17:11:21 +0300 (EEST)


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)