andre 5 месяцев назад
Родитель
Сommit
f86590788a

+ 7 - 3
app/UI/Client/Setting/Forms/InfoForm.php

@@ -3,7 +3,7 @@ namespace ThurData\Servers\KerioEmail\App\UI\Client\Setting\Forms;
 
 use ThurData\Servers\KerioEmail\App\Traits\FormExtendedTrait;
 use ThurData\Servers\KerioEmail\App\UI\Admin\Custom\Forms\SortedFieldForm;
-use ThurData\Servers\KerioEmail\App\UI\Client\Setting\Providers\SettingDataProvider;
+use ThurData\Servers\KerioEmail\App\UI\Client\Setting\Providers\InfoSettingDataProvider;
 use ThurData\Servers\KerioEmail\Core\UI\Interfaces\ClientArea;
 use ThurData\Servers\KerioEmail\Core\UI\Widget\Forms\Fields\Hidden;
 use ThurData\Servers\KerioEmail\Core\UI\Widget\Forms\Fields\Select;
@@ -18,7 +18,7 @@ class InfoForm extends BaseForm implements ClientArea
     {
         $this->initIds('infoForm');
         $this->setFormType('info');
-        $this->setProvider(new SettingDataProvider());
+        $this->setProvider(new InfoSettingDataProvider());
         $this->initFields();
         $this->loadDataToForm();
     }
@@ -31,7 +31,11 @@ class InfoForm extends BaseForm implements ClientArea
     private function initFields()
     {
         $this->setConfirmMessage("DNS Information");
-        $this->addField(new Hidden("seldns"));
+        $this->addField(new Hidden("selfdns"));
+        $this->addField(new Hidden("selfdomain"));
         $this->addField(new Text("mxactive"));
+        $this->addField(new Text("spf"));
+        $this->addField(new Text("dmarc"));
+        $this->addField(new Text("dkim"));
     }
 }

+ 89 - 0
app/UI/Client/Setting/Providers/InfoSettingDataProvider.php

@@ -0,0 +1,89 @@
+<?php
+namespace ThurData\Servers\KerioEmail\App\UI\Client\Setting\Providers;
+
+use ThurData\Servers\KerioEmail\App\Enums\Kerio;
+use function ThurData\Servers\KerioEmail\Core\Helper\di;
+use ThurData\Servers\KerioEmail\Core\UI\ResponseTemplates\HtmlDataJsonResponse;
+use ThurData\Servers\KerioEmail\Core\UI\Widget\Forms\DataProviders\BaseDataProvider;
+use ThurData\Servers\KerioEmail\Api\KerioWhmcs;
+
+/**
+ *
+ * Created by PhpStorm.
+ * User: ThurData
+ * Date: 10.09.19
+ * Time: 13:06
+ * Class SettingDataProvider
+ */
+class InfoSettingDataProvider extends BaseDataProvider
+{
+
+    public function read()
+    {
+        $this->data['domain'] = $this->getWhmcsParamByKey('domain');
+
+        $api = new KerioWhmcs('whmcsKerioEmail', 'Thurdata', '1.0');
+        try {
+            $api->login($this->getWhmcsParamByKey('serverhostname'), $this->getWhmcsParamByKey('serverusername'), $this->getWhmcsParamByKey('serverpassword'));
+            $domainID = $api->getDomainId($this->getWhmcsParamByKey('domain'));
+        } catch (KerioApiException $error) {
+            logModuleCall(
+                'kerioEmail',
+                __FUNCTION__,
+                $error,
+                'Debug Error',
+                $error->getMessage()
+            );
+            return ['error' => $error->getMessage()];
+        }
+        $fields = array(
+            "id",
+            "loginName",
+            "isEnabled");
+        try {
+            $users = $api->getUsers($fields,$domainID);
+        } catch (KerioApiException $error) {
+            logModuleCall(
+                'kerioEmail',
+                __FUNCTION__,
+                $error,
+                'Debug Error',
+                $error->getMessage()
+            );
+            return ['error' => $error->getMessage()];
+        }
+        $api->logout();
+
+        foreach($users as $user) {
+            if($user['isEnabled']){
+                $this->availableValues['manager'][ $user['id']] = $user['loginName'] . '@' . $this->getWhmcsParamByKey('domain');
+            }
+        }
+
+        $lang = di('lang');
+        $this->availableValues['status'] = [
+            Kerio::ACC_STATUS_ACTIVE        => $lang->absoluteT('kerio','account','status','active'),
+            Kerio::ACC_STATUS_CLOSED        => $lang->absoluteT('kerio','account','status','closed'),
+        ];
+
+        $this->availableValues['type'] = [
+            Kerio::RES_TYPE_LOCATION        => $lang->absoluteT('kerio','ressource','type','location'),
+            Kerio::RES_TYPE_EQUIPMENT       => $lang->absoluteT('kerio','ressource','type','equipment')
+        ];
+    }
+
+    public function create()
+    {
+
+    }
+
+    public function updateStatus()
+    {
+
+    }
+
+    public function update()
+    {
+
+    }
+}

+ 0 - 171
app/UI/Client/Setting/Providers/SettingDataProvider.php

@@ -1,171 +0,0 @@
-<?php
-namespace ThurData\Servers\KerioEmail\App\UI\Client\Setting\Providers;
-
-use ThurData\Servers\KerioEmail\App\Enums\Kerio;
-use function ThurData\Servers\KerioEmail\Core\Helper\di;
-use ThurData\Servers\KerioEmail\Core\UI\ResponseTemplates\HtmlDataJsonResponse;
-use ThurData\Servers\KerioEmail\Core\UI\Widget\Forms\DataProviders\BaseDataProvider;
-use ThurData\Servers\KerioEmail\Api\KerioWhmcs;
-
-/**
- *
- * Created by PhpStorm.
- * User: ThurData
- * Date: 10.09.19
- * Time: 13:06
- * Class SettingDataProvider
- */
-class SettingDataProvider extends BaseDataProvider
-{
-
-    public function read()
-    {
-        $this->data['domain'] = $this->getWhmcsParamByKey('domain');
-
-        $api = new KerioWhmcs('whmcsKerioEmail', 'Thurdata', '1.0');
-        try {
-            $api->login($this->getWhmcsParamByKey('serverhostname'), $this->getWhmcsParamByKey('serverusername'), $this->getWhmcsParamByKey('serverpassword'));
-            $domainID = $api->getDomainId($this->getWhmcsParamByKey('domain'));
-        } catch (KerioApiException $error) {
-            logModuleCall(
-                'kerioEmail',
-                __FUNCTION__,
-                $error,
-                'Debug Error',
-                $error->getMessage()
-            );
-            return ['error' => $error->getMessage()];
-        }
-        $fields = array(
-            "id",
-            "loginName",
-            "isEnabled");
-        try {
-            $users = $api->getUsers($fields,$domainID);
-        } catch (KerioApiException $error) {
-            logModuleCall(
-                'kerioEmail',
-                __FUNCTION__,
-                $error,
-                'Debug Error',
-                $error->getMessage()
-            );
-            return ['error' => $error->getMessage()];
-        }
-        $api->logout();
-
-        foreach($users as $user) {
-            if($user['isEnabled']){
-                $this->availableValues['manager'][ $user['id']] = $user['loginName'] . '@' . $this->getWhmcsParamByKey('domain');
-            }
-        }
-
-        $lang = di('lang');
-        $this->availableValues['status'] = [
-            Kerio::ACC_STATUS_ACTIVE        => $lang->absoluteT('kerio','account','status','active'),
-            Kerio::ACC_STATUS_CLOSED        => $lang->absoluteT('kerio','account','status','closed'),
-        ];
-
-        $this->availableValues['type'] = [
-            Kerio::RES_TYPE_LOCATION        => $lang->absoluteT('kerio','ressource','type','location'),
-            Kerio::RES_TYPE_EQUIPMENT       => $lang->absoluteT('kerio','ressource','type','equipment')
-        ];
-    }
-
-    public function create()
-    {
-        $fieldToProtection = [
-            'name',
-            'status',
-            'manager',
-            'type',
-            'description'
-        ];
-
-        foreach ($this->formData as $field => &$value)
-        {
-            $value = in_array($field, $fieldToProtection) ? htmlentities($value) : $value;
-        }
-
-        $api = new KerioWhmcs('whmcsKerioEmail', 'Thurdata', '1.0');
-        try {
-            $api->login($this->getWhmcsParamByKey('serverhostname'), $this->getWhmcsParamByKey('serverusername'), $this->getWhmcsParamByKey('serverpassword'));
-            $domainID = $api->getDomainId($this->getWhmcsParamByKey('domain'));
-        } catch (KerioApiException $error) {
-            logModuleCall(
-                'kerioEmail',
-                __FUNCTION__,
-                $error,
-                'Debug Error',
-                $error->getMessage()
-            );
-            return ['error' => $error->getMessage()];
-        }
-        try {
-            $ressourceID = $api->createResouce($this->formData, $domainID);
-        } catch (KerioApiException $error) {
-            logModuleCall(
-                'kerioEmail',
-                __FUNCTION__,
-                $error,
-                'Debug Error',
-                $error->getMessage()
-            );
-            return ['error' => $error->getMessage()];
-        }
-        $api->logout();
-
-        return (new HtmlDataJsonResponse())->setMessageAndTranslate('ressourceHasBeenAdded')->setStatusSuccess();
-
-    }
-
-    public function updateStatus()
-    {
-
-
-    }
-
-    public function update()
-    {
-        $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()];
-        }
-
-        $isEnabled = $this->formData['status'] === Kerio::ACC_STATUS_ACTIVE ? true : false;
-
-        /**
-         * run service for each id
-         */
-        foreach($this->request->get('massActions') as $id)
-        {
-            try {
-                $result = $api->updateResouce(['isEnabled' => $isEnabled], $id);
-            } catch (KerioApiException $error) {
-                logModuleCall(
-                    'kerioEmail',
-                    __FUNCTION__,
-                    $error,
-                    'Debug Error',
-                    $error->getMessage()
-                );
-                return ['error' => $error->getMessage()];
-            }
-    
-        }
-        $api->logout();
-        /**
-         * return success
-         */
-        return (new HtmlDataJsonResponse())->setMessageAndTranslate('massSettingStatusHasBeenUpdated')->setStatusSuccess();
-    }
-}