DeleteEmailAliasDataProvider.php 2.5 KB

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