getRequestValue('id'))->first(); $this->data['domain'] = $hosting->domain; /** * load api */ $accounts = (new KerioManager()) ->getApiByServer($hosting->server) ->soap ->repository() ->accounts ->getByDomainName($hosting->domain); /** * * load lang */ $lang = di('lang'); /** * subscription requests */ $this->availableValues['subscriptionRequest'] = [ Kerio::STATUS_ACCEPT => $lang->absoluteT('Automatically accept'), Kerio::STATUS_APPROVAL => $lang->absoluteT('Require list owner 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 list owner approval'), Kerio::STATUS_REJECT => $lang->absoluteT('Automatically reject') ]; /** * */ foreach($accounts as $account) { $this->availableValues['memberList'][$account->getName()] = $account->getName(); } if($this->formData) { $this->loadReloadedData(); } } /** * */ public function loadReloadedData() { foreach($this->formData as $key => $value) { $this->data[$key] = $value; } } public function create() { /** * * provided aliases */ $customEmails = explode(',',$this->formData['emailAliases']); $this->formData['emailAliases'] = []; foreach($customEmails as $email) { if ($email !== '') { $this->formData['emailAliases'][] = $email; } } /** * provided owners */ $owners = explode(',',$this->formData['owners']); $this->formData['owners'] = []; foreach($owners as $email) { if ($email !== '') { $this->formData['owners'][] = $email; } } /** * custom members */ $customMembers = explode(',',$this->formData['customMember']); 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'); /** * load kerio manager by hosting id */ $service = (new KerioManager()) ->getApiByHosting($hid) ->soap ->service() ->createDistributionList() ->setFormData($this->formData) ; /** * load product configuration */ $productManager = new ProductManager(); $productManager->loadByHostingId($hid); $service->setProductManager($productManager); $result= $service->run(); if(!$result) { return (new HtmlDataJsonResponse())->setMessageAndTranslate($service->getError())->setStatusError(); } return (new HtmlDataJsonResponse())->setMessageAndTranslate('distributionListHasBeenAdded')->setStatusSuccess(); } public function update() { // TODO: Implement update() method. } }