|
|
@@ -71,37 +71,51 @@ class CreateAccount extends AddonController
|
|
|
*/
|
|
|
protected function kerioRunService($params = null)
|
|
|
{
|
|
|
+ $api = new KerioWhmcs('whmcsKerioEmail', 'Thurdata', '1.0');
|
|
|
+ try {
|
|
|
+ $api->login($params['serverhostname'], $params['serverusername'], $params['serverpassword']);
|
|
|
+ $result = $api->createDomain($params['domain']);
|
|
|
+ $domainID = $result['result'][0]['id'];
|
|
|
+ } catch (KerioApiException $error) {
|
|
|
+ logModuleCall(
|
|
|
+ 'kerioEmail',
|
|
|
+ __FUNCTION__,
|
|
|
+ $error,
|
|
|
+ 'Debug Error',
|
|
|
+ $error->getMessage()
|
|
|
+ );
|
|
|
+ return ['error' => $error->getMessage()];
|
|
|
+ }
|
|
|
+
|
|
|
+ // check and calculate limits
|
|
|
$productManager = new ProductManager();
|
|
|
$productManager->loadById($params['pid']);
|
|
|
$acc_limit = $productManager->get('acc_limit');
|
|
|
$accounts = $productManager->get('acc_base') + $params['configoptions']['acc_add'] + $params['configoptions']['acc_new'];
|
|
|
if ($acc_limit >= 0) {
|
|
|
+ $attr['userMaxCountCheckbox'] = TRUE;
|
|
|
if ($accounts > $acc_limit) {
|
|
|
$accounts = $acc_limit;
|
|
|
}
|
|
|
+ $attr['userMaxCount'] = $acc_limit;
|
|
|
+ } else {
|
|
|
+ $attr['userMaxCountCheckbox'] = FALSE;
|
|
|
}
|
|
|
$domainMaxSize = $productManager->get('domainMaxSize');
|
|
|
$domainSize = $productManager->get('domainBaseSize') + $params['configoptions']['domainAddSize'] + $params['configoptions']['domainNewSize'];
|
|
|
if ($domainMaxSize >= 0) {
|
|
|
+ $attr['domainQuota']['diskSizeLimit']['isActive'] = TRUE;
|
|
|
if ($domainSize > $domainMaxSize) {
|
|
|
$domainSize = $domainMaxSize;
|
|
|
}
|
|
|
+ $attr['domainQuota']['diskSizeLimit']['limit']['value'] = $domainSize;
|
|
|
+ $attr['domainQuota']['diskSizeLimit']['limit']['units'] = 'GigaBytes';
|
|
|
+ } else {
|
|
|
+ $attr['domainQuota']['diskSizeLimit']['isActive'] = FALSE;
|
|
|
}
|
|
|
- $api = new KerioWhmcs('whmcsKerioEmail', 'Thurdata', '1.0');
|
|
|
try {
|
|
|
- $api->login($params['serverhostname'], $params['serverusername'], $params['serverpassword']);
|
|
|
- $result = $api->createDomain($params['domain']);
|
|
|
- $domainID = $result['result'][0]['id'];
|
|
|
- $api->logout();
|
|
|
- logModuleCall(
|
|
|
- 'kerioEmail',
|
|
|
- __FUNCTION__,
|
|
|
- $accounts,
|
|
|
- 'Debug ID',
|
|
|
- $domainSize
|
|
|
- );
|
|
|
+ $result = $api->modifyDomain($domainID, $attr);
|
|
|
} catch (KerioApiException $error) {
|
|
|
-
|
|
|
logModuleCall(
|
|
|
'kerioEmail',
|
|
|
__FUNCTION__,
|
|
|
@@ -109,10 +123,18 @@ class CreateAccount extends AddonController
|
|
|
'Debug Error',
|
|
|
$error->getMessage()
|
|
|
);
|
|
|
-
|
|
|
return ['error' => $error->getMessage()];
|
|
|
}
|
|
|
|
|
|
+ logModuleCall(
|
|
|
+ 'kerioEmail',
|
|
|
+ __FUNCTION__,
|
|
|
+ $attr,
|
|
|
+ 'Debug ID',
|
|
|
+ $result
|
|
|
+ );
|
|
|
+ $api->logout();
|
|
|
+
|
|
|
/**
|
|
|
* return success response
|
|
|
*/
|