getRequestValue('id'); /** * hosting model */ $hosting = Hosting::where('id', $hid)->first(); /** * hosting domain */ $this->data['domain'] = $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" ); $accounts = $api->getUsers($fields,$this->maildomainID); $api->logout(); logModuleCall( 'kerioEmail', __FUNCTION__, $accounts, 'Debug Aliases', $hosting->domain ); /** * available accounts */ foreach($accounts as $account) { $this->availableValues['mailbox'][$account['id']] = $account['loginName'] . '@' . $this->maildomain; } } public function create() { /** * hosting id */ $hid = $this->request->get('id'); /** * product manager allow to check product settings */ $productManager = new ProductManager(); $productManager->loadByHostingId($hid); /** * * get soap create alias service * set service configuration */ $service =(new KerioManager()) ->getApiByHosting($hid) ->soap ->service() ->createAccountAlias() ->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('emailAliasHasBeenCreated')->setStatusSuccess(); } public function update() { // TODO: Implement update() method. } }