andre 2 жил өмнө
parent
commit
0736ba70c1

+ 14 - 0
api/KerioWhmcs.php

@@ -457,6 +457,20 @@ class KerioWhmcs extends KerioConnectApi {
 		return $result;
 	}
 
+	/**
+	 * Delete Alias.
+	 *
+	 * @param	string	aliasID
+	 * @return	array	Result
+	 */
+	function deleteAlias($aliasID) {
+		$params = array(
+			'aliasIds' => array($aliasID),
+		);
+		$result = $this->sendRequest('Aliases.remove', $params);
+		return $result;
+	}
+
 	/**
 	 * Create user.
 	 *

+ 30 - 4
app/UI/Client/EmailAlias/Providers/DeleteEmailAliasDataProvider.php

@@ -9,6 +9,7 @@ use ThurData\Servers\KerioEmail\App\Libs\Kerio\Components\Api\Soap\Models\Accoun
 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;
 
 /**
  *
@@ -38,16 +39,41 @@ class DeleteEmailAliasDataProvider extends BaseDataProvider
          */
         $hid = $this->request->get('id');
 
-        /**
-         * product manager allow to check product settings
-         */
+        $api = new KerioWhmcs('whmcsKerioEmail', 'Thurdata', '1.0');
+        try {
+            $api->login($this->getWhmcsParamByKey('serverhostname'), $this->getWhmcsParamByKey('serverusername'), $this->getWhmcsParamByKey('serverpassword'));
+        } catch (KerioApiException $error) {
+            logModuleCall(
+                'kerioEmail',
+                __FUNCTION__,
+                $error,
+                'Debug Error',
+                $error->getMessage()
+            );
+            return ['error' => $error->getMessage()];
+        }
+        try {
+            $result = $api->deleteAlias($this->formData['id']);
+        } catch (KerioApiException $error) {
+            logModuleCall(
+                'kerioEmail',
+                __FUNCTION__,
+                $error,
+                'Debug Error',
+                $error->getMessage()
+            );
+            return ['error' => $error->getMessage()];
+        }
+
         logModuleCall(
             'kerioEmail',
             __FUNCTION__,
             $this->formData['id'],
             'Debug Error',
-            $this->formData
+            $result
         );
+        $api->logout();
+
         $productManager = new ProductManager();
         $productManager->loadByHostingId($hid);