andre пре 5 година
родитељ
комит
95211a984d
1 измењених фајлова са 9 додато и 6 уклоњено
  1. 9 6
      zimbraSingle.inc

+ 9 - 6
zimbraSingle.inc

@@ -353,8 +353,8 @@ function zimbraSingleClientArea($userData)
         return false;
     }
     $apiAccountManager = new Zm_Account($api);
-    $response = $apiAccountManager->getQuota($account_name);
-    if(is_a($response, "Exception")) {
+    $quota = $apiAccountManager->getQuota($account_name);
+    if(is_a($quota, "Exception")) {
         logModuleCall(
             'zimbrasingle',
             __FUNCTION__,
@@ -364,7 +364,6 @@ function zimbraSingleClientArea($userData)
         );
         return false;
     }
-
     $response = $apiAccountManager->getMailbox($account_name);
     if(is_a($response, "Exception")) {
         logModuleCall(
@@ -372,18 +371,22 @@ function zimbraSingleClientArea($userData)
             __FUNCTION__,
             $params,
             "Error : could not fetch mailbox info for $account_name",
-            $response
+            ""
         );
         return false;
     }
+    $mboxSize = $response['S'];
+    $usagePercent = $mboxSize * 100 / $quota;
+    $clientInfo['quota'] = bytesToHuman($quota);
+    $clientInfo['size'] = bytesToHuman($mboxSize);
+    $clientInfo['usage'] = round($usagePercent, 2);
 
-//    $clientInfo['quota'] = bytesToHuman($bytes);
     logModuleCall(
         'zimbrasingle',
         __FUNCTION__,
         $params,
         "debug: getQuota",
-        $response
+        $clientInfo
     );
     
     $response = $apiAccountManager->getAccountInfo($account_name);