From 723dd04bc0b3d36b704ee62643dae1818b09a613 Mon Sep 17 00:00:00 2001
From: tbrehm <t.brehm@ispconfig.org>
Date: Mon, 4 May 2009 15:22:07 +0000
Subject: [PATCH] Fixed: FS#699 - Bug: Change Client of DNS entry

---
 interface/web/dns/dns_soa_edit.php | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/interface/web/dns/dns_soa_edit.php b/interface/web/dns/dns_soa_edit.php
index 24ff16460b..0616c56522 100644
--- a/interface/web/dns/dns_soa_edit.php
+++ b/interface/web/dns/dns_soa_edit.php
@@ -175,6 +175,18 @@ class page_action extends tform_actions {
 			// And we want to update all rr records too, that belong to this record
 			$app->db->query("UPDATE dns_rr SET sys_groupid = $client_group_id WHERE zone = ".$this->id);
 		}
+		
+		//** When the client group has changed, change also the owner of the record if the owner is not the admin user
+		if($this->oldDataRecord["client_group_id"] != $this->dataRecord["client_group_id"] && $this->dataRecord["sys_userid"] != 1) {
+			$client_group_id = intval($this->dataRecord["client_group_id"]);
+			$tmp = $app->db->queryOneREcord("SELECT userid FROM sys_user WHERE default_group = ".$client_group_id);
+			if($tmp["userid"] > 0) {
+				$app->db->query("UPDATE dns_soa SET sys_userid = ".$tmp["userid"]." WHERE id = ".$this->id);
+				$app->db->query("UPDATE dns_rr SET sys_userid = ".$tmp["userid"]." WHERE zone = ".$this->id);
+			}
+			
+		}
+		
 	}
 	
 }
-- 
GitLab