فهرست منبع

get mailinglists

andre 2 سال پیش
والد
کامیت
0f712fa6bc

+ 4 - 4
app/UI/Client/DistributionList/Forms/AddListForm.php

@@ -35,10 +35,10 @@ class AddListForm extends SortedFieldForm implements ClientArea
     protected function initFields()
     {
         $this->addSection(new AddMembersDistribution());
-        $this->addSection(new AddPropertiesDistribution());
-        $this->addSection(new AddAliasesDistribution());
-        $this->addSection(new AddOwnersDistribution());
-        $this->addSection(new AddPreferencesDistribution());
+//        $this->addSection(new AddPropertiesDistribution());
+//        $this->addSection(new AddAliasesDistribution());
+//        $this->addSection(new AddOwnersDistribution());
+//        $this->addSection(new AddPreferencesDistribution());
 
     }
 

+ 45 - 21
app/UI/Client/DistributionList/Providers/AddListDataProvider.php

@@ -10,6 +10,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;
 
 /**
  *
@@ -27,16 +28,49 @@ class AddListDataProvider extends BaseDataProvider
         $hosting = Hosting::where('id', $this->getRequestValue('id'))->first();
         $this->data['domain'] = $hosting->domain;
 
-        /**
-         * load api
-         */
-        $accounts     = (new KerioManager())
-            ->getApiByServer($hosting->server)
-            ->soap
-            ->repository()
-            ->accounts
-            ->getByDomainName($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");
+        try {
+            $accounts = $api->getUsers($fields,$this->maildomainID);
+        } catch (KerioApiException $error) {
+            logModuleCall(
+                'kerioEmail',
+                __FUNCTION__,
+                $error,
+                'Debug Error',
+                $error->getMessage()
+            );
+            return ['error' => $error->getMessage()];
+        }
+        $api->logout();
 
+        foreach($accounts as $account)
+        {
+            $this->availableValues['memberList'][$account['loginName']] = $account['loginName'];
+        }
 
         /**
          *
@@ -49,7 +83,7 @@ class AddListDataProvider extends BaseDataProvider
          */
         $this->availableValues['subscriptionRequest'] = [
             Kerio::STATUS_ACCEPT   => $lang->absoluteT('Automatically accept'),
-            Kerio::STATUS_APPROVAL => $lang->absoluteT('Require list owner approval'),
+            Kerio::STATUS_APPROVAL => $lang->absoluteT('Require moderator approval'),
             Kerio::STATUS_REJECT   => $lang->absoluteT('Automatically reject')
         ];
 
@@ -58,20 +92,10 @@ class AddListDataProvider extends BaseDataProvider
          */
         $this->availableValues['unsubscriptionRequest'] = [
             Kerio::STATUS_ACCEPT   => $lang->absoluteT('Automatically accept'),
-            Kerio::STATUS_APPROVAL => $lang->absoluteT('Require list owner approval'),
+            Kerio::STATUS_APPROVAL => $lang->absoluteT('Require moderator approval'),
             Kerio::STATUS_REJECT   => $lang->absoluteT('Automatically reject')
         ];
 
-
-
-        /**
-         *
-         */
-        foreach($accounts as $account)
-        {
-            $this->availableValues['memberList'][$account->getName()] = $account->getName();
-        }
-
         if($this->formData)
         {
             $this->loadReloadedData();

+ 12 - 1
app/UI/Client/EmailAccount/Pages/Accounts.php

@@ -172,7 +172,18 @@ class Accounts extends DataTable implements ClientArea
             "diskSizeLimit",
             "consumedSize",
             "lastLoginInfo");
-        $accounts = $api->getUsers($fields,$this->maildomainID);
+        try {
+            $accounts = $api->getUsers($fields,$this->maildomainID);
+        } catch (KerioApiException $error) {
+            logModuleCall(
+                'kerioEmail',
+                __FUNCTION__,
+                $error,
+                'Debug Error',
+                $error->getMessage()
+            );
+            return ['error' => $error->getMessage()];
+        }
         $api->logout();
 
         $data = [];