瀏覽代碼

add domainaliase

andre 2 年之前
父節點
當前提交
2a329364ac

+ 0 - 2
app/UI/Client/DomainAlias/Forms/AddDomainAliasForm.php

@@ -39,8 +39,6 @@ class AddDomainAliasForm extends SortedFieldForm implements ClientArea
         $email->addInputComponent((new InputText('domain'))->addHtmlAttribute('readonly','true'));
         $this->addSection($email);
 
-        $this->addField((new Text('description'))->setDescription('descriptionDomainList'));
-
         /**
          * hidden fields
          */

+ 24 - 47
app/UI/Client/DomainAlias/Providers/AddDomainAliasDataProvider.php

@@ -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();
     }