productManager) { $this->setError('Product Manager Not Found'); return false; } /** * domain name */ if(!$this->formData['domain']) { $this->setError('Domain name can not be found.'); return false; } /** * */ return parent::isValid(); } /** * @return mixed */ protected function getRessources() { $ressources = $this->api->repository()->ressources->getRessources($this->formData['domain']); return $ressources; } /** * @return Ressource */ protected function getModel() { /** * create new ressource in kerio */ $ressource = new Ressource(); $ressource->setName($this->formData['username'].'@'.$this->formData['domain']); $ressource->setPassword(html_entity_decode($this->formData['password']), ENT_QUOTES); /** * set ressource attributes */ $ressource->setAttr(Ressource::ATTR_STATUS, $this->formData['status']); $ressource->setAttr(Ressource::ATTR_TYPE, $this->formData['type']); $ressource->setAttr(Ressource::ATTR_DISPLAY_NAME, $this->formData['display_name']); $ressource->setAttr(Ressource::ATTR_DESC, $this->formData['description']); $ressource->setAttr(Ressource::ATTR_NOTE, $this->formData['notes']); $ressource->setAttr(Ressource::ATTR_CONT, $this->formData['contact']); $ressource->setAttr(Ressource::ATTR_CONT_EMAIL, $this->formData['contact_mail']); $ressource->setAttr(Ressource::ATTR_CONT_PHONE, $this->formData['contact_phone']); $ressource->setAttr(Ressource::ATTR_SITE, $this->formData['site']); $ressource->setAttr(Ressource::ATTR_BUILDING, $this->formData['building']); $ressource->setAttr(Ressource::ATTR_FLOOR, $this->formData['floor']); $ressource->setAttr(Ressource::ATTR_ROOM, $this->formData['room']); $ressource->setAttr(Ressource::ATTR_CAPACITY, $this->formData['capacity']); $ressource->setAttr(Ressource::ATTR_STREET, $this->formData['street']); $ressource->setAttr(Ressource::ATTR_TOWN, $this->formData['town']); $ressource->setAttr(Ressource::ATTR_POSTAL_CODE, $this->formData['post_code']); $ressource->setAttr(Ressource::ATTR_COUNTY, $this->formData['county']); $ressource->setAttr(Ressource::ATTR_STATE, $this->formData['state']); $ressource->setAttr(Ressource::ATTR_AUTO, $this->formData['auto_accept'] == 'on' ? 'TRUE' : 'FALSE' ); $ressource->setAttr(Ressource::ATTR_BUSY, $this->formData['auto_busy'] == 'on' ? 'TRUE' : 'FALSE' ); foreach($this->productManager->getKerioConfiguration() as $key => $value) { $value = $value === ProductParams::SWITCHER_ENABLED ? Kerio::ATTR_ENABLED : Kerio::ATTR_DISABLED; $ressource->setAttr($key, $value); } return $ressource; } /** * @return bool|mixed|Ressource|void */ protected function process() { /** * */ $model = $this->getModel(); /** * create ressource in KERIO */ $result = $this->api->ressource->create($model); /** * problem with create ressource */ if(!$result) { $this->setError($this->api->ressource->getLastResult()->getLastErrorCode()); return false; } return $result; } }