|
|
@@ -13,6 +13,8 @@ use ThurData\Servers\KerioEmail\Core\App\Controllers\Instances\AddonController;
|
|
|
use ThurData\Servers\KerioEmail\App\Traits\HostingService;
|
|
|
use \ThurData\Servers\KerioEmail\Core\UI\Traits\WhmcsParams;
|
|
|
use ThurData\Servers\KerioEmail\Api\KerioWhmcs;
|
|
|
+use ThurData\Servers\KerioEmail\Core\Helper\ConfigOptionsHelper;
|
|
|
+use ThurData\Servers\KerioEmail\Core\Helper\UpdateLimit;
|
|
|
|
|
|
/**
|
|
|
*
|
|
|
@@ -89,9 +91,24 @@ class CreateAccount extends AddonController
|
|
|
|
|
|
// check and calculate limits
|
|
|
$productManager = new ProductManager();
|
|
|
+ $configOption = new ConfigOptionsHelper;
|
|
|
+ $updateLimit = new UpdateLimit;
|
|
|
$productManager->loadById($params['pid']);
|
|
|
- $acc_limit = $productManager->get('acc_limit');
|
|
|
- $accounts = $productManager->get('acc_base') + $params['configoptions']['acc_add'] + $params['configoptions']['acc_new'];
|
|
|
+ $acc_base = $productManager->get('acc_base') ? $productManager->get('acc_base') : 0;
|
|
|
+ $acc_limit = $productManager->get('acc_limit') ? $productManager->get('acc_limit') : 0;
|
|
|
+ $acc_add = $params['configoptions']['acc_add'] + $params['configoptions']['acc_new'];
|
|
|
+ $acc_new = 0;
|
|
|
+ // update
|
|
|
+ $acc_addObj = $configOption->getConfigurableOption($params['pid'], 'acc_add');
|
|
|
+ if(isset($acc_addObj->id)) {
|
|
|
+ $configOption->updateConfigurableOption($acc_addObj->id, ['qty' => $acc_add]);
|
|
|
+ }
|
|
|
+ $acc_newObj = $configOption->getConfigurableOption($params['pid'], 'acc_new');
|
|
|
+ if(isset($acc_newObj->id)) {
|
|
|
+ $configOption->updateConfigurableOption($acc_newObj->id, ['qty' => $acc_new]);
|
|
|
+ }
|
|
|
+ $accounts = $acc_base + $acc_add;
|
|
|
+ // set user count attributes
|
|
|
if ($acc_limit > 0) {
|
|
|
$attr['userMaxCountCheckbox'] = TRUE;
|
|
|
if ($accounts > $acc_limit) {
|
|
|
@@ -101,9 +118,23 @@ class CreateAccount extends AddonController
|
|
|
} else {
|
|
|
$attr['userMaxCountCheckbox'] = FALSE;
|
|
|
}
|
|
|
- $domainMaxSize = $productManager->get('domainMaxSize');
|
|
|
- $domainSize = $productManager->get('domainBaseSize') + $params['configoptions']['domainAddSize'] + $params['configoptions']['domainNewSize'];
|
|
|
- if ($domainMaxSize >= 0) {
|
|
|
+
|
|
|
+ $domainBaseSize = $productManager->get('domainBaseSize') ? $productManager->get('domainBaseSize') : 0;
|
|
|
+ $domainMaxSize = $productManager->get('domainMaxSize') ? $productManager->get('domainMaxSize') : 0;
|
|
|
+ $domainAddSize = $params['configoptions']['domainAddSize'] + $params['configoptions']['domainNewSize'];
|
|
|
+ $domainNewSize = 0;
|
|
|
+ // update
|
|
|
+ $domainAddSizeObj = $configOption->getConfigurableOption($params['pid'], 'domainAddSize');
|
|
|
+ if(isset($domainAddSizeObj->id)) {
|
|
|
+ $configOption->updateConfigurableOption($domainAddSizeObj->id, ['qty' => $domainAddSize]);
|
|
|
+ }
|
|
|
+ $domainNewSizeObj = $configOption->getConfigurableOption($params['pid'], 'domainNewSize');
|
|
|
+ if(isset($domainNewSizeObj->id)) {
|
|
|
+ $configOption->updateConfigurableOption($domainNewSizeObj->id, ['qty' => $domainNewSize]);
|
|
|
+ }
|
|
|
+ $domainSize = $domainBaseSize + $domainAddSize;
|
|
|
+ // set domain size attributes
|
|
|
+ if ($domainMaxSize > 0) {
|
|
|
$attr['domainQuota']['diskSizeLimit']['isActive'] = TRUE;
|
|
|
if ($domainSize > $domainMaxSize) {
|
|
|
$domainSize = $domainMaxSize;
|
|
|
@@ -126,7 +157,8 @@ class CreateAccount extends AddonController
|
|
|
return ['error' => $error->getMessage()];
|
|
|
}
|
|
|
$api->logout();
|
|
|
-
|
|
|
+ $updateLimit->updateDiskLimit($params['pid'], $domainSize * 1024);
|
|
|
+ $updateLimit->updateBWLimit($params['pid'], $accounts);
|
|
|
/**
|
|
|
* return success response
|
|
|
*/
|