Bläddra i källkod

del mailinglists

andre 2 år sedan
förälder
incheckning
a2d61966ac
1 ändrade filer med 28 tillägg och 7 borttagningar
  1. 28 7
      app/UI/Client/DistributionList/Providers/DeleteListDataProvider.php

+ 28 - 7
app/UI/Client/DistributionList/Providers/DeleteListDataProvider.php

@@ -65,6 +65,8 @@ class DeleteListDataProvider extends BaseDataProvider
             return ['error' => $error->getMessage()];
         }
 
+        $api->logout();
+
         return (new HtmlDataJsonResponse())->setMessageAndTranslate('distributionListHasBeenDeleted')->setStatusSuccess();
     }
 
@@ -75,21 +77,40 @@ class DeleteListDataProvider extends BaseDataProvider
          */
         $hid = $this->request->get('id');
 
+        $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()];
+        }
         /**
          *
          */
         foreach($this->request->get('massActions') as $id)
         {
                 
-            logModuleCall(
-                'kerioEmail',
-                __FUNCTION__,
-                $id,
-                'Debug add ML',
-                $hid
-            );
+            try {
+                $result = $api->deleteMailinglist($id);
+            } catch (KerioApiException $error) {
+                logModuleCall(
+                    'kerioEmail',
+                    __FUNCTION__,
+                    $error,
+                    'Debug Error',
+                    $error->getMessage()
+                );
+                return ['error' => $error->getMessage()];
+            }
 
         }
+        $api->logout();
 
         return (new HtmlDataJsonResponse())->setMessageAndTranslate('massDistributionListHasBeenDeleted')->setStatusSuccess();
     }