DeleteDomainAliasProvider.php 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. <?php
  2. namespace ThurData\Servers\KerioEmail\App\UI\Client\DomainAlias\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\Delete\DeleteDomainAlias;
  6. use ThurData\Servers\KerioEmail\Core\UI\ResponseTemplates\HtmlDataJsonResponse;
  7. use ThurData\Servers\KerioEmail\Core\UI\Widget\Forms\DataProviders\BaseDataProvider;
  8. use ThurData\Servers\KerioEmail\Api\KerioWhmcs;
  9. /**
  10. *
  11. * Created by PhpStorm.
  12. * User: ThurData
  13. * Date: 02.10.19
  14. * Time: 14:41
  15. * Class DeleteDomainAliasProvider
  16. */
  17. class DeleteDomainAliasProvider extends BaseDataProvider
  18. {
  19. /**
  20. *
  21. */
  22. public function read()
  23. {
  24. $this->data['id'] = $this->actionElementId;
  25. }
  26. /**
  27. *
  28. */
  29. public function update()
  30. {
  31. // TODO: Implement update() method.
  32. }
  33. /**
  34. * @return HtmlDataJsonResponse|void
  35. */
  36. public function delete()
  37. {
  38. /**
  39. * hosting id
  40. */
  41. $hid = $this->request->get('id');
  42. logModuleCall(
  43. 'kerioEmail',
  44. __FUNCTION__,
  45. $this->formData,
  46. 'Debug Error',
  47. $this
  48. );
  49. return (new HtmlDataJsonResponse())->setMessageAndTranslate('domainAliasHasBeenDeleted')->setStatusSuccess();
  50. }
  51. public function massDelete()
  52. {
  53. /**
  54. * hosting id
  55. */
  56. $hid = $this->request->get('id');
  57. /**
  58. * load product configuration
  59. */
  60. $productManager = new ProductManager();
  61. $productManager->loadByHostingId($hid);
  62. /**
  63. * load kerio manager by hosting id
  64. */
  65. $service = (new KerioManager())
  66. ->getApiByHosting($hid)
  67. ->soap
  68. ->service()
  69. ->deleteDomainAlias();
  70. /**
  71. *
  72. */
  73. foreach($this->request->get('massActions') as $id)
  74. {
  75. $service->setFormData(['id' => $id]);
  76. $result = $service->run();
  77. }
  78. return (new HtmlDataJsonResponse())
  79. ->setMessageAndTranslate('massDomainAliasHasBeenDeleted')
  80. ->setStatusSuccess();
  81. }
  82. }