Kaynağa Gözat

debug accountInfo

andre 5 yıl önce
ebeveyn
işleme
d86b63dfd7
2 değiştirilmiş dosya ile 40 ekleme ve 1 silme
  1. 30 0
      api/Zm/Account.php
  2. 10 1
      zimbraSingle.inc

+ 30 - 0
api/Zm/Account.php

@@ -164,6 +164,36 @@ class Zm_Account
 		return $result;
 	}
 
+	/**
+	 * getQuota
+	 * @param string $name account name
+	 * @return string account informations
+	 */
+	function getQuota($name)
+	{
+		$result = null;
+
+		$params = array(
+			new SoapVar('<ns1:account by="name">' . $name . '</ns1:account>', XSD_ANYXML),
+		);
+
+		try
+		{
+			$result = $this->auth->execSoapCall(
+				"GetAccountRequest",
+				$params
+			);
+
+			$result = getSoapAttribute($result['SOAP:ENVELOPE']['SOAP:BODY']['GETACCOUNTRESPONSE']['ACCOUNT']['A'], "zimbraMailQuota");
+		}
+		catch (SoapFault $exception)
+		{
+			$result = $exception;
+		}
+
+		return $result;
+	}
+
 	/**
 	 * getAccountId
 	 * @param string $name account name

+ 10 - 1
zimbraSingle.inc

@@ -338,6 +338,7 @@ function zimbraSingleChangePackage($userData) {
 function zimbraSingleClientArea($userData)
 {
     $accessData = zimbraSingleGetAccess();
+    $clientInfo = array();
     $account_name = $userData['username'] . '@' . $userData['maildomain'];
     $api = new Zm_Auth($accessData['zimbraServer'], $accessData['adminUser'], $accessData['adminPass'], "admin");
     $login = $api->login();
@@ -364,11 +365,12 @@ function zimbraSingleClientArea($userData)
         return false;
     }
 
+//    $clientInfo['quota'] = bytesToHuman($bytes);
     logModuleCall(
         'zimbrasingle',
         __FUNCTION__,
         $params,
-        "debug: getAccount",
+        "debug: getQuota",
         $response
     );
     
@@ -563,3 +565,10 @@ function zimbraSingleCheckPassword($pwd)
     }
     return $message;
 }
+
+function bytesToHuman($bytes)
+{
+    $units = ['B', 'KB', 'MB', 'GB', 'TB', 'PB'];
+    for ($i = 0; $bytes > 1024; $i++) $bytes /= 1024;
+    return round($bytes, 2) . ' ' . $units[$i];
+}