|
|
@@ -97,12 +97,12 @@ function zimbraSingle_TestConnection($params)
|
|
|
'zimbrasingle',
|
|
|
__FUNCTION__,
|
|
|
$params,
|
|
|
- "Connection test to " . $params['serverip'] . " failed: Cannot login",
|
|
|
+ "Connection failed, cannot login to " . $params['serverip'],
|
|
|
$login->getMessage()
|
|
|
);
|
|
|
return array(
|
|
|
'success' => false,
|
|
|
- 'error' => "Connection test to " . $params['serverip'] . " failed, the error was: " . $login->getMessage(),
|
|
|
+ 'error' => "Connection failed, cannot login to " . $params['serverip'],
|
|
|
);
|
|
|
}
|
|
|
return array(
|
|
|
@@ -152,23 +152,23 @@ function zimbraSingle_ClientArea($params)
|
|
|
__FUNCTION__,
|
|
|
$params,
|
|
|
"Error: cannot login to " . $accessData['zimbraServer'],
|
|
|
- $login
|
|
|
+ $login->getMessage()
|
|
|
);
|
|
|
return false;
|
|
|
}
|
|
|
$apiAccountManager = new Zm_Account($api);
|
|
|
- $response = $apiAccountManager->getAccountInfo($params['username']);
|
|
|
- if(is_a($response, "Exception")) {
|
|
|
+ $accountInfo = $apiAccountManager->getAccountInfo($params['username']);
|
|
|
+ if(is_a($accountInfo, "Exception")) {
|
|
|
logModuleCall(
|
|
|
'zimbrasingle',
|
|
|
__FUNCTION__,
|
|
|
$params,
|
|
|
"Error: could not gather informations for " . $params['username'],
|
|
|
- $response
|
|
|
+ $accountInfo->getMessage()
|
|
|
);
|
|
|
return false;
|
|
|
}
|
|
|
- $webmailUrl = recursiveFindAll( $response, 'PUBLICMAILURL');
|
|
|
+ $webmailUrl = recursiveFindAll($accountInfo, 'PUBLICMAILURL');
|
|
|
$clientInfo['webmailurl'] = $webmailUrl[0]['DATA'];
|
|
|
return array(
|
|
|
'templatefile' => 'clientarea',
|
|
|
@@ -206,34 +206,34 @@ function zimbraSingle_UsageUpdate($params) {
|
|
|
->get();
|
|
|
foreach((array)$productsObj as $productObj) {
|
|
|
$product = get_object_vars($productObj[0]);
|
|
|
- $quota = $apiAccountManager->getQuota($product['username']);
|
|
|
- if(is_a($quota, "Exception")) {
|
|
|
+ $accountQuota = $apiAccountManager->getQuota($product['username']);
|
|
|
+ if(is_a($accountQuota, "Exception")) {
|
|
|
logModuleCall(
|
|
|
'zimbrasingle',
|
|
|
__FUNCTION__,
|
|
|
- $product,
|
|
|
- "Error : could not find " . $product['username'],
|
|
|
- $quota->getMessage()
|
|
|
+ $params,
|
|
|
+ "Error : could not find quota for " . $product['username'],
|
|
|
+ $accountQuota->getMessage()
|
|
|
);
|
|
|
}
|
|
|
- $response = $apiAccountManager->getMailbox($product['username']);
|
|
|
- if(is_a($response, "Exception")) {
|
|
|
+ $mboxObj = $apiAccountManager->getMailbox($product['username']);
|
|
|
+ if(is_a($mboxObj, "Exception")) {
|
|
|
logModuleCall(
|
|
|
'zimbrasingle',
|
|
|
__FUNCTION__,
|
|
|
$params,
|
|
|
"Error: could not fetch mailbox info for " . $product['username'],
|
|
|
- $response->getMessage()
|
|
|
+ $mboxObj->getMessage()
|
|
|
);
|
|
|
}
|
|
|
- $mbox = get_object_vars($response);
|
|
|
- $mboxSize = $mbox['S'];
|
|
|
+ $mboxVars = get_object_vars($mboxObj);
|
|
|
+ $mboxSize = $mboxVars['S'];
|
|
|
Capsule::table('tblhosting')
|
|
|
->where('id', '=', $product['id'])
|
|
|
->update(
|
|
|
array(
|
|
|
'diskusage' => round($mboxSize / 1048576,2),
|
|
|
- 'disklimit' => round($quota / 1048576,2),
|
|
|
+ 'disklimit' => round($accountQuota / 1048576,2),
|
|
|
'lastupdate' => Capsule::raw('now()')
|
|
|
)
|
|
|
);
|
|
|
@@ -266,7 +266,7 @@ function zimbraSingle_ChangePassword($params)
|
|
|
__FUNCTION__,
|
|
|
$params,
|
|
|
"Error: cannot login to " . $params['serverip'],
|
|
|
- $login
|
|
|
+ $login->getMessage()
|
|
|
);
|
|
|
return false;
|
|
|
}
|
|
|
@@ -277,8 +277,8 @@ function zimbraSingle_ChangePassword($params)
|
|
|
'zimbrasingle',
|
|
|
__FUNCTION__,
|
|
|
$params,
|
|
|
- "Error: password for " . $params['username'] . " could not be set",
|
|
|
- $response
|
|
|
+ "Error: password could not be set for " . $params['username'],
|
|
|
+ $response->getMessage()
|
|
|
);
|
|
|
return false;
|
|
|
}
|
|
|
@@ -311,25 +311,25 @@ function zimbraSingle_CreateAccount($params)
|
|
|
__FUNCTION__,
|
|
|
$params,
|
|
|
"Error: cannot login to " . $params['serverip'],
|
|
|
- $login
|
|
|
+ $login->getMessage()
|
|
|
);
|
|
|
return $login->getMessage();
|
|
|
}
|
|
|
- $accountName = $params['customfields']['username'] . '@' . $params['customfields']['maildomain'];
|
|
|
+ $params['username'] = $params['customfields']['username'] . '@' . $params['customfields']['maildomain'];
|
|
|
$apiAccountManager = new Zm_Account($api);
|
|
|
- $accountExists = $apiAccountManager->accountExists($accountName);
|
|
|
+ $accountExists = $apiAccountManager->accountExists($params['username']);
|
|
|
if(is_a($accountExists, "Exception")) {
|
|
|
logModuleCall(
|
|
|
'zimbrasingle',
|
|
|
__FUNCTION__,
|
|
|
- $accessData,
|
|
|
- "Error: could not verify $accountName",
|
|
|
- $accountExists
|
|
|
+ $params,
|
|
|
+ "Error: could not verify " . $params['username'],
|
|
|
+ $accountExists->getMessage()
|
|
|
);
|
|
|
- return "Error: could not verify $accountName";
|
|
|
+ return "Error: could not verify ". $params['username'];
|
|
|
}
|
|
|
if($accountExists === true) {
|
|
|
- return "Error: account $accountName already exists";
|
|
|
+ return "Error: account already exists " . $params['username'];
|
|
|
}
|
|
|
$attrs = array();
|
|
|
$attrs["gn"] = $params['customfields']["givenname"];
|
|
|
@@ -337,14 +337,14 @@ function zimbraSingle_CreateAccount($params)
|
|
|
$attrs["displayName"] = $attrs["gn"] . " " . $attrs["sn"];
|
|
|
$passDecrypt = localAPI('DecryptPassword', array('password2' => $params['customfields']['password']));
|
|
|
if ($passDecrypt['result'] == 'success') {
|
|
|
- $password = $passDecrypt['password'];
|
|
|
+ $params['password'] = $passDecrypt['password'];
|
|
|
} else {
|
|
|
logModuleCall(
|
|
|
'zimbrasingle',
|
|
|
__FUNCTION__,
|
|
|
- $params['customfields']['password'],
|
|
|
+ $params,
|
|
|
"Error: could not decrypt password",
|
|
|
- $passDecrypt
|
|
|
+ $passDecrypt['message']
|
|
|
);
|
|
|
return "Error: could not decrypt password";
|
|
|
}
|
|
|
@@ -353,30 +353,30 @@ function zimbraSingle_CreateAccount($params)
|
|
|
logModuleCall(
|
|
|
'zimbrasingle',
|
|
|
__FUNCTION__,
|
|
|
- $params['configoption1'],
|
|
|
- "Error: serviceclass not available",
|
|
|
- $cosID
|
|
|
+ $params,
|
|
|
+ "Error: could not find serviceclass " . $params['configoption1'],
|
|
|
+ $cosID->getMessage()
|
|
|
);
|
|
|
- return "Error: serviceclass not available";
|
|
|
+ return "Error: could not find serviceclass " . $params['configoption1'];
|
|
|
}
|
|
|
$attrs['zimbraCOSId'] = $cosID;
|
|
|
- $id = $apiAccountManager->createAccount($accountName, $password, $attrs);
|
|
|
- if(is_a($id, "Exception")) {
|
|
|
+ $zimbraID = $apiAccountManager->createAccount($params['username'], $params['password'], $attrs);
|
|
|
+ if(is_a($zimbraID, "Exception")) {
|
|
|
logModuleCall(
|
|
|
'zimbrasingle',
|
|
|
__FUNCTION__,
|
|
|
$params,
|
|
|
- "Error: account $accountName not created",
|
|
|
- $id
|
|
|
+ "Error: could not create account " . $params['username'],
|
|
|
+ $zimbraID->getMessage()
|
|
|
);
|
|
|
- return "Error: account $accountName not created";
|
|
|
+ return "Error: could not create account " . $params['username'];
|
|
|
}
|
|
|
Capsule::table('tblhosting')
|
|
|
->where('id', '=', $params['serviceid'])
|
|
|
->update(
|
|
|
array(
|
|
|
- 'username' => $accountName,
|
|
|
- 'password' => $params['customfields']['password'],
|
|
|
+ 'username' => $params['username'],
|
|
|
+ 'password' => $params['password'],
|
|
|
)
|
|
|
);
|
|
|
return 'success';
|
|
|
@@ -405,7 +405,7 @@ function zimbraSingle_SuspendAccount($params)
|
|
|
__FUNCTION__,
|
|
|
$params,
|
|
|
"Error: cannot login to " . $params['serverip'],
|
|
|
- $login
|
|
|
+ $login->getMessage()
|
|
|
);
|
|
|
return $login->getMessage();
|
|
|
}
|
|
|
@@ -416,8 +416,8 @@ function zimbraSingle_SuspendAccount($params)
|
|
|
'zimbrasingle',
|
|
|
__FUNCTION__,
|
|
|
$params,
|
|
|
- "Error: account " . $params['username'] . " could not locked",
|
|
|
- $response
|
|
|
+ "Error: could not lock account " . $params['username'],
|
|
|
+ $response->getMessage()
|
|
|
);
|
|
|
return false;
|
|
|
}
|
|
|
@@ -447,7 +447,7 @@ function zimbraSingle_UnsuspendAccount($params)
|
|
|
__FUNCTION__,
|
|
|
$params,
|
|
|
"Error: cannot login to " . $params['serverip'],
|
|
|
- $login
|
|
|
+ $login->getMessage()
|
|
|
);
|
|
|
return $login->getMessage();
|
|
|
}
|
|
|
@@ -458,10 +458,10 @@ function zimbraSingle_UnsuspendAccount($params)
|
|
|
'zimbrasingle',
|
|
|
__FUNCTION__,
|
|
|
$params,
|
|
|
- "Error: account " . $params['username'] . " could not unlocked",
|
|
|
- $response
|
|
|
+ "Error: could not unlock account " . $params['username'],
|
|
|
+ $response->getMessage()
|
|
|
);
|
|
|
- return "Error: account " . $params['username'] . " could not unlocked";
|
|
|
+ return "Error: could not unlock account " . $params['username'];
|
|
|
}
|
|
|
return 'success';
|
|
|
}
|
|
|
@@ -488,24 +488,24 @@ function zimbraSingle_TerminateAccount($params)
|
|
|
__FUNCTION__,
|
|
|
$params,
|
|
|
"Error: cannot login to " . $params['serverip'],
|
|
|
- $login
|
|
|
+ $login->getMessage()
|
|
|
);
|
|
|
return $login->getMessage();
|
|
|
}
|
|
|
$apiAccountManager = new Zm_Account($api);
|
|
|
- $response = $apiAccountManager->getAccountStatus($params['username']);
|
|
|
- if(is_a($response, "Exception")) {
|
|
|
+ $accountStatus = $apiAccountManager->getAccountStatus($params['username']);
|
|
|
+ if(is_a($accountStatus, "Exception")) {
|
|
|
logModuleCall(
|
|
|
'zimbrasingle',
|
|
|
__FUNCTION__,
|
|
|
$params,
|
|
|
- "Error: account ". $params['username'] . " could not verified",
|
|
|
- $response
|
|
|
+ "Error: could not verify account ". $params['username'],
|
|
|
+ $accountStatus->getMessage()
|
|
|
);
|
|
|
return "Error : account " . $params['username'] . " Name could not verified";
|
|
|
}
|
|
|
- if ($response != 'locked') {
|
|
|
- return "Account ". $params['username'] . " active, suspend account first!";
|
|
|
+ if ($accountStatus != 'locked') {
|
|
|
+ return "Account ". $params['username'] . " is active, suspend account first!";
|
|
|
}
|
|
|
$response = $apiAccountManager->deleteAccount($params['username']);
|
|
|
if(is_a($response, "Exception")) {
|
|
|
@@ -513,10 +513,10 @@ function zimbraSingle_TerminateAccount($params)
|
|
|
'zimbrasingle',
|
|
|
__FUNCTION__,
|
|
|
$params,
|
|
|
- "Error: account ". $params['username'] . " could not removed",
|
|
|
- $response
|
|
|
+ "Error: could not remove account ". $params['username'],
|
|
|
+ $response->getMessage()
|
|
|
);
|
|
|
- return "Error: account ". $params['username'] . " could not removed";
|
|
|
+ return "Error: could not remove account ". $params['username'];
|
|
|
}
|
|
|
return 'success';
|
|
|
}
|
|
|
@@ -539,16 +539,6 @@ function zimbraSingle_TerminateAccount($params)
|
|
|
*/
|
|
|
function zimbraSingle_ChangePackage($params)
|
|
|
{
|
|
|
-// Debug
|
|
|
-logModuleCall(
|
|
|
- 'zimbrasingle',
|
|
|
- __FUNCTION__,
|
|
|
- $whmcs,
|
|
|
- "Debug",
|
|
|
- $params
|
|
|
-);
|
|
|
-//
|
|
|
- $accountName = $params['customfields']['username'] . '@' . $params['customfields']['maildomain'];
|
|
|
$api = new Zm_Auth($params['serverip'], $params['serverusername'], $params['serverpassword'], "admin");
|
|
|
$login = $api->login();
|
|
|
if(is_a($login, "Exception")) {
|
|
|
@@ -557,21 +547,21 @@ logModuleCall(
|
|
|
__FUNCTION__,
|
|
|
$params,
|
|
|
"Error: cannot login to " . $params['serverip'],
|
|
|
- $login
|
|
|
+ $login->getMessage()
|
|
|
);
|
|
|
return $login->getMessage();
|
|
|
}
|
|
|
$apiAccountManager = new Zm_Account($api);
|
|
|
- $response = $apiAccountManager->setAccountCos($accountName, $params['configoption1']);
|
|
|
+ $response = $apiAccountManager->setAccountCos($params['username'], $params['configoption1']);
|
|
|
if(is_a($response, "Exception")) {
|
|
|
logModuleCall(
|
|
|
'zimbrasingle',
|
|
|
__FUNCTION__,
|
|
|
$params,
|
|
|
- "Error: class of service for $accountName could not be set",
|
|
|
- $response
|
|
|
+ "Error: could not set class of service for ". $params['username'],
|
|
|
+ $response->getMessage()
|
|
|
);
|
|
|
- return "Error: class of service for $accountName could not be set";
|
|
|
+ return "Error: could not set class of service for ". $params['username'];
|
|
|
}
|
|
|
return 'success';
|
|
|
}
|
|
|
@@ -612,7 +602,7 @@ function zimbraSingle_ConfigOptions($params)
|
|
|
__FUNCTION__,
|
|
|
$adminPassCrypt,
|
|
|
"Error: cloud not decrypt admin password" ,
|
|
|
- $adminPassDecrypt
|
|
|
+ $adminPassDecrypt['message']
|
|
|
);
|
|
|
return false;
|
|
|
}
|
|
|
@@ -624,23 +614,23 @@ function zimbraSingle_ConfigOptions($params)
|
|
|
__FUNCTION__,
|
|
|
$params,
|
|
|
"Error: cannot login to " . $accessData['zimbraServer'],
|
|
|
- $login
|
|
|
+ $login->getMessage()
|
|
|
);
|
|
|
return false;
|
|
|
}
|
|
|
$apiAccountManager = new Zm_Account($api);
|
|
|
- $response = $apiAccountManager->getAllCos();
|
|
|
- if(is_a($response, "Exception")) {
|
|
|
+ $cosIDs = $apiAccountManager->getAllCos();
|
|
|
+ if(is_a($cosIDs, "Exception")) {
|
|
|
logModuleCall(
|
|
|
'zimbrasingle',
|
|
|
__FUNCTION__,
|
|
|
$params,
|
|
|
"Error: could not fetch classes of service",
|
|
|
- $response
|
|
|
+ $cosIDs->getMessage()
|
|
|
);
|
|
|
return false;
|
|
|
}
|
|
|
- $cosNames = recursiveFindAll($response, 'NAME');
|
|
|
+ $cosNames = recursiveFindAll($cosIDs, 'NAME');
|
|
|
$configOptions = array();
|
|
|
$configOptions['cos'] = array(
|
|
|
"FriendlyName" => "Class of Service",
|