UrlService.php 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. <?php
  2. /* * ********************************************************************
  3. * ProxmoxVPS Product developed. (27.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\ProxmoxAddon\App\Services;
  20. use ModulesGarden\ProxmoxAddon\Core\UI\Traits\WhmcsParams;
  21. use function ModulesGarden\ProxmoxAddon\Core\Helper\isAdmin;
  22. class UrlService
  23. {
  24. use WhmcsParams;
  25. public function getUrl($controller = null, $action = null, array $params = [])
  26. {
  27. $url = 'clientarea.php?action=productdetails&id=' . $this->getWhmcsParamByKey('serviceid');
  28. if ($controller)
  29. {
  30. $params['modop'] = 'custom';
  31. $params['a'] = 'management';
  32. $params['mg-page'] = $controller;
  33. if ($action)
  34. {
  35. $params['mg-action'] = $action;
  36. }
  37. if ($params)
  38. {
  39. $url .= '&' . http_build_query($params);
  40. }
  41. }
  42. if (isAdmin())
  43. {
  44. return '../dologin.php?username=' . urlencode($this->getWhmcsParamByKey('clientsdetails')['email']) . '&goto=' . urlencode($url);
  45. }
  46. return $url;
  47. }
  48. }