'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() { $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()]; } logModuleCall( 'kerioEmail', __FUNCTION__, $domains, 'Debug Settings', 'Debug Settings' ); foreach($domains as $domain) { if(($domain['name']) === $this->getWhmcsParamByKey('domain')){ $aliasList = $domain['aliasList']; } } logModuleCall( 'kerioEmail', __FUNCTION__, $error, 'Debug Error', $error->getMessage() ); $api->logout(); /** * format model to array */ $data = []; $dataProv = new ArrayDataProvider(); $dataProv->setDefaultSorting('setting', 'ASC')->setData($data); $this->setDataProvider($dataProv); } }