|
|
@@ -9,6 +9,7 @@ use ThurData\Servers\KerioEmail\App\Libs\Kerio\Components\Api\Soap\Services\Dele
|
|
|
use ThurData\Servers\KerioEmail\Core\Models\Whmcs\Hosting;
|
|
|
use ThurData\Servers\KerioEmail\Core\UI\ResponseTemplates\HtmlDataJsonResponse;
|
|
|
use ThurData\Servers\KerioEmail\Core\UI\Widget\Forms\DataProviders\BaseDataProvider;
|
|
|
+use ThurData\Servers\KerioEmail\Api\KerioWhmcs;
|
|
|
|
|
|
/**
|
|
|
*
|
|
|
@@ -25,22 +26,22 @@ class AddDomainAliasDataProvider extends BaseDataProvider
|
|
|
{
|
|
|
$hosting = Hosting::where('id', $this->getRequestValue('id'))->first();
|
|
|
|
|
|
- /**
|
|
|
- * get API
|
|
|
- */
|
|
|
- $api =(new KerioManager())
|
|
|
- ->getApiByServer($hosting->server)
|
|
|
- ->soap;
|
|
|
-
|
|
|
- /**
|
|
|
- * load domain from repo
|
|
|
- */
|
|
|
- $domain = $api->repository()
|
|
|
- ->domains
|
|
|
- ->getByName($hosting->domain);
|
|
|
-
|
|
|
- $this->data['domainId'] = $domain->getId();
|
|
|
- $this->data['domain'] = $hosting->domain;
|
|
|
+ $api = new KerioWhmcs('whmcsKerioEmail', 'Thurdata', '1.0');
|
|
|
+ try {
|
|
|
+ $api->login($this->getWhmcsParamByKey('serverhostname'), $this->getWhmcsParamByKey('serverusername'), $this->getWhmcsParamByKey('serverpassword'));
|
|
|
+ $domainID = $api->getDomainId($this->getWhmcsParamByKey('domain'));
|
|
|
+ } catch (KerioApiException $error) {
|
|
|
+ logModuleCall(
|
|
|
+ 'kerioEmail',
|
|
|
+ __FUNCTION__,
|
|
|
+ $error,
|
|
|
+ 'Debug Error',
|
|
|
+ $error->getMessage()
|
|
|
+ );
|
|
|
+ return ['error' => $error->getMessage()];
|
|
|
+ }
|
|
|
+ $this->data['domainId'] = $domainID;
|
|
|
+ $this->data['domain'] = $this->getWhmcsParamByKey('domain');
|
|
|
|
|
|
}
|
|
|
|
|
|
@@ -56,37 +57,13 @@ class AddDomainAliasDataProvider extends BaseDataProvider
|
|
|
*/
|
|
|
$hid = $this->request->get('id');
|
|
|
|
|
|
- /**
|
|
|
- * load product configuration
|
|
|
- */
|
|
|
- $productManager = new ProductManager();
|
|
|
- $productManager->loadByHostingId($hid);
|
|
|
-
|
|
|
- /**
|
|
|
- * load kerio manager by hosting id
|
|
|
- */
|
|
|
- $service = (new KerioManager())
|
|
|
- ->getApiByHosting($hid)
|
|
|
- ->soap
|
|
|
- ->service()
|
|
|
- ->createDomainAlias()
|
|
|
- ->setProductManager($productManager)
|
|
|
- ->setFormData($this->formData)
|
|
|
- ;
|
|
|
-
|
|
|
- /**
|
|
|
- * run service
|
|
|
- */
|
|
|
- $result = $service->run();
|
|
|
-
|
|
|
- /**
|
|
|
- *
|
|
|
- * return success or error response
|
|
|
- */
|
|
|
- if(!$result)
|
|
|
- {
|
|
|
- return (new HtmlDataJsonResponse())->setMessageAndTranslate($service->getError())->setStatusError();
|
|
|
- }
|
|
|
+ logModuleCall(
|
|
|
+ 'kerioEmail',
|
|
|
+ __FUNCTION__,
|
|
|
+ $this,
|
|
|
+ 'Debug Error',
|
|
|
+ $this->formData
|
|
|
+ );
|
|
|
|
|
|
return (new HtmlDataJsonResponse())->setMessageAndTranslate('domainAliasHasBeenCreated')->setStatusSuccess();
|
|
|
}
|