Bläddra i källkod

del ressources

andre 2 år sedan
förälder
incheckning
108480d54e

+ 15 - 0
api/KerioWhmcs.php

@@ -479,6 +479,21 @@ class KerioWhmcs extends KerioConnectApi {
 		return $result;
 	}
 
+	/**
+	 * Remove resource.
+	 *
+	 * @param	string	Resource ID
+	 * @return	array	Result
+	 */
+	function delResouce($resource) {
+		$params = array(
+			'resourceIds' => array($resource)
+		);
+	
+		$result = $this->sendRequest('Resources.remove', $params);
+		return $result;
+	}
+
 	/**
 	 * Get list of aliases from a domain
 	 * 

+ 26 - 7
app/UI/Client/Ressource/Providers/DeleteRessourceDataProvider.php

@@ -8,6 +8,7 @@ use ThurData\Servers\KerioEmail\App\Libs\Product\ProductManager;
 use ThurData\Servers\KerioEmail\App\Libs\Kerio\Components\Api\Soap\Services\Delete\DeleteRessource;
 use ThurData\Servers\KerioEmail\Core\UI\ResponseTemplates\HtmlDataJsonResponse;
 use ThurData\Servers\KerioEmail\Core\UI\Widget\Forms\DataProviders\BaseDataProvider;
+use ThurData\Servers\KerioEmail\Api\KerioWhmcs;
 
 /**
  *
@@ -33,13 +34,31 @@ class DeleteRessourceDataProvider extends BaseDataProvider
     public function delete()
     {
 
-        logModuleCall(
-            'kerioEmail',
-            __FUNCTION__,
-            $this->formData,
-            'Debug Data',
-            $this->data
-        );
+        $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 {
+            $api->delResouce($this->formData['id']);
+        } catch (KerioApiException $error) {
+            logModuleCall(
+                'kerioEmail',
+                __FUNCTION__,
+                $error,
+                'Debug Error',
+                $error->getMessage()
+            );
+            return ['error' => $error->getMessage()];
+        }
 
         return (new HtmlDataJsonResponse())->setMessageAndTranslate('ressourceHasBeenDeleted')->setStatusSuccess();
 

+ 0 - 1
app/UI/Client/Ressource/Providers/RessourceDataProvider.php

@@ -148,7 +148,6 @@ class RessourceDataProvider extends BaseDataProvider
         $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',