瀏覽代碼

mass actions

andre 2 年之前
父節點
當前提交
14a45abd48
共有 1 個文件被更改,包括 26 次插入8 次删除
  1. 26 8
      app/UI/Client/EmailAccount/Providers/DeleteAccountDataProvider.php

+ 26 - 8
app/UI/Client/EmailAccount/Providers/DeleteAccountDataProvider.php

@@ -89,21 +89,39 @@ class DeleteAccountDataProvider extends BaseDataProvider
         $productManager = new ProductManager();
         $productManager->loadByHostingId($hid);
 
-        logModuleCall(
-            'kerioEmail',
-            __FUNCTION__,
-            $this->request->get('massActions'),
-            'Debug Error',
-            $this->formData
-        );
+        $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)
         {
-
+            try {
+                $api->deleteUser($id);
+            } catch (KerioApiException $error) {
+                logModuleCall(
+                    'kerioEmail',
+                    __FUNCTION__,
+                    $error,
+                    'Debug Error',
+                    $error->getMessage()
+                );
+                return ['error' => $error->getMessage()];
+            }
         }
+        $api->logout();
 
         return (new HtmlDataJsonResponse())->setMessageAndTranslate('massEmailAccountHasBeenDeleted')->setStatusSuccess();
     }