Parcourir la source

cleanup pages

andre il y a 2 ans
Parent
commit
a5c0e6e586

+ 0 - 2
app/UI/Client/EmailAccount/Pages/Accounts.php

@@ -2,7 +2,6 @@
 
 namespace ThurData\Servers\KerioEmail\App\UI\Client\EmailAccount\Pages;
 
-use ThurData\Servers\KerioEmail\App\Libs\Product\ProductManager;
 use ThurData\Servers\KerioEmail\App\Libs\Kerio\Components\Api\Soap\Helpers\AccountHelper;
 use ThurData\Servers\KerioEmail\App\UI\Admin\Custom\Fields\EnabledField;
 use ThurData\Servers\KerioEmail\App\UI\Client\EmailAccount\Buttons\AddAccountButton;
@@ -14,7 +13,6 @@ use ThurData\Servers\KerioEmail\App\UI\Client\EmailAccount\Buttons\MassChangeSta
 use ThurData\Servers\KerioEmail\App\UI\Client\EmailAccount\Buttons\MassDeleteAccountButton;
 use ThurData\Servers\KerioEmail\App\UI\Client\EmailAccount\Buttons\SpanDropdownButton;
 use function ThurData\Servers\KerioEmail\Core\Helper\di;
-use ThurData\Servers\KerioEmail\Core\Models\Whmcs\Hosting;
 use ThurData\Servers\KerioEmail\Core\UI\Widget\DataTable\Column;
 use ThurData\Servers\KerioEmail\Core\UI\Widget\DataTable\DataProviders\DataProvider;
 use ThurData\Servers\KerioEmail\Core\UI\Interfaces\ClientArea;

+ 6 - 169
app/UI/Client/EmailAccount/Providers/AccountDataProvider.php

@@ -1,19 +1,9 @@
 <?php
 namespace ThurData\Servers\KerioEmail\App\UI\Client\EmailAccount\Providers;
-use ThurData\Servers\KerioEmail\App\Enums\ProductParams;
-use ThurData\Servers\KerioEmail\App\Enums\Size;
+
 use ThurData\Servers\KerioEmail\App\Enums\Kerio;
-use ThurData\Servers\KerioEmail\App\Helpers\KerioManager;
-use ThurData\Servers\KerioEmail\App\Http\Admin\ProductConfiguration;
 use ThurData\Servers\KerioEmail\App\Libs\Product\ProductManager;
-use ThurData\Servers\KerioEmail\App\Libs\Kerio\Components\Api\Soap\Helpers\ServiceFactory;
-use ThurData\Servers\KerioEmail\App\Libs\Kerio\Components\Api\Soap\Models\Account;
-use ThurData\Servers\KerioEmail\App\Libs\Kerio\Components\Api\Soap\Models\ClassOfService;
-use ThurData\Servers\KerioEmail\App\Libs\Kerio\Components\Api\Soap\Repository\ClassOfServices;
-use ThurData\Servers\KerioEmail\App\Services\ConfigurableOptions\Strategy\Types\ClassOfServicesOptions;
 use function ThurData\Servers\KerioEmail\Core\Helper\di;
-use ThurData\Servers\KerioEmail\Core\Http\JsonResponse;
-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;
@@ -31,12 +21,8 @@ class AccountDataProvider extends BaseDataProvider
 
     public function read()
     {
-        /**
-         * hosting id
-         */
-        $hid = $this->request->get('id');
-        $hosting = Hosting::where('id', $hid)->first();
-        $this->data['domain'] = $this->getWhmcsParamByKey('customfields')['maildomain'];
+
+        $this->data['domain'] = $this->getWhmcsParamByKey('domain');
         $this->data['quota'] = 0;
         $lang = di('lang');
         $this->availableValues['status'] = [
@@ -52,25 +38,13 @@ class AccountDataProvider extends BaseDataProvider
 
     public function create()
     {
-        /**
-         * hosting id
-         */
-        $hid = $this->request->get('id');
-
         $fieldToProtection = ['firstname', 'lastname', 'display_name', 'office', 'title', 'department', 'profession'];
-
         foreach ($this->formData as $field => &$value)
         {
             $value = in_array($field, $fieldToProtection) ? htmlentities($value) : $value;
         }
 
-        /**
-         * product manager allow to check product settings
-         */
-        $productManager = new ProductManager();
-        $productManager->loadByHostingId($hid);
-
-        $maildomain = $this->getWhmcsParamByKey('customfields')['maildomain'];
+        $maildomain = $this->getWhmcsParamByKey('domain');
         $api = new KerioWhmcs('whmcsKerioEmail', 'Thurdata', '1.0');
         try {
             $api->login($this->getWhmcsParamByKey('serverhostname'), $this->getWhmcsParamByKey('serverusername'), $this->getWhmcsParamByKey('serverpassword'));
@@ -108,7 +82,7 @@ class AccountDataProvider extends BaseDataProvider
             $account['diskSizeLimit']['limit']['units'] = $this->formData['unit'];
         }
         try {
-            $result1 = $api->modifyUser($userID, $account);
+            $result = $api->modifyUser($userID, $account);
         } catch (KerioApiException $error) {
             logModuleCall(
                 'kerioEmail',
@@ -129,7 +103,7 @@ class AccountDataProvider extends BaseDataProvider
         $fields['departmentName'] = $this->formData['department'];
         $fields['profession'] = $this->formData['profession'];
         try {
-            $result2 = $api->setAddress($userID, $fields);
+            $result = $api->setAddress($userID, $fields);
         } catch (KerioApiException $error) {
             logModuleCall(
                 'kerioEmail',
@@ -148,22 +122,10 @@ class AccountDataProvider extends BaseDataProvider
     public function updateStatus()
     {
 
-
     }
 
     public function update()
     {
-        /**
-         * hosting id
-         */
-        $hid = $this->request->get('id');
-
-        /**
-         * product manager allow to check product settings
-         */
-        $productManager = new ProductManager();
-        $productManager->loadByHostingId($hid);
-
         $status['isEnabled'] = $this->formData['status'] === 'active' ? TRUE : FALSE;
         $api = new KerioWhmcs('whmcsKerioEmail', 'Thurdata', '1.0');
         try {
@@ -211,121 +173,7 @@ class AccountDataProvider extends BaseDataProvider
      */
     protected function readCosParams()
     {
-        $hid = $this->request->get('id');
-
-
-        /**
-         *
-         * load product manager
-         */
-        $productManager = new ProductManager();
-        $productManager->loadByHostingId($hid);
-
-        /**
-         *
-         * check if class of services should be selectable
-         */
-        if($productManager->get('cos_name') === ClassOfServices::CLASS_OF_SERVICE_QUOTA)
-        {
-            /**
-             *
-             * get soap create domain  service
-             */
-            $api =(new KerioManager())
-                ->getApiByHosting($hid)
-                ->soap;
-
-            /**
-             *
-             * get cos from API
-             */
-            $classOfServices = $api->repository()->cos->all();
-
-            /**
-             *
-             * load configurable options coses
-             */
-            $supportedCos = $productManager->getSettingCos();
 
-            /**
-             *
-             * add COS to array
-             */
-            $configoptions = $this->getFilteredCosConfigurableOptions();
-
-            foreach($classOfServices as $cos)
-            {
-                /**
-                 *
-                 *
-                 * skip COS which is not used in configurable options
-                 */
-                if(!($supportedCos && array_key_exists($cos->getId(), $supportedCos)))
-                {
-                    continue;
-                }
-
-                /**
-                 * 1. check if config opts are available
-                 * 2. skip if class of services doesnt exists in config option list
-                 */
-                if($configoptions && !array_key_exists('cosQuota_'.$cos->getId(), $configoptions))
-                {
-                    continue;
-                }
-
-                /**
-                 * 1. check if config opts are available
-                 * 2. skip not purchased as CO
-                 */
-                if ($configoptions && $configoptions['cosQuota_'.$cos->getId()] == 0)
-                {
-                    continue;
-                }
-
-                /**
-                 * 1. check if config opts are not available
-                 * 2. skip if quantity === 0
-                 */
-                if(!$configoptions && $supportedCos[$cos->getId()] == 0)
-                {
-                    continue;
-                }
-
-                /* @var $cos ClassOfService*/
-                $this->availableValues['cosId'][$cos->getId()] = $cos->getMbMailQuote().' MB';
-            }
-
-
-            return $this;
-        }
-
-
-        /**
-         *
-         * check if class of service is choosen by config opt
-         */
-        if($productManager->get('cos_name') === ClassOfServices::KERIO_CONFIG_OPTIONS)
-        {
-
-            $this->data['cosId'] = key($productManager->getSettingCos());
-            return $this;
-        }
-
-        /**
-         *
-         * if cos_name is dedicated (loaded from API)
-         */
-        if($productManager->get('cos_name') !== ClassOfServices::CUSTOM_KERIO)
-        {
-            /**
-             * if dedicated class of service has been selected
-             */
-            $this->data['cosId'] = $productManager->get('cos_name');
-            return $this;
-        }
-
-        return $this;
     }
 
     /**
@@ -333,17 +181,6 @@ class AccountDataProvider extends BaseDataProvider
      */
     protected function getFilteredCosConfigurableOptions()
     {
-        $configoptions = $this->getWhmcsParamByKey('configoptions');
-
-        foreach($configoptions as $key => $value)
-        {
-            if(strpos($key, ClassOfServicesOptions::COS_CONFIG_OPT_PREFIX) === false)
-            {
-                unset($configoptions[$key]);
-            }
-
-        }
 
-        return $configoptions;
     }
 }