DeleteListDataProvider.php 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  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. logModuleCall(
  60. 'kerioEmail',
  61. __FUNCTION__,
  62. $this->formData,
  63. 'Debug del ML',
  64. $result
  65. );
  66. return (new HtmlDataJsonResponse())->setMessageAndTranslate('distributionListHasBeenDeleted')->setStatusSuccess();
  67. }
  68. public function massDelete()
  69. {
  70. /**
  71. * hosting id
  72. */
  73. $hid = $this->request->get('id');
  74. /**
  75. *
  76. */
  77. foreach($this->request->get('massActions') as $id)
  78. {
  79. logModuleCall(
  80. 'kerioEmail',
  81. __FUNCTION__,
  82. $id,
  83. 'Debug add ML',
  84. $hid
  85. );
  86. }
  87. return (new HtmlDataJsonResponse())->setMessageAndTranslate('massDistributionListHasBeenDeleted')->setStatusSuccess();
  88. }
  89. }