From 2f337b079b33d51596324694f361736cbd749ab9 Mon Sep 17 00:00:00 2001
From: Till <t.brehm@ispconfig.org>
Date: Mon, 7 Nov 2022 18:04:22 +0100
Subject: [PATCH] Fix issue that PHP version of a site gets altered when an
 admin edits the site when domain limit mode is active.

---
 interface/web/sites/templates/web_vhost_domain_edit.htm | 3 +++
 interface/web/sites/web_vhost_domain_edit.php           | 6 ++++++
 2 files changed, 9 insertions(+)

diff --git a/interface/web/sites/templates/web_vhost_domain_edit.htm b/interface/web/sites/templates/web_vhost_domain_edit.htm
index d8c7d11939..c4421aac74 100644
--- a/interface/web/sites/templates/web_vhost_domain_edit.htm
+++ b/interface/web/sites/templates/web_vhost_domain_edit.htm
@@ -66,6 +66,9 @@
                     </div>
                 </tmpl_unless>
             </tmpl_if>
+            <tmpl_if name="domain_option">
+                <input type="hidden" id="client_group_id" name="client_group_id" value="{tmpl_var name='client_group_id_value'}" />
+            </tmpl_if>
             <div class="form-group">
                 <label for="ip_address" class="col-sm-3 control-label">{tmpl_var name='ip_address_txt'}</label>
                 <div class="col-sm-9"><select name="ip_address" id="ip_address" class="form-control">
diff --git a/interface/web/sites/web_vhost_domain_edit.php b/interface/web/sites/web_vhost_domain_edit.php
index 9b1117fb2b..365582e9af 100644
--- a/interface/web/sites/web_vhost_domain_edit.php
+++ b/interface/web/sites/web_vhost_domain_edit.php
@@ -725,6 +725,12 @@ class page_action extends tform_actions {
 			// remove the parent domain part of the domain name before we show it in the text field.
 			if($this->dataRecord["type"] == 'vhostsubdomain') $this->dataRecord["domain"] = str_replace('.'.$selected_domain, '', $this->dataRecord["domain"]);
 
+			// We have to set the client group id value as the client select field is hidden in this mode
+			if($is_admin) {
+				$app->tpl->setVar("client_group_id_value", $this->dataRecord["sys_groupid"], true);
+			} else {
+				$app->tpl->setVar("client_group_id_value", $_SESSION["s"]["user"]["default_group"], true);
+			}
 
 		} else {
 			// remove the parent domain part of the domain name before we show it in the text field.
-- 
GitLab