From 25e6bd655461c29b4b7fafbd364d0eb813756130 Mon Sep 17 00:00:00 2001 From: an0nz Date: Sun, 31 Aug 2025 23:56:03 +1200 Subject: [PATCH 1/2] fix: hidden template config options displayed in changeos --- includes/hooks/autovm/controller.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/includes/hooks/autovm/controller.php b/includes/hooks/autovm/controller.php index 71ddaf6..9c23201 100644 --- a/includes/hooks/autovm/controller.php +++ b/includes/hooks/autovm/controller.php @@ -221,7 +221,7 @@ public function desiredTemplates() // Find allowed templates $params = ['packageId' => $service->packageid]; - $templates = Capsule::select("SELECT a.optionname as name FROM tblproductconfigoptionssub a INNER JOIN tblproductconfigoptions b ON b.id = a.configid INNER JOIN tblproductconfiglinks c ON c.gid = b.gid WHERE b.optionname LIKE '%template%' AND c.pid = :packageId", $params); + $templates = Capsule::select("SELECT a.optionname as name FROM tblproductconfigoptionssub a INNER JOIN tblproductconfigoptions b ON b.id = a.configid INNER JOIN tblproductconfiglinks c ON c.gid = b.gid WHERE a.hidden=0 AND b.optionname LIKE '%template%' AND c.pid = :packageId", $params); // List allowed templates $allowdTemplates = []; From c8ef16f3e5761c0a1d1155e3d5487b2739bb0470 Mon Sep 17 00:00:00 2001 From: an0nz Date: Sun, 31 Aug 2025 23:59:05 +1200 Subject: [PATCH 2/2] fix: correctly handleand show whmcs template config options that use the value|display name format. --- includes/hooks/autovm/controller.php | 28 ++++++++++++++--- .../product/views/view/assets/js/main.js | 30 +++++++++++++++++++ .../servers/product/views/view/changeos.php | 2 +- .../servers/product/views/view/hoststatus.php | 2 +- .../product/views/view/machinedetals.php | 5 +++- 5 files changed, 60 insertions(+), 7 deletions(-) diff --git a/includes/hooks/autovm/controller.php b/includes/hooks/autovm/controller.php index 9c23201..b68861c 100644 --- a/includes/hooks/autovm/controller.php +++ b/includes/hooks/autovm/controller.php @@ -224,20 +224,24 @@ public function desiredTemplates() $templates = Capsule::select("SELECT a.optionname as name FROM tblproductconfigoptionssub a INNER JOIN tblproductconfigoptions b ON b.id = a.configid INNER JOIN tblproductconfiglinks c ON c.gid = b.gid WHERE a.hidden=0 AND b.optionname LIKE '%template%' AND c.pid = :packageId", $params); // List allowed templates - $allowdTemplates = []; + $allowedTemplates = []; + $allowedTemplatesDisplayNames = []; foreach ($templates as $template) { - - $allowdTemplates[] = $template->name; + $nameParts = explode('|', $template->name); + $allowedTemplates[] = $nameParts[0]; + $allowedTemplatesDisplayNames[] = $nameParts[1] ?? $nameParts[0]; } // Remove templates foreach ($response->data as $key => $template) { - $allowed = in_array($template->name, $allowdTemplates); + $allowed = in_array($template->name, $allowedTemplates); if (!$allowed) { unset($response->data[$key]); + } else { + $response->data[$key]->display_name = $allowedTemplatesDisplayNames[array_search($template->name, $allowedTemplates)] ?? $template->name; } } @@ -282,6 +286,22 @@ public function show() // Send request $response = $this->sendShowRequest($machineId); + // Find service + $service = Service::find($this->serviceId); + + $templateName = $response->data->template->name ?? null; + + if ($service && $templateName) { + // Find template config option and retrieve the display name + $params = ['packageId' => $service->packageid, 'templateName' => $templateName.'|%']; + $template = Capsule::select("SELECT a.optionname as name FROM tblproductconfigoptionssub a INNER JOIN tblproductconfigoptions b ON b.id = a.configid INNER JOIN tblproductconfiglinks c ON c.gid = b.gid WHERE a.optionname LIKE :templateName AND b.optionname LIKE '%template%' AND c.pid = :packageId", $params); + if (is_array($template) && count($template) > 0 && isset($template[0]->name)) { + $nameParts = explode('|', $template[0]->name); + $templateDisplayName = $nameParts[1] ?? $nameParts[0]; + $response->data->template->display_name = $templateDisplayName; + } + } + $this->response($response); } diff --git a/modules/servers/product/views/view/assets/js/main.js b/modules/servers/product/views/view/assets/js/main.js index b042a9a..ac6c675 100644 --- a/modules/servers/product/views/view/assets/js/main.js +++ b/modules/servers/product/views/view/assets/js/main.js @@ -333,6 +333,28 @@ const app = Vue.createApp({ }, + findTemplateDisplayName() { + + let cats = this.categories + + let id = this.templateId + + for (let i = 0; i < cats.length; i++) { + + let temp = cats[i].templates + + for (let j = 0; j < temp.length; j++) { + if (temp[j].id == id) { + this.tempDisplayNameSetup = temp[j].name + return temp[j].name; + } + } + } + + return 'er'; + + }, + findTemplateIcon() { let cats = this.categories @@ -557,6 +579,12 @@ const app = Vue.createApp({ return tempName }, + tempDisplayName() { + let tempDisplayName = null + tempDisplayName = this.getMachineProperty('template.display_name') + return tempDisplayName + }, + tempIcon() { let tempIcon = null; tempIcon = this.getMachineProperty('template.icon.address') @@ -2044,8 +2072,10 @@ const app = Vue.createApp({ } let templateName = templates.find(findname).name + let templateDisplayName = templates.find(findname).display_name let templateIcon = templates.find(findname).icon.address this.tempNameSetup = templateName + this.tempDisplayNameSetup = templateDisplayName this.tempIconSetup = templateIcon }, diff --git a/modules/servers/product/views/view/changeos.php b/modules/servers/product/views/view/changeos.php index 03df233..0eaf5d9 100644 --- a/modules/servers/product/views/view/changeos.php +++ b/modules/servers/product/views/view/changeos.php @@ -22,7 +22,7 @@
diff --git a/modules/servers/product/views/view/hoststatus.php b/modules/servers/product/views/view/hoststatus.php index ab69d9c..6b11147 100644 --- a/modules/servers/product/views/view/hoststatus.php +++ b/modules/servers/product/views/view/hoststatus.php @@ -1,7 +1,7 @@
-
+
{{ lang('hostname') }} diff --git a/modules/servers/product/views/view/machinedetals.php b/modules/servers/product/views/view/machinedetals.php index 3cca490..e9e3319 100644 --- a/modules/servers/product/views/view/machinedetals.php +++ b/modules/servers/product/views/view/machinedetals.php @@ -133,7 +133,10 @@ templateicon templateicon
- + + {{ tempDisplayName }} + + {{ tempName }}