|
|
@@ -15,6 +15,7 @@ use ThurData\Servers\KerioEmail\Core\UI\Widget\DataTable\Column;
|
|
|
use ThurData\Servers\KerioEmail\Core\UI\Widget\DataTable\DataProviders\DataProvider;
|
|
|
use ThurData\Servers\KerioEmail\Core\UI\Widget\DataTable\DataProviders\Providers\ArrayDataProvider;
|
|
|
use ThurData\Servers\KerioEmail\Core\UI\Widget\DataTable\DataTable;
|
|
|
+use ThurData\Servers\KerioEmail\Api\KerioWhmcs;
|
|
|
|
|
|
/**
|
|
|
*
|
|
|
@@ -39,36 +40,11 @@ class Lists extends DataTable implements ClientArea
|
|
|
->addColumn((new Column('name'))
|
|
|
->setOrderable()
|
|
|
->setSearchable(true))
|
|
|
- ->addColumn((new Column('status'))
|
|
|
+ ->addColumn((new Column('description'))
|
|
|
->setOrderable()
|
|
|
->setSearchable(true));
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- *
|
|
|
- * return status as html element
|
|
|
- * @param $key
|
|
|
- * @param $row
|
|
|
- * @return string
|
|
|
- */
|
|
|
- public function replaceFieldStatus($key, $row)
|
|
|
- {
|
|
|
- /**
|
|
|
- * check status
|
|
|
- */
|
|
|
- $enabled = $row[$key] === 'enabled' ? true : false;
|
|
|
-
|
|
|
- /**
|
|
|
- *
|
|
|
- * create enabled element
|
|
|
- */
|
|
|
- $field = new EnabledField();
|
|
|
- $field->setEnabled($enabled);
|
|
|
- $field->setRawTitle(di('lang')->absoluteT('kerio','account','status',$row[$key]));
|
|
|
-
|
|
|
- return $field->getHtml();
|
|
|
- }
|
|
|
-
|
|
|
public function initContent()
|
|
|
{
|
|
|
$this->addMassActionButton(new MassDeleteListButton());
|
|
|
@@ -83,29 +59,67 @@ class Lists extends DataTable implements ClientArea
|
|
|
* load hosting
|
|
|
*/
|
|
|
$hosting = Hosting::where('id', $this->getRequestValue('id'))->first();
|
|
|
+ $fields = array(
|
|
|
+ "id",
|
|
|
+ "name",
|
|
|
+ "description");
|
|
|
|
|
|
- /**
|
|
|
- * load api
|
|
|
- */
|
|
|
- $api = (new KerioManager())->getApiByServer($hosting->server);
|
|
|
+ $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();
|
|
|
|
|
|
- $repository = new Repository($api->soap);
|
|
|
- $lists = $repository->lists->getAllDistributionListsByDomain($hosting->domain);
|
|
|
+ logModuleCall(
|
|
|
+ 'kerioEmail',
|
|
|
+ __FUNCTION__,
|
|
|
+ $lists,
|
|
|
+ 'Debug Error',
|
|
|
+ $this->maildomain
|
|
|
+ );
|
|
|
|
|
|
$data = [];
|
|
|
- foreach($lists as $list)
|
|
|
- {
|
|
|
+// foreach($lists as $list)
|
|
|
+// {
|
|
|
/* @var $list DistributionList */
|
|
|
|
|
|
- $tmp = [
|
|
|
- 'id' => $list->getId(),
|
|
|
- 'email' => $list->getName(),
|
|
|
- 'name' => $list->getDataResourceA(DistributionList::ATTR_DISPLAY_NAME),
|
|
|
- 'status' => $list->getDataResourceA(DistributionList::ATTR_MAIL_STATUS)
|
|
|
- ];
|
|
|
+// $tmp = [
|
|
|
+// 'id' => $list->getId(),
|
|
|
+// 'email' => $list->getName(),
|
|
|
+// 'name' => $list->getDataResourceA(DistributionList::ATTR_DISPLAY_NAME),
|
|
|
+// 'status' => $list->getDataResourceA(DistributionList::ATTR_MAIL_STATUS)
|
|
|
+// ];
|
|
|
|
|
|
- $data[] = $tmp;
|
|
|
- }
|
|
|
+// $data[] = $tmp;
|
|
|
+// }
|
|
|
|
|
|
$dataProv = new ArrayDataProvider();
|
|
|
$dataProv->setDefaultSorting('id', 'ASC')->setData($data);
|