andre 2 rokov pred
rodič
commit
73ef3b88ab

+ 36 - 12
app/UI/Client/EmailAlias/Providers/AddEmailAliasDataProvider.php

@@ -35,25 +35,49 @@ class AddEmailAliasDataProvider extends BaseDataProvider
          * hosting domain
          */
         $this->data['domain'] = $hosting->domain;
+        $api = new KerioWhmcs('whmcsKerioEmail', 'Thurdata', '1.0');
+        try {
+            $api->login($this->getWhmcsParamByKey('serverhostname'), $this->getWhmcsParamByKey('serverusername'), $this->getWhmcsParamByKey('serverpassword'));
+            $domains = $api->getDomains(['id','name']);
+        } catch (KerioApiException $error) {
+            logModuleCall(
+                'kerioEmail',
+                __FUNCTION__,
+                $error,
+                'Debug Error',
+                $error->getMessage()
+            );
+            return ['error' => $error->getMessage()];
+        }
+        foreach($domains as $maildomain) {
+            if(($maildomain['name']) === $this->getWhmcsParamByKey('domain')){ 
+                $this->maildomainID = $maildomain['id'];
+                $this->maildomain = $maildomain['name'];
+            }
+        }
+        $productManager = new ProductManager();
+        $productManager->loadByHostingId($hosting->id);
+        $fields = array(
+            "id",
+            "loginName"
+        );
+        $accounts = $api->getUsers($fields,$this->maildomainID);
+        $api->logout();
 
-        /**
-         * load api
-         * load repo
-         * load accounts from repo
-         */
-        $accounts =(new KerioManager())
-            ->getApiByHosting($hid)
-            ->soap
-            ->repository()
-            ->accounts
-            ->getByDomainName($hosting->domain);
+        logModuleCall(
+            'kerioEmail',
+            __FUNCTION__,
+            $accounts,
+            'Debug Aliases',
+            $hosting->domain
+        );
 
         /**
          * available accounts
          */
         foreach($accounts as $account)
         {
-            $this->availableValues['mailbox'][$account->getId()] = $account->getName();
+            $this->availableValues['mailbox'][$account['id']] = $account['loginName'] . '@' . $this->maildomain;
         }
 
     }