Browse Source

changePackage - try to get domainId by name

andre 2 years ago
parent
commit
51441eb8e1
2 changed files with 10 additions and 12 deletions
  1. 1 8
      api/KerioWhmcs.php
  2. 9 4
      app/Http/Actions/ChangePackage.php

+ 1 - 8
api/KerioWhmcs.php

@@ -104,19 +104,12 @@ class KerioWhmcs extends KerioConnectApi {
 
 		$result = $this->sendRequest($method, $params);
 
-		logModuleCall(
-            'kerioEmail',
-            __FUNCTION__,
-            $result,
-            'Debug ChangePackage',
-            $domain
-        );
-
 		foreach($result['list'] as $key) {
 			if ($key['name'] == $domain) {
 				return $key['id'];
 			}
 		}
+
 		return FALSE;
 	}
 

+ 9 - 4
app/Http/Actions/ChangePackage.php

@@ -60,11 +60,13 @@ class ChangePackage extends AddonController
     {
 
         $productManager = new ProductManager();
+        $configOption = new ConfigOptionsHelper;
+        $updateLimit = new UpdateLimit;
         $productManager->loadById($params['pid']);
         $api = new KerioWhmcs('whmcsKerioEmail', 'Thurdata', '1.0');
         try {
             $api->login($params['serverhostname'], $params['serverusername'], $params['serverpassword']);
-            $result = $api->getDomainId('rondomali.ch');
+            $domainId = $api->getDomainId('rondomali.ch');
         } catch (KerioApiException $error) {
             logModuleCall(
                 'kerioEmail',
@@ -75,13 +77,16 @@ class ChangePackage extends AddonController
             );
             return ['error' => $error->getMessage()];
         }             
+        if ($domainId === FALSE) {
+            return "Error: Domain $domain not found";
+        }
 
         logModuleCall(
             'kerioEmail',
             __FUNCTION__,
-            $result,
-            'Debug ChangePackage',
-            $params
+            $params,
+            'Debug ChangPackage',
+            $domainId
         );
 
         $api->logout();