getRequestValue('id'))->first(); $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"); try { $accounts = $api->getUsers($fields,$this->maildomainID); } catch (KerioApiException $error) { logModuleCall( 'kerioEmail', __FUNCTION__, $error, 'Debug Error', $error->getMessage() ); return ['error' => $error->getMessage()]; } $api->logout(); /** * * load lang */ $lang = di('lang'); $this->availableValues['moderator']['none'] = $lang->absoluteT('none'); foreach($accounts as $account) { $this->availableValues['memberList'][$account['loginName']] = $account['loginName'] . '@' . $this->maildomain; $this->availableValues['moderator'][$account['loginName']] = $account['loginName'] . '@' . $this->maildomain; } /** * subscription requests */ $this->availableValues['subscriptionRequest'] = [ Kerio::STATUS_ACCEPT => $lang->absoluteT('Automatically accept'), Kerio::STATUS_APPROVAL => $lang->absoluteT('Require moderator approval'), Kerio::STATUS_REJECT => $lang->absoluteT('Automatically reject') ]; /** * unsubscription requests */ $this->availableValues['unsubscriptionRequest'] = [ Kerio::STATUS_ACCEPT => $lang->absoluteT('Automatically accept'), Kerio::STATUS_APPROVAL => $lang->absoluteT('Require moderator approval'), Kerio::STATUS_REJECT => $lang->absoluteT('Automatically reject') ]; $this->availableValues['lang'] = [ 'de' => $lang->absoluteT('german'), 'en' => $lang->absoluteT('english') ]; if($this->formData) { $this->loadReloadedData(); } } /** * */ public function loadReloadedData() { foreach($this->formData as $key => $value) { $this->data[$key] = $value; } } public function create() { $myFormData = $this->formData; /** * custom members */ $customMembers = explode(',',$this->formData['customMember']); foreach($this->formData['memberList'] as $member) { $memberList[] = $member . '@' . $this->getWhmcsParamByKey('domain'); } $this->formData['memberList'] = $memberList; foreach($customMembers as $customMember) { if($customMember !== '' && !in_array($customMember, $this->formData['memberList'])) { $this->formData['memberList'][] = $customMember; } } /** * display name */ $this->formData['displayName'] = htmlentities($this->formData['displayName']); /** * reply display name */ $this->formData['replyDisplayName'] = htmlentities($this->formData['replyDisplayName']); /** * hosting id */ $hid = $this->request->get('id'); logModuleCall( 'kerioEmail', __FUNCTION__, $myFormData, 'Debug add ML', $this->formData ); return (new HtmlDataJsonResponse())->setMessageAndTranslate('distributionListHasBeenAdded')->setStatusSuccess(); } public function update() { // TODO: Implement update() method. } }