Răsfoiți Sursa

add ressources

andre 2 ani în urmă
părinte
comite
b7ee192520

+ 0 - 1
app/UI/Client/Ressource/Forms/AddRessourceForm.php

@@ -23,7 +23,6 @@ use ThurData\Servers\KerioEmail\Core\UI\Widget\Forms\Sections\HalfPageSection;
 use ThurData\Servers\KerioEmail\Core\UI\Widget\Forms\Sections\InputGroup;
 use ThurData\Servers\KerioEmail\Core\UI\Widget\Forms\Fields\InputGroupElements;
 use ThurData\Servers\KerioEmail\Core\UI\Widget\Forms\Sections\RawSection;
-use ThurData\Servers\KerioEmail\Api\KerioWhmcs;
 
 /**
  *

+ 0 - 8
app/UI/Client/Ressource/Pages/Ressources.php

@@ -206,14 +206,6 @@ class Ressources extends DataTable implements ClientArea
             $data[] = $ressourceArray;
         }
 
-        logModuleCall(
-            'kerioEmail',
-            __FUNCTION__,
-            $ressources,
-            'Debug Error',
-            $data
-        );
-
         $dataProv = new ArrayDataProvider();
         $dataProv->setDefaultSorting('ressource', 'ASC')->setData($data);
 

+ 41 - 72
app/UI/Client/Ressource/Providers/RessourceDataProvider.php

@@ -16,6 +16,7 @@ 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;
 
 /**
  *
@@ -39,14 +40,46 @@ class RessourceDataProvider extends BaseDataProvider
         //todo refactor
         $this->data['domain'] = $hosting->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()];
+        }
+        try {
+            $users = $api->getUsers(['id','name'],$domainID);
+        } catch (KerioApiException $error) {
+            logModuleCall(
+                'kerioEmail',
+                __FUNCTION__,
+                $error,
+                'Debug Error',
+                $error->getMessage()
+            );
+            return ['error' => $error->getMessage()];
+        }
+        $api->logout();
+
+        logModuleCall(
+            'kerioEmail',
+            __FUNCTION__,
+            $users,
+            'Debug Error',
+            $domainID
+        );
+
         $lang = di('lang');
         $this->availableValues['status'] = [
             Kerio::ACC_STATUS_ACTIVE        => $lang->absoluteT('kerio','account','status','active'),
-            Kerio::ACC_STATUS_LOCKED        => $lang->absoluteT('kerio','account','status','locked'),
-            Kerio::ACC_STATUS_MAINTENANCE   => $lang->absoluteT('kerio','account','status','maintenance'),
             Kerio::ACC_STATUS_CLOSED        => $lang->absoluteT('kerio','account','status','closed'),
-            Kerio::ACC_STATUS_LOCKOUT       => $lang->absoluteT('kerio','account','status','lockout'),
-            Kerio::ACC_STATUS_PENDING       => $lang->absoluteT('kerio','account','status','pending')
         ];
 
         $this->availableValues['type'] = [
@@ -64,26 +97,11 @@ class RessourceDataProvider extends BaseDataProvider
         $hid = $this->request->get('id');
 
         $fieldToProtection = [
-            'display_name',
+            'name',
             'status',
             'type',
-            'capacity',
-            'description',
-            'notes',
-            'contact',
-            'site',
-            'contact_mail',
-            'contact_phone',
-            'street',
-            'building',
-            'floor',
-            'room',
-            'post_code',
-            'town',
-            'state',
-            'county',
-            'auto_accept',
-            'auto_busy'
+            'manager',
+            'description'
         ];
 
         foreach ($this->formData as $field => &$value)
@@ -97,38 +115,6 @@ class RessourceDataProvider extends BaseDataProvider
         $productManager = new ProductManager();
         $productManager->loadByHostingId($hid);
 
-        /**
-         *
-         * get soap create domain  service
-         */
-        $service =(new KerioManager())
-            ->getApiByHosting($hid)
-            ->soap
-            ->service()
-            ->createRessource();
-        /**
-         *
-         * set product manager & form data to service
-         */
-        $service
-            ->setProductManager($productManager)
-            ->setFormData($this->formData);
-
-        /**
-         *
-         * run service
-         */
-        $result = $service->run();
-
-        /**
-         *
-         * return success or error response
-         */
-        if(!$result)
-        {
-            return (new HtmlDataJsonResponse())->setMessageAndTranslate($service->getError())->setStatusError();
-        }
-
         return (new HtmlDataJsonResponse())->setMessageAndTranslate('ressourceHasBeenAdded')->setStatusSuccess();
 
     }
@@ -152,29 +138,12 @@ class RessourceDataProvider extends BaseDataProvider
         $productManager = new ProductManager();
         $productManager->loadByHostingId($hid);
 
-        /**
-         *
-         * get soap create domain  service
-         */
-        $service =(new KerioManager())
-            ->getApiByHosting($hid)
-            ->soap
-            ->service()
-            ->updateRessourceStatus()
-            ->setProductManager($productManager)
-        ;
-        /**
-         *
-         * set product manager & form data to service
-         */
-
         /**
          * run service for each id
          */
         foreach($this->request->get('massActions') as $id)
         {
-            $service->setFormData(['status' => $this->formData['status'], 'id' => $id]);
-            $result = $service->run();
+
         }
 
         /**

+ 1 - 1
app/UI/Client/Ressource/Sections/GeneralSection.php

@@ -45,7 +45,7 @@ class GeneralSection extends FreeFieldsSection
 
         $email = new InputGroup('usernameGroup');
 
-        $email->addTextField('username', false, true);
+        $email->addTextField('name', false, true);
         $email->addInputAddon('emailSign', false, '@');
         $email->addInputComponent((new InputGroupElements\Text('domain'))->addHtmlAttribute('readonly','true'));
         $this->addSection($email);