AclService.php 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. <?php
  2. namespace ModulesGarden\ProxmoxAddon\App\Services\Cloud;
  3. use ModulesGarden\ProxmoxAddon\Core\UI\Traits\WhmcsParams;
  4. use function ModulesGarden\Servers\ProxmoxCloudVps\Core\Helper\sl;
  5. class AclService
  6. {
  7. use ProductService;
  8. use WhmcsParams;
  9. public function backup()
  10. {
  11. if (!$this->configuration()->isPermissionBackup() && !$this->configuration()->isPermissionBackupJob())
  12. {
  13. throw new \Exception(sl("lang")->tr("No access to backup"));
  14. }
  15. }
  16. public function backupJob()
  17. {
  18. if (!$this->configuration()->isPermissionBackupJob())
  19. {
  20. throw new \Exception(sl("lang")->tr("No access to backup job"));
  21. }
  22. }
  23. public function novnc()
  24. {
  25. if (!$this->configuration()->isPermissionNovnc())
  26. {
  27. throw new \Exception(sl("lang")->tr("No access to noVNC console"));
  28. }
  29. }
  30. public function xtermjs()
  31. {
  32. if (!$this->configuration()->isPermissionXtermjs())
  33. {
  34. throw new \Exception(sl("lang")->tr("No access to Xterm.js console"));
  35. }
  36. }
  37. public function spice()
  38. {
  39. if (!$this->configuration()->isPermissionSpice())
  40. {
  41. throw new \Exception(sl("lang")->tr("No access to spice console"));
  42. }
  43. }
  44. public function disk()
  45. {
  46. if (!$this->configuration()->isPermissionDisk())
  47. {
  48. throw new \Exception(sl("lang")->tr("No access to disk"));
  49. }
  50. }
  51. public function firewall()
  52. {
  53. if (!$this->configuration()->isPermissionFirewall())
  54. {
  55. throw new \Exception(sl("lang")->tr("No access to firewall"));
  56. }
  57. }
  58. public function firewallOption()
  59. {
  60. if (!$this->configuration()->isPermissionFirewallOption())
  61. {
  62. throw new \Exception(sl("lang")->tr("No access to firewall option"));
  63. }
  64. }
  65. public function graph()
  66. {
  67. if (!$this->configuration()->isPermissionGraph())
  68. {
  69. throw new \Exception(sl("lang")->tr("No access to graph"));
  70. }
  71. }
  72. public function network()
  73. {
  74. if (!$this->configuration()->isPermissionNetwork())
  75. {
  76. throw new \Exception(sl("lang")->tr("No access to network"));
  77. }
  78. }
  79. public function reinstall()
  80. {
  81. if (!$this->configuration()->isPermissionReinstall())
  82. {
  83. throw new \Exception(sl("lang")->tr("No access to reinstall"));
  84. }
  85. }
  86. public function snapshot()
  87. {
  88. if (!$this->configuration()->isPermissionSnapshot())
  89. {
  90. throw new \Exception(sl("lang")->tr("No access to snapshot"));
  91. }
  92. }
  93. public function taskHistory()
  94. {
  95. if (!$this->configuration()->isPermissionTaskHistory())
  96. {
  97. throw new \Exception(sl("lang")->tr("No access to task history"));
  98. }
  99. }
  100. public function additionalDiskBackup()
  101. {
  102. if (!$this->configuration()->isPermissionAdditionalDiskBackup())
  103. {
  104. throw new \Exception(sl("lang")->tr("No access to additional disk backup"));
  105. }
  106. }
  107. public function hasFirewallOption($option)
  108. {
  109. return in_array( $option, $this->configuration()->getPermissionFirewalOptions());
  110. }
  111. public function customTemplate()
  112. {
  113. if (!$this->configuration()->isPermissionCustomTemplates())
  114. {
  115. throw new \Exception(sl("lang")->tr("No access to Custom Templates"));
  116. }
  117. }
  118. }