andre il y a 2 ans
Parent
commit
cb2a7ab1a9
1 fichiers modifiés avec 29 ajouts et 2 suppressions
  1. 29 2
      app/UI/Client/EmailAccount/Providers/AccountDataProvider.php

+ 29 - 2
app/UI/Client/EmailAccount/Providers/AccountDataProvider.php

@@ -164,14 +164,41 @@ class AccountDataProvider extends BaseDataProvider
         $productManager = new ProductManager();
         $productManager->loadByHostingId($hid);
 
+        $status['isEnabled'] = $this->formData['status'] === 'active' ? TRUE : FALSE;
+        $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()];
+        }
+
         /**
          * run service for each id
          */
         foreach($this->request->get('massActions') as $id)
         {
-
+            try {
+                $result = $api->modifyUser($id, $status);
+            } catch (KerioApiException $error) {
+                logModuleCall(
+                    'kerioEmail',
+                    __FUNCTION__,
+                    $error,
+                    'Debug Error',
+                    $error->getMessage()
+                );
+                return ['error' => $error->getMessage()];
+            }
         }
-
+        $api->logout();
+        
         logModuleCall(
             'kerioEmail',
             __FUNCTION__,