| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173 |
- <?php
- /* * ********************************************************************
- * ProxmoxVPS Product developed. (27.03.19)
- * *
- *
- * CREATED BY MODULESGARDEN -> http://modulesgarden.com
- * CONTACT -> contact@modulesgarden.com
- *
- *
- * This software is furnished under a license and may be used and copied
- * only in accordance with the terms of such license and with the
- * inclusion of the above copyright notice. This software or any other
- * copies thereof may not be provided or otherwise made available to any
- * other person. No title to and ownership of the software is hereby
- * transferred.
- *
- *
- * ******************************************************************** */
- namespace ModulesGarden\ProxmoxAddon\App\Services\Cloud;
- use ModulesGarden\ProxmoxAddon\App\Models\VmModel;
- use ModulesGarden\ProxmoxAddon\Core\UI\Traits\WhmcsParams;
- use ModulesGarden\ProxmoxAddon\Core\UI\Widget\Sidebar\Sidebar;
- use ModulesGarden\ProxmoxAddon\Core\UI\Widget\Sidebar\SidebarItem;
- use ModulesGarden\ProxmoxAddon\Core\UI\Widget\Sidebar\SidebarService;
- use ModulesGarden\Servers\ProxmoxCloudVps\App\Http\Client\BaseClientController;
- use function ModulesGarden\Servers\ProxmoxCloudVps\Core\Helper\sl;
- class ClientAreaSidebarService
- {
- use HostingService;
- use WhmcsParams;
- use ProductService;
- use BaseClientController;
- /**
- * @var \WHMCS\View\Menu\Item
- */
- private $primarySidebar;
- /**
- * ClientAreaSidebarService constructor.
- * @param $hostingId
- */
- public function __construct($hostingId, \WHMCS\View\Menu\Item $primarySidebar)
- {
- $this->setHostingId($hostingId);
- $this->primarySidebar = $primarySidebar;
- }
- public function informationReplaceUri()
- {
- $overview = $this->primarySidebar->getChild('Service Details Overview');
- if (!is_a($overview, '\WHMCS\View\Menu\Item'))
- {
- return;
- }
- $panel = $overview->getChild('Information');
- if (!is_a($panel, '\WHMCS\View\Menu\Item'))
- {
- return;
- }
- $panel->setUri("clientarea.php?action=productdetails&id={$this->getHostingId()}");
- $panel->setAttributes([]);
- return $this;
- }
- public function serviceDetailsOverview(){
- if(!$this->getWhmcsParamByKey("packageid") || !$this->configuration()->isPermissionCustomTemplates()){
- return;
- }
- $overview = $this->primarySidebar->getChild('Service Details Overview');
- if (!is_a($overview, '\WHMCS\View\Menu\Item'))
- {
- return;
- }
- $order = 800;
- foreach ( sl("sidebar")->getSidebar('Service Details Overview')->get() as $sidebarItem)
- {
- /**
- * @var SidebarItem $sidebarItem
- */
- $newItem = [
- 'label' => sl('lang')->abtr($sidebarItem->getTitle()),
- 'uri' => str_replace('{$hostingId}', $this->getHostingId(), $sidebarItem->getHref()),
- 'order' => $sidebarItem->getOrder(),
- "current" => $sidebarItem->isActive()
- ];
- $childOrder = $sidebarItem->getOrder();
- $overview->addChild($sidebarItem->getName(), $newItem);
- }
- // /**
- // * @var Sidebar $sidebar
- // */
- // $newPanel = [
- // 'label' => sl("lang")->abtr('customTemplates'),
- // 'order' => 6969
- // 'uri' => str_replace('{$hostingId}', $this->getHostingId(), $sidebarItem->getHref()),
- // "current" => $sidebarItem->isActive()
- // ];
- // $childPanel = $this->primarySidebar->addChild('customTemplates', $newPanel);
- }
- public function build()
- {
- /**
- * @var $sidebarService SidebarService
- */
- $sidebarService = sl("sidebar");
- $this->setProductId($this->hosting()->packageid);
- /**
- * @var $lang \ModulesGarden\Servers\ProxmoxVps\Core\Lang\Lang
- */
- $lang = sl("lang");
- $request = sl('request');
- $order = 671;
- $vmUrl = 'clientarea.php?action=productdetails&id={$hostingId}&modop=custom&a=management&mg-page=vm&vm={$vmId}';
- /**
- * virtualMachines
- */
- foreach ($sidebarService->get() as $sidebar)
- {
- if($sidebar->getName()=='Service Details Overview'){
- continue;
- }
- /**
- * @var Sidebar $sidebar
- */
- $newPanel = [
- 'label' => $lang->abtr($sidebar->getTitle()),
- 'order' => $order
- ];
- $order++;
- $childPanel = $this->primarySidebar->addChild($sidebar->getName(), $newPanel);
- foreach ($sidebar->getChildren() as $sidebarItem)
- {
- /**
- * @var SidebarItem $sidebarItem
- */
- $newItem = [
- 'label' => $lang->abtr($sidebarItem->getTitle()),
- 'uri' => str_replace('{$hostingId}', $this->getHostingId(), $sidebarItem->getHref()),
- 'order' => $sidebarItem->getOrder(),
- "current" => $sidebarItem->isActive()
- ];
- $childOrder = $sidebarItem->getOrder();
- $childPanel->addChild($sidebarItem->getName(), $newItem);
- }
- /**
- * @var VmModel $vmModel
- */
- foreach (VmModel::ofHostingId( $this->getHostingId())->notVmid(0)->notTemplate()->get() as $vmModel){
- if($sidebar->getName()=='Virtual Datacenter'){
- continue;
- }
- $childOrder++;
- $newItem = [
- 'label' => $vmModel->name,
- 'uri' => str_replace(['{$hostingId}', '{$vmId}'], [$this->getHostingId(),$vmModel->id], $vmUrl),
- 'order' => $childOrder,
- "current" => $request->get('vm')==$vmModel->id
- ];
- $childPanel->addChild($vmModel->name, $newItem);
- }
- }
- }
- }
|