'success', 'inactive' => 'default', 'default' => 'default' ]; protected $id = 'Setting'; protected $name = 'Setting'; protected $title = null; /** * load columns */ protected function loadHtml() { $this ->addColumn((new Column('domain')) ->setOrderable(DataProvider::SORT_ASC) ->setSearchable(true, Column::TYPE_STRING)) ->addColumn((new Column('active(mx)')) ->setOrderable() ->setSearchable(true, Column::TYPE_STRING)) ->addColumn((new Column('spf')) ->setOrderable() ->setSearchable(true, Column::TYPE_STRING)) ->addColumn((new Column('dmarc')) ->setOrderable() ->setSearchable(true, Column::TYPE_STRING)) ->addColumn((new Column('dkim')) ->setOrderable() ->setSearchable(true)); } /** * @param $key * @param $row * @return mixed */ public function replaceFieldStatus($key, $row) { $status = self::STATUS_LABEL[$row[$key]] ? self::STATUS_LABEL[$row[$key]] : self::STATUS_LABEL['default']; $label = di('lang')->absoluteT('kerio','account','status',$row[$key]); $field = new EnabledField(); $field->setRawType($status); $field->setRawTitle($label); return $field->getHtml(); } /** * @param $key * @param $row * @return mixed */ public function replaceFieldLast_login($key, $row) { return $row[$key] ? $row[$key] : '-'; } /** * @param $key * @param $row * @return mixed */ public function replaceFieldType($key, $row) { return $row[$key] == 'Room' ? di('lang')->absoluteT('kerio','setting','type','location') : di('lang')->absoluteT('kerio','setting','type','equipment'); } /** * load buttons */ public function initContent() { $this->addActionButton(new EditSettingButton()); } /** * load data */ public function loadData() { $maildomain = $this->getWhmcsParamByKey('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','aliasList']); } catch (KerioApiException $error) { logModuleCall( 'kerioEmail', __FUNCTION__, $error, 'Debug Error', $error->getMessage() ); return ['error' => $error->getMessage()]; } $api->logout(); logModuleCall( 'kerioEmail', __FUNCTION__, $domains, 'Debug Settings', $this->params ); foreach($domains as $domain) { if(($domain['name']) === $maildomain){ $aliasList = $domain['aliasList']; } } $dkimSet = $api->getDkimDnsRecord($maildomain); $dkimArray = explode(PHP_EOL,$dkimSet['detail']); $dkimValue = explode(":",$dkimArray[1]); $this->domainKey = ltrim($dkimValue[1]); $dkimName = explode(":",$dkimArray[0]); $this->dkimName = ltrim($dkimName[1]); $api->logout(); // get settings from product configuration $productManager = new ProductManager(); $productManager->loadById($this->params['pid']); $this->spfConfig = $productManager->get('spf_string'); $this->dmarcConfig = $productManager->get('dmarc_string'); /** * format model to array */ $data = []; $dataProv = new ArrayDataProvider(); $dataProv->setDefaultSorting('setting', 'ASC')->setData($data); $this->setDataProvider($dataProv); } }