addColumn((new Column('email')) ->setOrderable(DataProvider::SORT_ASC) ->setSearchable(true, Column::TYPE_STRING)) ->addColumn((new Column('name')) ->setOrderable() ->setSearchable(true)) ->addColumn((new Column('description')) ->setOrderable() ->setSearchable(true)); } public function initContent() { $this->addMassActionButton(new MassDeleteListButton()); $this->addButton(new AddListButton()); $this->addActionButton(new EditListButton()); $this->addActionButton(new DeleteListButton()); } public function loadData() { /** * load hosting */ $hosting = Hosting::where('id', $this->getRequestValue('id'))->first(); $fields = array( "id", "name", "description"); $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']; } } try { $lists = $api->getMailingLists($fields,$this->maildomainID); } catch (KerioApiException $error) { logModuleCall( 'kerioEmail', __FUNCTION__, $error, 'Debug Error', $error->getMessage() ); return ['error' => $error->getMessage()]; } $api->logout(); logModuleCall( 'kerioEmail', __FUNCTION__, $lists, 'Debug Error', $this->maildomain ); $data = []; foreach($lists as $list) { /* @var $list DistributionList */ $tmp = [ 'id' => $list['id'], 'email' => $list['name'] . '@' . $this->maildomain, 'description' => $list['description'] ]; $data[] = $tmp; } $dataProv = new ArrayDataProvider(); $dataProv->setDefaultSorting('id', 'ASC')->setData($data); $this->setDataProvider($dataProv); } }