Przeglądaj źródła

edit mailinglists

andre 2 lat temu
rodzic
commit
22239128c3

+ 1 - 0
api/KerioWhmcs.php

@@ -284,6 +284,7 @@ class KerioWhmcs extends KerioConnectApi {
 		$params = array(
 			'query' => array(
 				'fields' => $fields,
+				'conditions' => array($conditions),
 				'orderBy' => array(array(
 					'columnName' => 'name',
 					'direction' => 'Asc'

+ 58 - 1
app/UI/Client/DistributionList/Providers/EditListDataProvider.php

@@ -15,6 +15,7 @@ use function ThurData\Servers\KerioEmail\Core\Helper\di;
 use ThurData\Servers\KerioEmail\Core\Models\Whmcs\Hosting;
 use ThurData\Servers\KerioEmail\Core\UI\ResponseTemplates\HtmlDataJsonResponse;
 use ThurData\Servers\KerioEmail\Core\UI\Widget\Forms\DataProviders\BaseDataProvider;
+use ThurData\Servers\KerioEmail\Api\KerioWhmcs;
 
 /**
  *
@@ -29,11 +30,67 @@ class EditListDataProvider extends AddListDataProvider
 
     public function read()
     {
+        $fields = array(
+            "id",
+            "name",
+            "description",
+            "languageId",
+            "subscription",
+            "replyTo",
+            "posting"
+        );
+
+        $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()];
+        }
+        try {
+            $domainID = $api->getDomainId($this->getWhmcsParamByKey('domain'));
+        } catch (KerioApiException $error) {
+            logModuleCall(
+                'kerioEmail',
+                __FUNCTION__,
+                $error,
+                'Debug Error',
+                $error->getMessage()
+            );
+            return ['error' => $error->getMessage()];
+        }
+        $cond = array(
+            "fieldName" => "id",
+            "comparator" => "Eq",
+            "value" => $this->actionElementId
+        );
+
+        try {
+            $list = $api->getMailingLists($fields,$domainID,$cond);
+        } catch (KerioApiException $error) {
+            logModuleCall(
+                'kerioEmail',
+                __FUNCTION__,
+                $error,
+                'Debug Error',
+                $error->getMessage()
+            );
+            return ['error' => $error->getMessage()];
+        }
+
+
+        $api->logout();
 
         logModuleCall(
             'kerioEmail',
             __FUNCTION__,
-            $this,
+            $list,
             'Debug Error',
             $this->actionElementId
         );