DeleteListDataProvider.php 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. <?php
  2. namespace ThurData\Servers\KerioEmail\App\UI\Client\DistributionList\Providers;
  3. use ThurData\Servers\KerioEmail\App\Helpers\KerioManager;
  4. use ThurData\Servers\KerioEmail\App\Libs\Product\ProductManager;
  5. use ThurData\Servers\KerioEmail\App\Libs\Kerio\Components\Api\Soap\Services\Create\CreateDistributionList;
  6. use ThurData\Servers\KerioEmail\App\Libs\Kerio\Components\Api\Soap\Services\Delete\DeleteDistributionList;
  7. use ThurData\Servers\KerioEmail\Core\UI\ResponseTemplates\HtmlDataJsonResponse;
  8. use ThurData\Servers\KerioEmail\Core\UI\Widget\Forms\DataProviders\BaseDataProvider;
  9. use ThurData\Servers\KerioEmail\Api\KerioWhmcs;
  10. /**
  11. *
  12. * Created by PhpStorm.
  13. * User: ThurData
  14. * Date: 02.10.19
  15. * Time: 08:21
  16. * Class DeleteListDataProvider
  17. */
  18. class DeleteListDataProvider extends BaseDataProvider
  19. {
  20. public function read()
  21. {
  22. $this->data['id'] = $this->actionElementId;
  23. }
  24. public function update()
  25. {
  26. // TODO: Implement update() method.
  27. }
  28. public function delete()
  29. {
  30. /**
  31. * hosting id
  32. */
  33. $hid = $this->request->get('id');
  34. $api = new KerioWhmcs('whmcsKerioEmail', 'Thurdata', '1.0');
  35. try {
  36. $api->login($this->getWhmcsParamByKey('serverhostname'), $this->getWhmcsParamByKey('serverusername'), $this->getWhmcsParamByKey('serverpassword'));
  37. } catch (KerioApiException $error) {
  38. logModuleCall(
  39. 'kerioEmail',
  40. __FUNCTION__,
  41. $error,
  42. 'Debug Error',
  43. $error->getMessage()
  44. );
  45. return ['error' => $error->getMessage()];
  46. }
  47. try {
  48. $result = $api->deleteMailinglist($this->formData['id']);
  49. } catch (KerioApiException $error) {
  50. logModuleCall(
  51. 'kerioEmail',
  52. __FUNCTION__,
  53. $error,
  54. 'Debug Error',
  55. $error->getMessage()
  56. );
  57. return ['error' => $error->getMessage()];
  58. }
  59. return (new HtmlDataJsonResponse())->setMessageAndTranslate('distributionListHasBeenDeleted')->setStatusSuccess();
  60. }
  61. public function massDelete()
  62. {
  63. /**
  64. * hosting id
  65. */
  66. $hid = $this->request->get('id');
  67. /**
  68. *
  69. */
  70. foreach($this->request->get('massActions') as $id)
  71. {
  72. logModuleCall(
  73. 'kerioEmail',
  74. __FUNCTION__,
  75. $id,
  76. 'Debug add ML',
  77. $hid
  78. );
  79. }
  80. return (new HtmlDataJsonResponse())->setMessageAndTranslate('massDistributionListHasBeenDeleted')->setStatusSuccess();
  81. }
  82. }