|
|
@@ -194,7 +194,7 @@ function zimbraSingle_ClientArea($params) {
|
|
|
__FUNCTION__,
|
|
|
$params,
|
|
|
'Error: could not gather informations for ' . $params['username'],
|
|
|
- $accountInfo->getMessage()
|
|
|
+ $accountInfo
|
|
|
);
|
|
|
return false;
|
|
|
}
|
|
|
@@ -243,9 +243,9 @@ function zimbraSingle_UsageUpdate($params) {
|
|
|
__FUNCTION__,
|
|
|
$params,
|
|
|
'Error : could not find quota for ' . $product['username'],
|
|
|
- $accountQuota->getMessage()
|
|
|
+ $accountQuota
|
|
|
);
|
|
|
- break;
|
|
|
+ continue;
|
|
|
}
|
|
|
$mboxObj = $apiAccountManager->getMailbox($product['username']);
|
|
|
if(is_a($mboxObj, 'Exception')) {
|
|
|
@@ -254,9 +254,9 @@ function zimbraSingle_UsageUpdate($params) {
|
|
|
__FUNCTION__,
|
|
|
$params,
|
|
|
'Error: could not fetch mailbox info for ' . $product['username'],
|
|
|
- $mboxObj->getMessage()
|
|
|
+ $mboxObj
|
|
|
);
|
|
|
- break;
|
|
|
+ continue;
|
|
|
}
|
|
|
$mboxVars = get_object_vars($mboxObj);
|
|
|
$mboxSize = $mboxVars['S'];
|
|
|
@@ -323,7 +323,7 @@ function zimbraSingle_ChangePassword($params) {
|
|
|
__FUNCTION__,
|
|
|
$params,
|
|
|
'Error: password could not be set for ' . $params['username'],
|
|
|
- $response->getMessage()
|
|
|
+ $response
|
|
|
);
|
|
|
return false;
|
|
|
}
|
|
|
@@ -368,7 +368,7 @@ function zimbraSingle_CreateAccount($params) {
|
|
|
__FUNCTION__,
|
|
|
$params,
|
|
|
'Error: could not verify ' . $params['username'],
|
|
|
- $accountExists->getMessage()
|
|
|
+ $accountExists
|
|
|
);
|
|
|
return 'Error: could not verify '. $params['username'];
|
|
|
}
|
|
|
@@ -399,7 +399,7 @@ function zimbraSingle_CreateAccount($params) {
|
|
|
__FUNCTION__,
|
|
|
$params,
|
|
|
'Error: could not find serviceclass ' . $params['configoption1'],
|
|
|
- $cosID->getMessage()
|
|
|
+ $cosID
|
|
|
);
|
|
|
return 'Error: could not find serviceclass ' . $params['configoption1'];
|
|
|
}
|
|
|
@@ -411,7 +411,7 @@ function zimbraSingle_CreateAccount($params) {
|
|
|
__FUNCTION__,
|
|
|
$params,
|
|
|
'Error: could not create account ' . $params['username'],
|
|
|
- $zimbraID->getMessage()
|
|
|
+ $zimbraID
|
|
|
);
|
|
|
return 'Error: could not create account ' . $params['username'];
|
|
|
}
|
|
|
@@ -471,7 +471,7 @@ function zimbraSingle_SuspendAccount($params) {
|
|
|
__FUNCTION__,
|
|
|
$params,
|
|
|
'Error: could not lock account ' . $params['username'],
|
|
|
- $response->getMessage()
|
|
|
+ $response
|
|
|
);
|
|
|
return false;
|
|
|
}
|
|
|
@@ -512,7 +512,7 @@ function zimbraSingle_UnsuspendAccount($params) {
|
|
|
__FUNCTION__,
|
|
|
$params,
|
|
|
'Error: could not unlock account ' . $params['username'],
|
|
|
- $response->getMessage()
|
|
|
+ $response
|
|
|
);
|
|
|
return 'Error: could not unlock account ' . $params['username'];
|
|
|
}
|
|
|
@@ -552,7 +552,7 @@ function zimbraSingle_TerminateAccount($params) {
|
|
|
__FUNCTION__,
|
|
|
$params,
|
|
|
'Error: could not verify account '. $params['username'],
|
|
|
- $accountStatus->getMessage()
|
|
|
+ $accountStatus
|
|
|
);
|
|
|
return 'Error : account ' . $params['username'] . ' Name could not verified';
|
|
|
}
|
|
|
@@ -566,7 +566,7 @@ function zimbraSingle_TerminateAccount($params) {
|
|
|
__FUNCTION__,
|
|
|
$params,
|
|
|
'Error: could not remove account '. $params['username'],
|
|
|
- $response->getMessage()
|
|
|
+ $response
|
|
|
);
|
|
|
return 'Error: could not remove account '. $params['username'];
|
|
|
}
|
|
|
@@ -610,7 +610,7 @@ function zimbraSingle_ChangePackage($params) {
|
|
|
__FUNCTION__,
|
|
|
$params,
|
|
|
'Error: could not set class of service for '. $params['username'],
|
|
|
- $response->getMessage()
|
|
|
+ $response
|
|
|
);
|
|
|
return 'Error: could not set class of service for '. $params['username'];
|
|
|
}
|
|
|
@@ -621,7 +621,7 @@ function zimbraSingle_ChangePackage($params) {
|
|
|
__FUNCTION__,
|
|
|
$params,
|
|
|
'Error : could not find quota for ' . $params['username'],
|
|
|
- $accountQuota->getMessage()
|
|
|
+ $accountQuota
|
|
|
);
|
|
|
}
|
|
|
try {
|
|
|
@@ -704,7 +704,7 @@ function zimbraSingle_ConfigOptions($params) {
|
|
|
__FUNCTION__,
|
|
|
$params,
|
|
|
'Error: could not fetch classes of service',
|
|
|
- $cosIDs->getMessage()
|
|
|
+ $cosIDs
|
|
|
);
|
|
|
return false;
|
|
|
}
|
|
|
@@ -718,3 +718,73 @@ function zimbraSingle_ConfigOptions($params) {
|
|
|
);
|
|
|
return $configOptions;
|
|
|
}
|
|
|
+
|
|
|
+/**
|
|
|
+ * Perform single sign-on for a given instance of a product/service.
|
|
|
+ *
|
|
|
+ * Called when single sign-on is requested for an instance of a product/service.
|
|
|
+ *
|
|
|
+ * When successful, returns an URL to which the user should be redirected.
|
|
|
+ *
|
|
|
+ * @param array $params common module parameters
|
|
|
+ *
|
|
|
+ * @see https://developers.whmcs.com/provisioning-modules/module-parameters/
|
|
|
+ *
|
|
|
+ * @return array
|
|
|
+ */
|
|
|
+function zimbraSingle_ServiceSingleSignOn($params) {
|
|
|
+ $api = new Zm_Auth($params['serverhostname'], $params['serverusername'], $params['serverpassword'], 'admin');
|
|
|
+ $login = $api->login();
|
|
|
+ if(is_a($login, 'Exception')) {
|
|
|
+ logModuleCall(
|
|
|
+ 'zimbrasingle',
|
|
|
+ __FUNCTION__,
|
|
|
+ $params,
|
|
|
+ 'Error: cannot login to ' . $params['serverhostname'],
|
|
|
+ $login->getMessage()
|
|
|
+ );
|
|
|
+ return array(
|
|
|
+ 'success' => false,
|
|
|
+ 'redirectTo' => '',
|
|
|
+ );
|
|
|
+ }
|
|
|
+ $apiDomainManager = new Zm_Domain($api);
|
|
|
+ $domainOptions = $apiDomainManager->getDomainOptions($params['customfields']['maildomain']);
|
|
|
+ if(is_a($domainOptions, 'Exception')) {
|
|
|
+ logModuleCall(
|
|
|
+ 'zimbrasingle',
|
|
|
+ __FUNCTION__,
|
|
|
+ $params,
|
|
|
+ 'Error : could not fetch options for ' . $params['customfields']['maildomain'],
|
|
|
+ $domainOptions->getMessage()
|
|
|
+ );
|
|
|
+ return array(
|
|
|
+ 'success' => false,
|
|
|
+ 'redirectTo' => '',
|
|
|
+ );
|
|
|
+ }
|
|
|
+ $preAuthKey = $domainOptions['zimbraPreAuthKey'];
|
|
|
+ $apiAccountManager = new Zm_Account($api);
|
|
|
+ $accountInfo = $apiAccountManager->getAccountInfo($params['username']);
|
|
|
+ if(is_a($accountInfo, 'Exception')) {
|
|
|
+ logModuleCall(
|
|
|
+ 'zimbrasingle',
|
|
|
+ __FUNCTION__,
|
|
|
+ $params,
|
|
|
+ 'Error: could not gather informations for ' . $params['username'],
|
|
|
+ $accountInfo
|
|
|
+ );
|
|
|
+ return array(
|
|
|
+ 'success' => false,
|
|
|
+ 'redirectTo' => '',
|
|
|
+ );
|
|
|
+ }
|
|
|
+ $webmailUrl = zimbraSingleFindAll($accountInfo, 'PUBLICMAILURL');
|
|
|
+ $timestamp=time()*1000;
|
|
|
+ $preauthToken=hash_hmac('sha1', $params['username'] . '|name|0|' . $timestamp, $preAuthKey);
|
|
|
+ $preauthURL = $webmailUrl[0]['DATA'] . '/service/preauth?account=' . $params['username'] . '&by=name×tamp=' . $timestamp .'&expires=0&preauth='. $preauthToken;
|
|
|
+ return array(
|
|
|
+ 'success' => true,
|
|
|
+ 'redirectTo' => $preauthURL,
|
|
|
+ );
|
|
|
+}
|