productManager->getHosting(); $serviceID = $hosting->id; $configOption = new ConfigOptionsHelper; $acc_base = $this->productManager->get('acc_base') ? $this->productManager->get('acc_base') : 0; if(isset($this->formData['configoptions']['acc_add']) && isset($this->formData['configoptions']['acc_new'])) { $acc_add = $this->formData['configoptions']['acc_add']; $acc_new = $this->formData['configoptions']['acc_new']; $acc_add = $acc_add + $acc_new; $acc_new = 0; $accountLimit = $acc_base + $acc_add; if (($this->productManager->get('acc_limit') > 0) && ($accountLimit > $this->productManager->get('acc_limit'))) { $acc_add = $this->productManager->get('acc_limit') - $acc_base; $accountLimit = $this->productManager->get('acc_limit'); } $acc_addObj = $configOption->getConfigurableOption($serviceID, 'acc_add'); if(isset($acc_addObj->id)) { $configOption->updateConfigurableOption($acc_addObj->id, ['qty' => $acc_add]); } $acc_newObj = $configOption->getConfigurableOption($serviceID, 'acc_new'); if(isset($acc_newObj->id)) { $configOption->updateConfigurableOption($acc_newObj->id, ['qty' => $acc_new]); } } else { $accountLimit = $acc_base; } $domain = new Domain(); $domain->setName($this->formData['domain']); $domainBaseSize = $this->productManager->get('domainBaseSize') ? $this->productManager->get('domainBaseSize') : 0; if(isset($this->formData['configoptions']['domainAddSize']) && isset($this->formData['configoptions']['domainNewSize'])) { $domainAddSize = $this->formData['configoptions']['domainAddSize']; $domainNewSize = $this->formData['configoptions']['domainNewSize']; $domainAddSize = $domainAddSize + $domainNewSize; $domainNewSize = 0; $domainSize = $domainBaseSize + $domainAddSize; if (($this->productManager->get('domainMaxSize') > 0) && ($domainSize > $this->productManager->get('domainMaxSize'))) { $domainMaxSize = $this->productManager->get('domainMaxSize'); $domainAddSize = $domainMaxSize - $domainBaseSize; $domainSize = $domainBaseSize + $domainAddSize; } $domainAddSizeObj = $configOption->getConfigurableOption($serviceID, 'domainAddSize'); if(isset($domainAddSizeObj->id)) { $configOption->updateConfigurableOption($domainAddSizeObj->id, ['qty' => $domainAddSize]); } $domainNewSizeObj = $configOption->getConfigurableOption($serviceID, 'domainNewSize'); if(isset($domainNewSizeObj->id)) { $configOption->updateConfigurableOption($domainNewSizeObj->id, ['qty' => $domainNewSize]); } } else { $domainSize = $domainBaseSize; } $updateLimit = new UpdateLimit; $updateLimit->updateDiskLimit($serviceID, $domainSize * 1024); $updateLimit->updateBWLimit($serviceID, $accountLimit); $domain->setAttrs([ Domain::ATTR_MAIL_DOMAIN_QUOTA => $domainSize * Size::B_TO_GB, ]); /** * API request */ $result = $this->api->domain->create($domain); /** * check result */ if(!$result) { $this->setError($this->api->domain->getLastResult()->getLastErrorCode()); return false; } return $result; } }