ChangeUserRole.php 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. <?php
  2. /**********************************************************************
  3. * ProxmoxVPS developed. (26.03.19)
  4. * *
  5. *
  6. * CREATED BY MODULESGARDEN -> http://modulesgarden.com
  7. * CONTACT -> contact@modulesgarden.com
  8. *
  9. *
  10. * This software is furnished under a license and may be used and copied
  11. * only in accordance with the terms of such license and with the
  12. * inclusion of the above copyright notice. This software or any other
  13. * copies thereof may not be provided or otherwise made available to any
  14. * other person. No title to and ownership of the software is hereby
  15. * transferred.
  16. *
  17. *
  18. **********************************************************************/
  19. namespace ModulesGarden\Servers\ProxmoxVps\App\Http\Actions;
  20. use ModulesGarden\ProxmoxAddon\App\Models\ModuleSettings;
  21. use ModulesGarden\ProxmoxAddon\App\Services\ApiService;
  22. use ModulesGarden\ProxmoxAddon\App\Services\Vps\ProductService;
  23. use ModulesGarden\ProxmoxAddon\App\Services\Vps\UserService;
  24. use ModulesGarden\Servers\ProxmoxVps\App\Helpers\AppParams;
  25. use ModulesGarden\Servers\ProxmoxVps\App\Helpers\ProxmoxAddonValidator;
  26. use ModulesGarden\Servers\ProxmoxVps\App\UI\Validators\Validator;
  27. use ModulesGarden\Servers\ProxmoxVps\Core\App\Controllers\Instances\AddonController;
  28. use ModulesGarden\Servers\ProxmoxVps\Core\UI\Traits\WhmcsParams;
  29. class ChangeUserRole extends AddonController
  30. {
  31. use WhmcsParams;
  32. use ProductService;
  33. use UserService;
  34. use ApiService;
  35. public function execute($params = null)
  36. {
  37. if(!ProxmoxAddonValidator::isInstalled()){
  38. return ProxmoxAddonValidator::failAsString();
  39. }
  40. (new AppParams())->initFromWhmcsParams();
  41. try
  42. {
  43. //Create User
  44. if (!$this->isUser())
  45. {
  46. $this->userCreate();
  47. }
  48. $this->userUpdate();
  49. return "success";
  50. }
  51. catch (\Exception $ex)
  52. {
  53. if (ModuleSettings::isDebug())
  54. {
  55. logModuleCall(
  56. 'ProxmoxVps',
  57. __CLASS__,
  58. [],
  59. null,
  60. $ex->getMessage() . " " . $ex->getTraceAsString()
  61. );
  62. }
  63. return $ex->getMessage();
  64. }
  65. }
  66. }