|
|
@@ -34,10 +34,7 @@ class AccountDataProvider extends BaseDataProvider
|
|
|
* hosting id
|
|
|
*/
|
|
|
$hid = $this->request->get('id');
|
|
|
-
|
|
|
$hosting = Hosting::where('id', $hid)->first();
|
|
|
- //todo refactor
|
|
|
- $this->data['domain'] = $this->getWhmcsParamByKey('customfields')['maildomain'];
|
|
|
|
|
|
$lang = di('lang');
|
|
|
$this->availableValues['status'] = [
|
|
|
@@ -71,6 +68,45 @@ class AccountDataProvider extends BaseDataProvider
|
|
|
$productManager = new ProductManager();
|
|
|
$productManager->loadByHostingId($hid);
|
|
|
|
|
|
+ $maildomain = $this->getWhmcsParamByKey('customfields')['maildomain'];
|
|
|
+ $api = new KerioWhmcs('whmcsKerioEmail', 'Thurdata', '1.0');
|
|
|
+ try {
|
|
|
+ $api->login($params['serverhostname'], $params['serverusername'], $params['serverpassword']);
|
|
|
+ $domainID = $api->getDomainId($maildomain);
|
|
|
+ } catch (KerioApiException $error) {
|
|
|
+ logModuleCall(
|
|
|
+ 'kerioEmail',
|
|
|
+ __FUNCTION__,
|
|
|
+ $error,
|
|
|
+ 'Debug Error',
|
|
|
+ $error->getMessage()
|
|
|
+ );
|
|
|
+ return ['error' => $error->getMessage()];
|
|
|
+ }
|
|
|
+ if ($domainID === FALSE) {
|
|
|
+ return "Error: Domain $maildomain not found";
|
|
|
+ }
|
|
|
+ try {
|
|
|
+ $userID = $api->createUser($domainID, $this->formData['username'], $this->formData['password']);
|
|
|
+ } catch (KerioApiException $error) {
|
|
|
+ logModuleCall(
|
|
|
+ 'kerioEmail',
|
|
|
+ __FUNCTION__,
|
|
|
+ $error,
|
|
|
+ 'Debug Error',
|
|
|
+ $error->getMessage()
|
|
|
+ );
|
|
|
+ return ['error' => $error->getMessage()];
|
|
|
+ }
|
|
|
+
|
|
|
+ $account['fullName'] = $this->formData['display_name'];
|
|
|
+ if ($this->formData['quota'] > 0) {
|
|
|
+ $account['diskSizeLimit']['isActive'] = TRUE;
|
|
|
+ $account['diskSizeLimit']['limit']['value'] = $this->formData['quota'];
|
|
|
+ $account['diskSizeLimit']['limit']['unit'] = $this->formData['unit'];
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
$fields['firstName'] = $this->formData['firstname'];
|
|
|
$fields['surName'] = $this->formData['lastname'];
|
|
|
$fields['commonName'] = $this->formData['display_name'];
|
|
|
@@ -80,18 +116,13 @@ class AccountDataProvider extends BaseDataProvider
|
|
|
$fields['phoneNumberMobile'] = $this->formData['mobile_phone'];
|
|
|
$fields['departmentName'] = $this->formData['department'];
|
|
|
$fields['profession'] = $this->formData['profession'];
|
|
|
- if ($this->formData['quota'] > 0) {
|
|
|
- $fields['diskSizeLimit']['isActive'] = TRUE;
|
|
|
- $fields['diskSizeLimit']['limit']['value'] = $this->formData['quota'];
|
|
|
- $fields['diskSizeLimit']['limit']['unit'] = $this->formData['unit'];
|
|
|
- }
|
|
|
|
|
|
logModuleCall(
|
|
|
'kerioEmail',
|
|
|
__FUNCTION__,
|
|
|
- $this->formData,
|
|
|
+ $domainID,
|
|
|
'Debug Add Account',
|
|
|
- $this->getWhmcsParamByKey('customfields')['maildomain']
|
|
|
+ $userID
|
|
|
);
|
|
|
|
|
|
return (new HtmlDataJsonResponse())->setMessageAndTranslate('emailAccountHasBeenAdded')->setStatusSuccess();
|