Code

Display quota image
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Wed, 10 Dec 2008 13:13:34 +0000 (13:13 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Wed, 10 Dec 2008 13:13:34 +0000 (13:13 +0000)
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@13243 594d385d-05f5-0310-b6e9-bd551577e9d8

gosa-plugins/mail/admin/groups/mail/class_groupMail.inc
gosa-plugins/mail/personal/mail/class_mail-methods.inc
gosa-plugins/mail/personal/mail/class_mailAccount.inc

index 695bae8d87942257a9f214e17055df6dcc4e97b6..b4c01024dba3cb84de6b35744fd218f7cafa7b70 100644 (file)
@@ -11,7 +11,6 @@ class mailgroup extends plugin
   var $gosaMailForwardingAddress  = array();  // Forwarding also empty
   var $gosaMailServer             = "";       // Selected mailserver 
   var $gosaMailQuota              = "";       // Defined Quota 
-  var $quotaUsage                 = 0;        // Currently used quota
   var $gosaVacationMessage        = "";       // Vocation message 
   var $gosaSpamSortLevel          = "";     
   var $gosaSpamMailbox            = "";
@@ -20,6 +19,8 @@ class mailgroup extends plugin
   var $gosaMailMaxSize            = "";       // 
   var $FolderType                 = array("CAT" => '', "SUB_CAT" => '');
 
+  var $quotaUsage                 = -1;        // -1 Means undefined
+
   /* Internal */
   var $AclTypes                   = array();
   var $members                    = array();  // Group members
@@ -100,6 +101,7 @@ class mailgroup extends plugin
 
         /* Read quota */
         $this->gosaMailQuota = $this->mailMethod->getQuota($this->gosaMailQuota);
+        $this->quotaUsage = $this->mailMethod->getQuotaUsage($this->quotaUsage);
         if($this->mailMethod->is_error()){
           msg_dialog::display(_("Mail error"), sprintf(_("Cannot read quota settings: %s"),
                 $this->mailMethod->get_error()), ERROR_DIALOG);
@@ -408,11 +410,9 @@ class mailgroup extends plugin
     $smarty->assign("AclTypes" ,    $this->AclTypes);
   
     $smarty->assign("quotaEnabled", $this->mailMethod->quotaEnabled());
-    $smarty->assign("gosaMailQuota",$this->gosaMailQuota);
-    if($this->mailMethod->is_connected()){ 
-      $smarty->assign("quotaUsage", $this->mailMethod->getQuotaUsage());
-    }else{
-      $smarty->assign("quotaUsage", _("Unknown")); 
+    if($this->mailMethod->quotaEnabled()){
+      $smarty->assign("gosaMailQuota",$this->gosaMailQuota);
+      $smarty->assign("quotaUsage",   mailMethod::quota_to_image($this->quotaUsage,$this->gosaMailQuota)); 
     }
 
     $smarty->assign("MailDomains", $this->mailDomainParts);
index 9f1cbf7cf12d2a47bd010130011d4f0f3b6c6433..d2d76936dd510e98f98424b5f01747d2ff18d77a 100644 (file)
@@ -725,6 +725,17 @@ class mailMethod{
     return("");
   }
 
+
+  static function quota_to_image($use,$quota)
+  {
+    if($use == -1 ){ 
+      return(_("Unknown"));
+    }elseif($quota == 0){
+      return(progressbar(100,100,15,true));
+    }else{
+      return(progressbar(round(($use * 100)/ $quota),100,15,true));
+    }
+  }
 }
 
 
index d346f242aa82923661de7e7e04f65501cc461e34..295ab5747b801bd6eb374b0fabd985551664e8f1 100644 (file)
@@ -68,6 +68,8 @@ class mailAccount extends plugin
   var $gosaSpamMailbox                    = "";
 
   /* The methods defaults */
+  var $quotaUsage     = -1; // Means unknown
+
   var $mailMethod      = NULL;
   var $MailDomain      = "";
   var $sieveManagementUsed = FALSE;
@@ -140,6 +142,7 @@ class mailAccount extends plugin
 
         /* Read quota */
         $this->gosaMailQuota = $this->mailMethod->getQuota($this->gosaMailQuota);
+        $this->quotaUsage    = $this->mailMethod->getQuotaUsage($this->quotaUsage);
         if($this->mailMethod->is_error()){
           msg_dialog::display(_("Mail error"), sprintf(_("Cannot read quota settings: %s"), 
                 $this->mailMethod->get_error()), ERROR_DIALOG);
@@ -392,12 +395,10 @@ class mailAccount extends plugin
       $smarty->assign($attr,$this->$attr);
     }
     $smarty->assign("quotaEnabled", $this->mailMethod->quotaEnabled());
-    if($this->mailMethod->is_connected()){
-      $smarty->assign("quotaUsage",   $this->mailMethod->getQuotaUsage());
-    }else{
-      $smarty->assign("quotaUsage",   _("Unknown"));
+    if($this->mailMethod->quotaEnabled()){
+      $smarty->assign("quotaUsage",   mailMethod::quota_to_image($this->quotaUsage,$this->gosaMailQuota));
+      $smarty->assign("gosaMailQuota",$this->gosaMailQuota);
     }
-    $smarty->assign("gosaMailQuota",$this->gosaMailQuota);
     $smarty->assign("domainSelectionEnabled", $this->mailMethod->domainSelectionEnabled());
     $smarty->assign("MailDomains", $this->mailDomainParts);
     $smarty->assign("MailDomain" , $this->mailDomainPart);