ChangeUserRole.php 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  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\ProxmoxCloudVps\App\Http\Actions;
  20. use ModulesGarden\ProxmoxAddon\App\Models\ModuleSettings;
  21. use ModulesGarden\ProxmoxAddon\App\Services\ApiService;
  22. use ModulesGarden\ProxmoxAddon\App\Services\Cloud\ProductService;
  23. use ModulesGarden\ProxmoxAddon\App\Services\Cloud\UserService;
  24. use ModulesGarden\ProxmoxAddon\App\Services\CloudService;
  25. use ModulesGarden\Servers\ProxmoxCloudVps\App\Helpers\AppParams;
  26. use ModulesGarden\Servers\ProxmoxCloudVps\App\Helpers\ProxmoxAddonValidator;
  27. use ModulesGarden\Servers\ProxmoxCloudVps\App\UI\Validators\Validator;
  28. use ModulesGarden\Servers\ProxmoxCloudVps\Core\App\Controllers\Instances\AddonController;
  29. use ModulesGarden\Servers\ProxmoxCloudVps\Core\UI\Traits\WhmcsParams;
  30. class ChangeUserRole extends AddonController
  31. {
  32. use WhmcsParams;
  33. use ProductService;
  34. use UserService;
  35. use ApiService;
  36. public function execute($params = null)
  37. {
  38. if(!ProxmoxAddonValidator::isInstalled()){
  39. return ProxmoxAddonValidator::failAsString();
  40. }
  41. try
  42. {
  43. (new AppParams())->initFromParams($params);
  44. //Create User
  45. if (!$this->isUser())
  46. {
  47. $this->userCreate();
  48. }
  49. $this->userUpdate();
  50. $cloud = new CloudService();
  51. $vms = $cloud->getVmids();
  52. $this->userUpdatePermission($vms);
  53. return "success";
  54. }
  55. catch (\Exception $ex)
  56. {
  57. if (ModuleSettings::isDebug())
  58. {
  59. logModuleCall(
  60. 'ProxmoxCloudVps',
  61. __CLASS__,
  62. [],
  63. null,
  64. $ex->getMessage() . " " . $ex->getTraceAsString()
  65. );
  66. }
  67. return $ex->getMessage();
  68. }
  69. }
  70. }