"id", "comparator" => "Eq", "value" => $this->actionElementId ); $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 { $ressource = $api->getResources($fields,$domainID,$cond); } catch (KerioApiException $error) { logModuleCall( 'kerioEmail', __FUNCTION__, $error, 'Debug Error', $error->getMessage() ); return ['error' => $error->getMessage()]; } $api->logout(); $lang = di('lang'); $this->data['id'] = $ressource[0]['id']; $this->data['name'] = $ressource[0]['name']; $this->data['domain'] = $this->getWhmcsParamByKey('domain'); $this->data['status'] = $ressource[0]['isEnabled'] == true ? Kerio::ACC_STATUS_ACTIVE : Kerio::ACC_STATUS_CLOSED; $this->data['type'] = $ressource[0]['type'] === 'Room' ? di('lang')->absoluteT('kerio','ressource','type','location') : di('lang')->absoluteT('kerio','ressource','type','equipment');; $this->data['description'] = $ressource[0]['description']; $this->data['manager'] = $ressource[0]['magager']; $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') ]; } /** * @return HtmlDataJsonResponse */ public function update() { $fieldToProtection = [ 'name', 'status', 'type', 'description', 'managert' ]; logModuleCall( 'kerioEmail', __FUNCTION__, $this->formData, 'Debug Error', $this->actionElementId ); foreach ($this->formData as $field => &$value) { $value = in_array($field, $fieldToProtection) ? htmlentities($value) : $value; } return (new HtmlDataJsonResponse())->setMessageAndTranslate('ressourceHasBeenUpdated')->setStatusSuccess(); } /** * @return HtmlDataJsonResponse */ public function updateStatus() { /** * hosting id */ $hid = $this->request->get('id'); /** * product manager allow to check product settings */ $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 */ $service->setFormData($this->formData); $result = $service->run(); if(!$result) { return (new HtmlDataJsonResponse())->setMessageAndTranslate($service->getError())->setStatusError(); } /** * return success */ return (new HtmlDataJsonResponse())->setMessageAndTranslate('ressourceStatusHasBeenUpdated')->setStatusSuccess(); } /** * @return HtmlDataJsonResponse */ public function changePassword() { /** * hosting id */ $hid = $this->request->get('id'); /** * product manager allow to check product settings */ $productManager = new ProductManager(); $productManager->loadByHostingId($hid); /** * * get soap create domain service */ $service =(new KerioManager()) ->getApiByHosting($hid) ->soap ->service() ->updateRessourcePassword() ->setProductManager($productManager) ; /** * * set product manager & form data to service */ /** * run service for each id */ $service->setFormData($this->formData); $result = $service->run(); if(!$result) { return (new HtmlDataJsonResponse())->setMessageAndTranslate($service->getError())->setStatusError(); } return (new HtmlDataJsonResponse())->setMessageAndTranslate('passwordChangedSuccessfully')->setStatusSuccess(); } }