DeleteEmailAliasDataProvider.php 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  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. $this->data['id'] = $params['accId'];
  23. $this->data['alias'] = $params['alias'];
  24. }
  25. public function update()
  26. {
  27. // TODO: Implement update() method.
  28. }
  29. public function delete()
  30. {
  31. /**
  32. * hosting id
  33. */
  34. $hid = $this->request->get('id');
  35. /**
  36. * product manager allow to check product settings
  37. */
  38. $productManager = new ProductManager();
  39. $productManager->loadByHostingId($hid);
  40. logModuleCall(
  41. 'kerioEmail',
  42. __FUNCTION__,
  43. $this->actionElementId,
  44. 'Debug Error',
  45. $this
  46. );
  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. }