ChangePackage.php 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. <?php
  2. namespace ThurData\Servers\KerioEmail\App\Http\Actions;
  3. use ThurData\Servers\KerioEmail\App\Enums\Response;
  4. use ThurData\Servers\KerioEmail\App\Helpers\KerioManager;
  5. use ThurData\Servers\KerioEmail\App\Libs\Product\ProductManager;
  6. use ThurData\Servers\KerioEmail\App\Traits\ExtensionsCheckerTrait;
  7. use ThurData\Servers\KerioEmail\Core\App\Controllers\Instances\AddonController;
  8. use ThurData\Servers\KerioEmail\App\Models\ProductConfiguration;
  9. /**
  10. *
  11. * Created by PhpStorm.
  12. * User: Tomasz Bielecki ( tomasz.bi@thurdata.com )
  13. * Date: 09.09.19
  14. * Time: 15:15
  15. * Class ChangePackage
  16. */
  17. class ChangePackage extends AddonController
  18. {
  19. use ExtensionsCheckerTrait;
  20. /**
  21. * @param null $params
  22. * @return string|void
  23. */
  24. public function execute($params = null)
  25. {
  26. try{
  27. /**
  28. * check if extensions are installed
  29. */
  30. $this->checkExtensionOrThrowError();
  31. /**
  32. * run kerio service
  33. */
  34. $result = $this->kerioRunService($params);
  35. return $result;
  36. }catch (\Exception $ex)
  37. {
  38. /**
  39. * return some crit error
  40. */
  41. return $ex->getMessage();
  42. }
  43. }
  44. /**
  45. * @param null $params
  46. * @return string
  47. */
  48. protected function kerioRunService($params = null)
  49. {
  50. $productManager = new ProductManager();
  51. $productManager->loadById($params['pid']);
  52. $service = (new KerioManager())
  53. ->getApiByServer($params['serverid'])
  54. ->soap
  55. ->service()
  56. ->changePackages($productManager->get('cos_name'))
  57. ->setProductManager($productManager)
  58. ->setFormData($params)
  59. ;
  60. $result = $service->run();
  61. // $configuration = ProductConfiguration::where('product_id', $params['pid'])->get();
  62. // foreach($configuration as $cModel)
  63. // {
  64. // $config[$cModel->setting] = $cModel->value;
  65. // }
  66. //
  67. // $new_account_size = $config['acc_size'];
  68. //
  69. // //todo mailboxes from API
  70. //
  71. // $repository = (new KerioManager())
  72. // ->getApiByServer($params['serverid'])
  73. // ->soap
  74. // ->repository();
  75. //
  76. // $mailboxesApi = $repository->accounts->getByDomainName($params['domain']);
  77. //
  78. // if ($config['coss_name'] == "customMGkerio")
  79. // {
  80. // $attr = $config;
  81. // foreach ($attr as $key => &$item)
  82. // {
  83. // if (preg_match('/kerio.+/', $key))
  84. // {
  85. // $item = $item == "on" ? "TRUE" : "FALSE";
  86. // }
  87. // else
  88. // {
  89. // unset($attr[$key]);
  90. // }
  91. // }
  92. //
  93. // $attr['kerioMailQuota'] = $new_account_size * 1048576;
  94. // }elseif ($config['coss_name'] == 'cosQuota')
  95. // {
  96. // //todo
  97. // }else{
  98. //
  99. // }
  100. //
  101. // foreach($mailboxesApi as $key => $value)
  102. // {
  103. // //todo
  104. // }
  105. return Response::SUCCESS;
  106. }
  107. }