diff --git a/interface/lib/lang/en.lng b/interface/lib/lang/en.lng
index 1d47aeb63bb4749e10ed9629e43cc7d1f840ad98..ec309d9f850adf2f1540598fda4ab7c366067569 100644
--- a/interface/lib/lang/en.lng
+++ b/interface/lib/lang/en.lng
@@ -149,6 +149,5 @@ $wb['strength_4'] = 'Strong';
 $wb['strength_5'] = 'Very Strong';
 $wb['weak_password_txt'] = 'The chosen password does not match the security guidelines. It has to be at least {chars} chars in length and have a strength of "{strength}".';
 $wb['weak_password_length_txt'] = 'The chosen password does not match the security guidelines. It has to be at least {chars} chars in length.';
-$wb['domain_owner_changed'] = 'You have changed the owner of domain {domain}, please change website and mail domain owner for this domain accordingly.';
 
 ?>
diff --git a/interface/lib/lang/es.lng b/interface/lib/lang/es.lng
index e5763574e821f14f9734617e85b4dd663b9c710b..38f6103ddfd53db7c7302a04b1fcf1dd1af31e5f 100644
--- a/interface/lib/lang/es.lng
+++ b/interface/lib/lang/es.lng
@@ -148,5 +148,4 @@ $wb['strength_5'] = 'Muy fuerte';
 $wb['weak_password_txt'] = 'La contraseña elegida no cumple las directrices de seguridad. Debe tener al menos {chars} caracteres y una fortaleza \"{strength}\".';
 $wb['weak_password_length_txt'] = 'La contraseña elegida no cumple las directrices de seguridad. Debe tener al menos {chars} caracteres.';
 $wb['Firewall'] = 'Cortafuegos';
-$wb['domain_owner_changed'] = 'Has cambiado el propietario del dominio {domain}, por favor cambia también el propietario del sitio web y dominio de correo de este dominio.';
 ?>
diff --git a/interface/lib/plugins/dns_dns_slave_plugin.inc.php b/interface/lib/plugins/dns_dns_slave_plugin.inc.php
new file mode 100644
index 0000000000000000000000000000000000000000..aa2e20f9ab4089e5833de379049ee22f416f24a3
--- /dev/null
+++ b/interface/lib/plugins/dns_dns_slave_plugin.inc.php
@@ -0,0 +1,50 @@
+<?php
+/**
+ * dns_dns_slave_plugin plugin
+ *
+ * @author Sergio Cambra <sergio@programatica.es> 2014
+ */
+
+
+class dns_dns_slave_plugin {
+
+	var $plugin_name        = 'dns_dns_slave_plugin';
+	var $class_name         = 'dns_dns_slave_plugin';
+
+	/*
+            This function is called when the plugin is loaded
+    */
+	function onLoad() {
+		global $app;
+		//Register for the events
+		$app->plugin->registerEvent('dns:dns_slave:on_after_insert', 'dns_dns_slave_plugin', 'dns_dns_slave_edit');
+		$app->plugin->registerEvent('dns:dns_slave:on_after_update', 'dns_dns_slave_plugin', 'dns_dns_slave_edit');
+	}
+
+	/*
+		Function to change dns slave owner
+    */
+	function dns_dns_slave_edit($event_name, $page_form) {
+		global $app, $conf;
+
+		// make sure that the record belongs to the client group and not the admin group when a dmin inserts it
+		if($_SESSION["s"]["user"]["typ"] == 'admin' && isset($page_form->dataRecord["client_group_id"])) {
+			$client_group_id = $app->functions->intval($page_form->dataRecord["client_group_id"]);
+			$app->db->query("UPDATE dns_slave SET sys_groupid = $client_group_id WHERE id = ".$page_form->id);
+		}
+		if($app->auth->has_clients($_SESSION['s']['user']['userid']) && isset($this->dataRecord["client_group_id"])) {
+			$client_group_id = $app->functions->intval($this->dataRecord["client_group_id"]);
+			$app->db->query("UPDATE dns_slave SET sys_groupid = $client_group_id WHERE id = ".$page_form->id);
+		}
+
+		//** When the client group has changed, change also the owner of the record if the owner is not the admin user
+		if($page_form->oldDataRecord && $page_form->oldDataRecord["client_group_id"] != $page_form->dataRecord["client_group_id"] && $page_form->dataRecord["sys_userid"] != 1) {
+			$client_group_id = $app->functions->intval($page_form->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_slave SET sys_userid = ".$tmp["userid"]." WHERE id = ".$page_form->id);
+			}
+		}
+	}
+
+}
diff --git a/interface/lib/plugins/dns_dns_soa_plugin.inc.php b/interface/lib/plugins/dns_dns_soa_plugin.inc.php
new file mode 100644
index 0000000000000000000000000000000000000000..1cada0e932d59510d136542b8a3295933a434e37
--- /dev/null
+++ b/interface/lib/plugins/dns_dns_soa_plugin.inc.php
@@ -0,0 +1,64 @@
+<?php
+/**
+ * dns_dns_soa_plugin plugin
+ *
+ * @author Sergio Cambra <sergio@programatica.es> 2014
+ */
+
+
+class dns_dns_soa_plugin {
+
+	var $plugin_name        = 'dns_dns_soa_plugin';
+	var $class_name         = 'dns_dns_soa_plugin';
+
+	/*
+            This function is called when the plugin is loaded
+    */
+	function onLoad() {
+		global $app;
+		//Register for the events
+		$app->plugin->registerEvent('dns:dns_soa:on_after_insert', 'dns_dns_soa_plugin', 'dns_dns_soa_edit');
+		$app->plugin->registerEvent('dns:dns_soa:on_after_update', 'dns_dns_soa_plugin', 'dns_dns_soa_edit');
+	}
+
+	/*
+		Function to change dns soa owner
+    */
+	function dns_dns_soa_edit($event_name, $page_form) {
+		global $app, $conf;
+
+		if ($event_name == 'dns:dns_soa:on_after_update') {
+			$tmp = $app->db->diffrec($page_form->oldDataRecord, $app->tform->getDataRecord($page_form->id));
+			if($tmp['diff_num'] > 0) {
+				// Update the serial number of the SOA record
+				$soa = $app->db->queryOneRecord("SELECT serial FROM dns_soa WHERE id = ".$page_form->id);
+				$app->db->query("UPDATE dns_soa SET serial = '".$app->validate_dns->increase_serial($soa["serial"])."' WHERE id = ".$page_form->id);
+			}
+
+			//** When the client group has changed, change also the owner of the record if the owner is not the admin user
+			if($page_form->oldDataRecord["client_group_id"] != $page_form->dataRecord["client_group_id"] && $page_form->dataRecord["sys_userid"] != 1) {
+				$client_group_id = $app->functions->intval($page_form->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 = ".$page_form->id);
+					$app->db->query("UPDATE dns_rr SET sys_userid = ".$tmp["userid"]." WHERE zone = ".$page_form->id);
+				}
+			}
+		}
+
+		// make sure that the record belongs to the client group and not the admin group when a dmin inserts it
+		if($_SESSION["s"]["user"]["typ"] == 'admin' && isset($page_form->dataRecord["client_group_id"])) {
+			$client_group_id = $app->functions->intval($page_form->dataRecord["client_group_id"]);
+			$app->db->query("UPDATE dns_soa SET sys_groupid = $client_group_id, sys_perm_group = 'ru' WHERE id = ".$page_form->id);
+			// 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 = ".$page_form->id);
+		}
+		if($app->auth->has_clients($_SESSION['s']['user']['userid']) && isset($page_form->dataRecord["client_group_id"])) {
+			$client_group_id = $app->functions->intval($page_form->dataRecord["client_group_id"]);
+			$app->db->query("UPDATE dns_soa SET sys_groupid = $client_group_id, sys_perm_group = 'riud' WHERE id = ".$page_form->id);
+			// 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 = ".$page_form->id);
+		}
+	}
+
+}
diff --git a/interface/lib/plugins/mail_mail_domain_plugin.inc.php b/interface/lib/plugins/mail_mail_domain_plugin.inc.php
new file mode 100644
index 0000000000000000000000000000000000000000..13f6009ee58d62a84aaf6cc4de54b9c48a5ca4e3
--- /dev/null
+++ b/interface/lib/plugins/mail_mail_domain_plugin.inc.php
@@ -0,0 +1,114 @@
+<?php
+/**
+ * mail_mail_domain_plugin plugin
+ *
+ * @author Sergio Cambra <sergio@programatica.es> 2014
+ */
+
+
+class mail_mail_domain_plugin {
+
+	var $plugin_name        = 'mail_mail_domain_plugin';
+	var $class_name         = 'mail_mail_domain_plugin';
+
+	/*
+            This function is called when the plugin is loaded
+    */
+	function onLoad() {
+		global $app;
+		//Register for the events
+		$app->plugin->registerEvent('mail:mail_domain:on_after_insert', 'mail_mail_domain_plugin', 'mail_mail_domain_edit');
+		$app->plugin->registerEvent('mail:mail_domain:on_after_update', 'mail_mail_domain_plugin', 'mail_mail_domain_edit');
+	}
+
+	/*
+		Function to create the sites_web_domain rule and insert it into the custom rules
+    */
+	function mail_mail_domain_edit($event_name, $page_form) {
+		global $app, $conf;
+
+		// make sure that the record belongs to the clinet group and not the admin group when a dmin inserts it
+		// also make sure that the user can not delete entry created by an admin
+		if($_SESSION["s"]["user"]["typ"] == 'admin' && isset($page_form->dataRecord["client_group_id"])) {
+			$client_group_id = $app->functions->intval($page_form->dataRecord["client_group_id"]);
+			$updates = "sys_groupid = $client_group_id, sys_perm_group = 'ru'";
+			if ($event_name == 'mail:mail_domain:on_after_update') {
+				$tmp = $app->db->queryOneRecord("SELECT userid FROM sys_user WHERE default_group = $client_group_id");
+				$client_user_id = ($tmp['userid'] > 0)?$tmp['userid']:1;
+				$updates = "sys_userid = $client_user_id, $updates";
+			}
+			$app->db->query("UPDATE mail_domain SET $updates WHERE domain_id = ".$page_form->id);
+		}
+		if($app->auth->has_clients($_SESSION['s']['user']['userid']) && isset($page_form->dataRecord["client_group_id"])) {
+			$client_group_id = $app->functions->intval($page_form->dataRecord["client_group_id"]);
+			$updates = "sys_groupid = $client_group_id, sys_perm_group = 'riud'";
+			if ($event_name == 'mail:mail_domain:on_after_update') {
+				$tmp = $app->db->queryOneRecord("SELECT userid FROM sys_user WHERE default_group = $client_group_id");
+				$client_user_id = ($tmp['userid'] > 0)?$tmp['userid']:1;
+				$updates = "sys_userid = $client_user_id, $updates";
+			}
+			$app->db->query("UPDATE mail_domain SET $updates WHERE domain_id = ".$page_form->id);
+		}
+
+		//** If the domain name or owner has been changed, change the domain and owner in all mailbox records
+		if($page_form->oldDataRecord && ($page_form->oldDataRecord['domain'] != $page_form->dataRecord['domain'] ||
+				(isset($page_form->dataRecord['client_group_id']) && $page_form->oldDataRecord['sys_groupid'] != $page_form->dataRecord['client_group_id']))) {
+			$app->uses('getconf');
+			$mail_config = $app->getconf->get_server_config($page_form->dataRecord["server_id"], 'mail');
+
+			//* Update the mailboxes
+			$mailusers = $app->db->queryAllRecords("SELECT * FROM mail_user WHERE email like '%@".$app->db->quote($page_form->oldDataRecord['domain'])."'");
+			$sys_groupid = $app->functions->intval((isset($page_form->dataRecord['client_group_id']))?$page_form->dataRecord['client_group_id']:$page_form->oldDataRecord['sys_groupid']);
+			$tmp = $app->db->queryOneRecord("SELECT userid FROM sys_user WHERE default_group = $sys_groupid");
+			$client_user_id = $app->functions->intval(($tmp['userid'] > 0)?$tmp['userid']:1);
+			if(is_array($mailusers)) {
+				foreach($mailusers as $rec) {
+					// setting Maildir, Homedir, UID and GID
+					$mail_parts = explode("@", $rec['email']);
+					$maildir = str_replace("[domain]", $page_form->dataRecord['domain'], $mail_config["maildir_path"]);
+					$maildir = str_replace("[localpart]", $mail_parts[0], $maildir);
+					$maildir = $app->db->quote($maildir);
+					$email = $app->db->quote($mail_parts[0].'@'.$page_form->dataRecord['domain']);
+					$app->db->datalogUpdate('mail_user', "maildir = '$maildir', email = '$email', sys_userid = $client_user_id, sys_groupid = '$sys_groupid'", 'mailuser_id', $rec['mailuser_id']);
+				}
+			}
+
+			//* Update the aliases
+			$forwardings = $app->db->queryAllRecords("SELECT * FROM mail_forwarding WHERE source like '%@".$app->db->quote($page_form->oldDataRecord['domain'])."' OR destination like '%@".$app->db->quote($page_form->oldDataRecord['domain'])."'");
+			if(is_array($forwardings)) {
+				foreach($forwardings as $rec) {
+					$destination = $app->db->quote(str_replace($page_form->oldDataRecord['domain'], $page_form->dataRecord['domain'], $rec['destination']));
+					$source = $app->db->quote(str_replace($page_form->oldDataRecord['domain'], $page_form->dataRecord['domain'], $rec['source']));
+					$app->db->datalogUpdate('mail_forwarding', "source = '$source', destination = '$destination', sys_userid = $client_user_id, sys_groupid = '$sys_groupid'", 'forwarding_id', $rec['forwarding_id']);
+				}
+			}
+
+			//* Update the mailinglist
+			$mailing_lists = $app->db->queryAllRecords("SELECT mailinglist_id FROM mail_mailinglist WHERE domain = '".$app->db->quote($page_form->oldDataRecord['domain'])."'");
+			if(is_array($mailing_lists)) {
+				foreach($mailing_lists as $rec) {
+					$app->db->datalogUpdate('mail_mailinglist', "sys_userid = $client_user_id, sys_groupid = '$sys_groupid'", 'mailinglist_id', $rec['mailinglist_id']);
+				}
+			}
+
+			//* Update the mailget records
+			$mail_gets = $app->db->queryAllRecords("SELECT mailget_id, destination FROM mail_get WHERE destination LIKE '%@".$app->db->quote($page_form->oldDataRecord['domain'])."'");
+			if(is_array($mail_gets)) {
+				foreach($mail_gets as $rec) {
+					$destination = $app->db->quote(str_replace($page_form->oldDataRecord['domain'], $page_form->dataRecord['domain'], $rec['destination']));
+					$app->db->datalogUpdate('mail_get', "destination = '$destination', sys_userid = $client_user_id, sys_groupid = '$sys_groupid'", 'mailget_id', $rec['mailget_id']);
+				}
+			}
+
+			if ($page_form->oldDataRecord["domain"] != $page_form->dataRecord['domain']) {
+				//* Delete the old spamfilter record
+				$tmp = $app->db->queryOneRecord("SELECT id FROM spamfilter_users WHERE email = '@".$app->db->quote($page_form->oldDataRecord["domain"])."'");
+				$app->db->datalogDelete('spamfilter_users', 'id', $tmp["id"]);
+				unset($tmp);
+			}
+			$app->db->query("UPDATE spamfilter_users SET email=REPLACE(email, '".$app->db->quote($page_form->oldDataRecord['domain'])."', '".$app->db->quote($page_form->dataRecord['domain'])."'), sys_userid = $client_user_id, sys_groupid = $sys_groupid WHERE email LIKE '%@".$app->db->quote($page_form->oldDataRecord['domain'])."'");
+
+		} // end if domain name changed
+	}
+
+}
diff --git a/interface/lib/plugins/sites_web_vhost_domain_plugin.inc.php b/interface/lib/plugins/sites_web_vhost_domain_plugin.inc.php
index 2764269d49e27504df3bdc35dc8e736fdedd9aa8..db4e20ebf83c877242db6df181aad9dae6c6a001 100644
--- a/interface/lib/plugins/sites_web_vhost_domain_plugin.inc.php
+++ b/interface/lib/plugins/sites_web_vhost_domain_plugin.inc.php
@@ -113,6 +113,30 @@ class sites_web_vhost_domain_plugin {
 					unset($records);
 					unset($rec);
 
+					// Update the webdav user(s) too
+					$records = $app->db->queryAllRecords("SELECT webdav_user_id FROM webdav_user WHERE parent_domain_id = ".$page_form->id);
+					foreach($records as $rec) {
+						$app->db->datalogUpdate('webdav_user', "sys_userid = '".$app->functions->intval($web_rec['sys_userid'])."', sys_groupid = '".$app->functions->intval($web_rec['sys_groupid'])."'", 'webdav_user_id', $app->functions->intval($rec['webdav_user_id']));
+					}
+					unset($records);
+					unset($rec);
+
+					// Update the web folder(s) too
+					$records = $app->db->queryAllRecords("SELECT web_folder_id FROM web_folder WHERE parent_domain_id = ".$page_form->id);
+					foreach($records as $rec) {
+						$app->db->datalogUpdate('web_folder', "sys_userid = '".$app->functions->intval($web_rec['sys_userid'])."', sys_groupid = '".$app->functions->intval($web_rec['sys_groupid'])."'", 'web_folder_id', $app->functions->intval($rec['web_folder_id']));
+					}
+					unset($records);
+					unset($rec);
+
+					//* Update all web folder users
+					$records = $app->db->queryAllRecords("SELECT web_folder_user.web_folder_user_id FROM web_folder_user, web_folder WHERE web_folder_user.web_folder_id = web_folder.web_folder_id AND web_folder.parent_domain_id = ".$page_form->id);
+					foreach($records as $rec) {
+						$app->db->datalogUpdate('web_folder_user', "sys_userid = '".$app->functions->intval($web_rec['sys_userid'])."', sys_groupid = '".$app->functions->intval($web_rec['sys_groupid'])."'", 'web_folder_user_id', $app->functions->intval($rec['web_folder_user_id']));
+					}
+					unset($records);
+					unset($rec);
+
 					// Update the Shell user(s) too
 					$records = $app->db->queryAllRecords("SELECT shell_user_id FROM shell_user WHERE parent_domain_id = ".$page_form->id);
 					foreach($records as $rec) {
@@ -121,6 +145,14 @@ class sites_web_vhost_domain_plugin {
 					unset($records);
 					unset($rec);
 
+					// Update the cron(s) too
+					$records = $app->db->queryAllRecords("SELECT id FROM cron WHERE parent_domain_id = ".$page_form->id);
+					foreach($records as $rec) {
+						$app->db->datalogUpdate('cron', "sys_userid = '".$app->functions->intval($web_rec['sys_userid'])."', sys_groupid = '".$app->functions->intval($web_rec['sys_groupid'])."'", 'id', $app->functions->intval($rec['id']));
+					}
+					unset($records);
+					unset($rec);
+
 					//* Update all subdomains and alias domains
 					$records = $app->db->queryAllRecords("SELECT domain_id, `domain`, `type`, `web_folder` FROM web_domain WHERE parent_domain_id = ".$page_form->id);
 					foreach($records as $rec) {
@@ -143,6 +175,22 @@ class sites_web_vhost_domain_plugin {
 					foreach($records as $rec) {
 						$app->db->datalogUpdate('web_database', "sys_userid = '".$app->functions->intval($web_rec['sys_userid'])."', sys_groupid = '".$app->functions->intval($web_rec['sys_groupid'])."'", 'database_id', $app->functions->intval($rec['database_id']));
 					}
+
+					//* Update all database users
+					$records = $app->db->queryAllRecords("SELECT web_database_user.database_user_id FROM web_database_user, web_database WHERE web_database_user.database_user_id IN (web_database.database_user_id, web_database.database_ro_user_id) AND web_database.parent_domain_id = ".$page_form->id);
+					foreach($records as $rec) {
+						$app->db->datalogUpdate('web_database_user', "sys_userid = '".$app->functions->intval($web_rec['sys_userid'])."', sys_groupid = '".$app->functions->intval($web_rec['sys_groupid'])."'", 'database_user_id', $app->functions->intval($rec['database_user_id']));
+					}
+					unset($records);
+					unset($rec);
+
+					// Update APS instances
+					$records = $app->db->queryAllRecords("SELECT instance_id FROM aps_instances_settings WHERE name = 'main_domain' AND value = '".$app->db->quote($page_form->oldDataRecord["domain"])."'");
+					if(is_array($records) && !empty($records)){
+						foreach($records as $rec){
+							$app->db->datalogUpdate('aps_instances', "sys_userid = '".$app->functions->intval($web_rec['sys_userid'])."', sys_groupid = '".$app->functions->intval($web_rec['sys_groupid'])."', customer_id = '".$app->functions->intval($client_id)."'", 'id', $rec['instance_id']);
+						}
+					}
 					unset($records);
 					unset($rec);
 
diff --git a/interface/web/client/domain_edit.php b/interface/web/client/domain_edit.php
index a79ba856f80364aa3ac5792057c5cbc4899b3019..221e8a2079e445e269a0677f7ec39817b820e87b 100644
--- a/interface/web/client/domain_edit.php
+++ b/interface/web/client/domain_edit.php
@@ -216,8 +216,44 @@ class page_action extends tform_actions {
 		if(isset($this->dataRecord["client_group_id"])) {
 			$client_group_id = $app->functions->intval($this->dataRecord["client_group_id"]);
 			$app->db->query("UPDATE domain SET sys_groupid = $client_group_id, sys_perm_group = 'ru' WHERE domain_id = ".$this->id);
-			$lng_text = $app->lng("domain_owner_changed");
-			$_SESSION['show_warning_msg'] = str_replace("{domain}", $this->dataRecord["domain"], $lng_text);
+
+			$data = new tform_actions();
+			$tform = $app->tform;
+			$app->tform = new tform();
+
+			$app->tform->loadFormDef("../dns/form/dns_soa.tform.php");
+			$data->oldDataRecord = $app->db->queryOneRecord("SELECT * FROM dns_soa WHERE origin LIKE '".$this->dataRecord['domain'].".'");
+			if ($data->oldDataRecord) {
+				$data->dataRecord = array_merge($data->oldDataRecord, array('client_group_id' => $this->dataRecord["client_group_id"]));
+				$data->id = $data->dataRecord['id'];
+				$app->plugin->raiseEvent("dns:dns_soa:on_after_update", $data);
+			}
+
+			$app->tform->loadFormDef("../dns/form/dns_slave.tform.php");
+			$data->oldDataRecord = $app->db->queryOneRecord("SELECT * FROM dns_slave WHERE origin LIKE '".$this->dataRecord['domain'].".'");
+			if ($data->oldDataRecord) {
+				$data->dataRecord = array_merge($data->oldDataRecord, array('client_group_id' => $this->dataRecord["client_group_id"]));
+				$data->id = $data->dataRecord['id'];
+				$app->plugin->raiseEvent("dns:dns_slave:on_after_update", $data);
+			}
+
+			$app->tform->loadFormDef("../mail/form/mail_domain.tform.php");
+			$data->oldDataRecord = $app->db->queryOneRecord("SELECT * FROM mail_domain WHERE domain = '".$this->dataRecord['domain']."'");
+			if ($data->oldDataRecord) {
+				$data->dataRecord = array_merge($data->oldDataRecord, array('client_group_id' => $this->dataRecord["client_group_id"]));
+				$data->id = $data->dataRecord['domain_id'];
+				$app->plugin->raiseEvent("mail:mail_domain:on_after_update", $data);
+			}
+
+			$app->tform->loadFormDef("../sites/form/web_vhost_domain.tform.php");
+			$data->oldDataRecord = $app->db->queryOneRecord("SELECT * FROM web_domain WHERE domain = '".$this->dataRecord['domain']."'");
+			if ($data->oldDataRecord) {
+				$data->dataRecord = array_merge($data->oldDataRecord, array('client_group_id' => $this->dataRecord["client_group_id"]));
+				$data->id = $data->dataRecord['domain_id'];
+				$app->plugin->raiseEvent("sites:web_vhost_domain:on_after_update", $data);
+			}
+
+			$app->tform = $tform;
 		}
 	}
 
diff --git a/interface/web/client/domain_list.php b/interface/web/client/domain_list.php
index 4c6bdf9925187bcb64d2bce2d67610e20683a11e..622e52a97e3a62d9dd94b20d1b2dd0c4321d9b8e 100644
--- a/interface/web/client/domain_list.php
+++ b/interface/web/client/domain_list.php
@@ -46,11 +46,6 @@ $app->auth->check_module_permissions('client');
 
 $app->uses('listform_actions');
 
-if(isset($_SESSION['show_warning_msg'])) {
-	$app->tpl->setVar('warning_msg', $_SESSION['show_warning_msg']);
-	unset($_SESSION['show_warning_msg']);
-}
-
 $app->listform_actions->SQLOrderBy = 'ORDER BY domain.domain';
 $app->listform_actions->onLoad();
 
diff --git a/interface/web/client/templates/domain_list.htm b/interface/web/client/templates/domain_list.htm
index 4bbb09a3899ca138561be5ffd23f91933c769f7b..3100660896b877df92d90c3908fc88813c7ccc17 100644
--- a/interface/web/client/templates/domain_list.htm
+++ b/interface/web/client/templates/domain_list.htm
@@ -4,16 +4,6 @@
 <div class="panel panel_list_domain">
 
     <div class="pnl_toolsarea">
-        <div>
-        <tmpl_if name='warning_msg'>
-            <div class="systemmonitor-state state-warning">
-                <div class="status"></div>
-                <div class="statusMsg">
-                    {tmpl_var name='warning_msg'}
-                </div>
-            </div>
-        </tmpl_if>
-        </div>
         <fieldset><legend>{tmpl_var name="toolsarea_head_txt"}</legend>
             <div class="buttons">
                 <button class="button iconstxt icoAdd" type="button" onclick="loadContent('client/domain_edit.php');">
diff --git a/interface/web/dns/dns_slave_edit.php b/interface/web/dns/dns_slave_edit.php
index 683d2cdfde4ce642c6e43acb24b584ee54136223..ea42823f4af381adb084d2fc7b80c36fd64abbb2 100644
--- a/interface/web/dns/dns_slave_edit.php
+++ b/interface/web/dns/dns_slave_edit.php
@@ -218,47 +218,6 @@ class page_action extends tform_actions {
 		parent::onInsert();
 	}
 
-	function onAfterInsert() {
-		global $app, $conf;
-
-		// make sure that the record belongs to the client group and not the admin group when a dmin inserts it
-		if($_SESSION["s"]["user"]["typ"] == 'admin' && isset($this->dataRecord["client_group_id"])) {
-			$client_group_id = $app->functions->intval($this->dataRecord["client_group_id"]);
-			$app->db->query("UPDATE dns_slave SET sys_groupid = $client_group_id WHERE id = ".$this->id);
-		}
-		if($app->auth->has_clients($_SESSION['s']['user']['userid']) && isset($this->dataRecord["client_group_id"])) {
-			$client_group_id = $app->functions->intval($this->dataRecord["client_group_id"]);
-			$app->db->query("UPDATE dns_slave SET sys_groupid = $client_group_id WHERE id = ".$this->id);
-		}
-
-	}
-
-	function onAfterUpdate() {
-		global $app, $conf;
-
-		$tmp = $app->db->diffrec($this->oldDataRecord, $app->tform->getDataRecord($this->id));
-
-		// make sure that the record belongs to the client group and not the admin group when a dmin inserts it
-		if($_SESSION["s"]["user"]["typ"] == 'admin' && isset($this->dataRecord["client_group_id"])) {
-			$client_group_id = $app->functions->intval($this->dataRecord["client_group_id"]);
-			$app->db->query("UPDATE dns_slave SET sys_groupid = $client_group_id WHERE id = ".$this->id);
-		}
-		if($app->auth->has_clients($_SESSION['s']['user']['userid']) && isset($this->dataRecord["client_group_id"])) {
-			$client_group_id = $app->functions->intval($this->dataRecord["client_group_id"]);
-			$app->db->query("UPDATE dns_slave SET sys_groupid = $client_group_id WHERE id = ".$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 = $app->functions->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_slave SET sys_userid = ".$tmp["userid"]." WHERE id = ".$this->id);
-			}
-		}
-
-	}
-
 }
 
 $page = new page_action;
diff --git a/interface/web/dns/dns_soa_edit.php b/interface/web/dns/dns_soa_edit.php
index 2131bfbc969849d938fab6ef9a2dab4c173cd36e..ce98f96fba2926767a4da01286eb8d117590645a 100644
--- a/interface/web/dns/dns_soa_edit.php
+++ b/interface/web/dns/dns_soa_edit.php
@@ -269,25 +269,6 @@ function onSubmit() {
 	parent::onSubmit();
 }
 
-function onAfterInsert() {
-	global $app, $conf;
-
-	// make sure that the record belongs to the client group and not the admin group when a dmin inserts it
-	if($_SESSION["s"]["user"]["typ"] == 'admin' && isset($this->dataRecord["client_group_id"])) {
-		$client_group_id = $app->functions->intval($this->dataRecord["client_group_id"]);
-		$app->db->query("UPDATE dns_soa SET sys_groupid = $client_group_id, sys_perm_group = 'ru' WHERE id = ".$this->id);
-		// 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);
-	}
-	if($app->auth->has_clients($_SESSION['s']['user']['userid']) && isset($this->dataRecord["client_group_id"])) {
-		$client_group_id = $app->functions->intval($this->dataRecord["client_group_id"]);
-		$app->db->query("UPDATE dns_soa SET sys_groupid = $client_group_id, sys_perm_group = 'riud' WHERE id = ".$this->id);
-		// 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);
-	}
-
-}
-
 function onBeforeUpdate () {
 	global $app, $conf;
 
@@ -305,42 +286,6 @@ function onBeforeUpdate () {
 	}
 }
 
-function onAfterUpdate() {
-	global $app, $conf;
-
-	$tmp = $app->db->diffrec($this->oldDataRecord, $app->tform->getDataRecord($this->id));
-	if($tmp['diff_num'] > 0) {
-		// Update the serial number of the SOA record
-		$soa = $app->db->queryOneRecord("SELECT serial FROM dns_soa WHERE id = ".$this->id);
-		$app->db->query("UPDATE dns_soa SET serial = '".$app->validate_dns->increase_serial($soa["serial"])."' WHERE id = ".$this->id);
-	}
-
-	// make sure that the record belongs to the client group and not the admin group when a dmin inserts it
-	if($_SESSION["s"]["user"]["typ"] == 'admin' && isset($this->dataRecord["client_group_id"])) {
-		$client_group_id = $app->functions->intval($this->dataRecord["client_group_id"]);
-		$app->db->query("UPDATE dns_soa SET sys_groupid = $client_group_id, sys_perm_group = 'ru' WHERE id = ".$this->id);
-		// 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);
-	}
-	if($app->auth->has_clients($_SESSION['s']['user']['userid']) && isset($this->dataRecord["client_group_id"])) {
-		$client_group_id = $app->functions->intval($this->dataRecord["client_group_id"]);
-		$app->db->query("UPDATE dns_soa SET sys_groupid = $client_group_id, sys_perm_group = 'riud' WHERE id = ".$this->id);
-		// 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 = $app->functions->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);
-		}
-	}
-
-}
-
 }
 
 $page = new page_action;
diff --git a/interface/web/mail/mail_domain_edit.php b/interface/web/mail/mail_domain_edit.php
index 4fba557143b7fc45075885d6f28a446672ea7897..56884e72655b66ade9bf4c0e3ac7595847605de1 100644
--- a/interface/web/mail/mail_domain_edit.php
+++ b/interface/web/mail/mail_domain_edit.php
@@ -261,24 +261,13 @@ class page_action extends tform_actions {
 	function onAfterInsert() {
 		global $app, $conf;
 
-		// make sure that the record belongs to the client group and not the admin group when a dmin inserts it
-		// also make sure that the user can not delete domain created by a admin
-		if($_SESSION["s"]["user"]["typ"] == 'admin' && isset($this->dataRecord["client_group_id"])) {
-			$client_group_id = $app->functions->intval($this->dataRecord["client_group_id"]);
-			$app->db->query("UPDATE mail_domain SET sys_groupid = $client_group_id, sys_perm_group = 'ru' WHERE domain_id = ".$this->id);
-		}
-		if($app->auth->has_clients($_SESSION['s']['user']['userid']) && isset($this->dataRecord["client_group_id"])) {
-			$client_group_id = $app->functions->intval($this->dataRecord["client_group_id"]);
-			$app->db->query("UPDATE mail_domain SET sys_groupid = $client_group_id, sys_perm_group = 'riud' WHERE domain_id = ".$this->id);
-		}
-
 		// Spamfilter policy
 		$policy_id = $app->functions->intval($this->dataRecord["policy"]);
 		if($policy_id > 0) {
 			$tmp_user = $app->db->queryOneRecord("SELECT id FROM spamfilter_users WHERE email = '@".$app->db->quote($this->dataRecord["domain"])."'");
 			if($tmp_user["id"] > 0) {
 				// There is already a record that we will update
-				$app->db->datalogUpdate('spamfilter_users', "policy_id = $ploicy_id", 'id', $tmp_user["id"]);
+				$app->db->datalogUpdate('spamfilter_users', "policy_id = $policy_id", 'id', $tmp_user["id"]);
 			} else {
 				$tmp_domain = $app->db->queryOneRecord("SELECT sys_groupid FROM mail_domain WHERE domain_id = ".$this->id);
 				// We create a new record
@@ -287,7 +276,7 @@ class page_action extends tform_actions {
 				$app->db->datalogInsert('spamfilter_users', $insert_data, 'id');
 				unset($tmp_domain);
 			}
-		}  // endif spamfilter policy
+		} // endif spamfilter policy
 	}
 
 	function onBeforeUpdate() {
@@ -316,26 +305,9 @@ class page_action extends tform_actions {
 		}
 	}
 
-
-
 	function onAfterUpdate() {
 		global $app, $conf;
 
-		// make sure that the record belongs to the client group and not the admin group when admin inserts it
-		// also make sure that the user can not delete domain created by a admin
-		if($_SESSION["s"]["user"]["typ"] == 'admin' && isset($this->dataRecord["client_group_id"])) {
-			$client_group_id = $app->functions->intval($this->dataRecord["client_group_id"]);
-			$tmp = $app->db->queryOneRecord("SELECT userid FROM sys_user WHERE default_group = $client_group_id");
-			$client_user_id = ($tmp['userid'] > 0)?$tmp['userid']:1;
-			$app->db->query("UPDATE mail_domain SET sys_userid = $client_user_id, sys_groupid = $client_group_id, sys_perm_group = 'ru' WHERE domain_id = ".$this->id);
-		}
-		if($app->auth->has_clients($_SESSION['s']['user']['userid']) && isset($this->dataRecord["client_group_id"])) {
-			$client_group_id = $app->functions->intval($this->dataRecord["client_group_id"]);
-			$tmp = $app->db->queryOneRecord("SELECT userid FROM sys_user WHERE default_group = $client_group_id");
-			$client_user_id = ($tmp['userid'] > 0)?$tmp['userid']:1;
-			$app->db->query("UPDATE mail_domain SET sys_userid = $client_user_id, sys_groupid = $client_group_id, sys_perm_group = 'riud' WHERE domain_id = ".$this->id);
-		}
-
 		// Spamfilter policy
 		$policy_id = $app->functions->intval($this->dataRecord["policy"]);
 		$tmp_user = $app->db->queryOneRecord("SELECT id FROM spamfilter_users WHERE email = '@".$app->db->quote($this->dataRecord["domain"])."'");
@@ -347,7 +319,7 @@ class page_action extends tform_actions {
 				$tmp_domain = $app->db->queryOneRecord("SELECT sys_groupid FROM mail_domain WHERE domain_id = ".$this->id);
 				// We create a new record
 				$insert_data = "(`sys_userid`, `sys_groupid`, `sys_perm_user`, `sys_perm_group`, `sys_perm_other`, `server_id`, `priority`, `policy_id`, `email`, `fullname`, `local`)
-				        VALUES (".$_SESSION["s"]["user"]["userid"].", ".$tmp_domain["sys_groupid"].", 'riud', 'riud', '', ".$app->functions->intval($this->dataRecord["server_id"]).", 5, ".$app->functions->intval($policy_id).", '@".$app->db->quote($this->dataRecord["domain"])."', '@".$app->db->quote($this->dataRecord["domain"])."', 'Y')";
+				        VALUES (".$_SESSION["s"]["user"]["userid"].", ".$app->functions->intval($tmp_domain["sys_groupid"]).", 'riud', 'riud', '', ".$app->functions->intval($this->dataRecord["server_id"]).", 5, ".$app->functions->intval($policy_id).", '@".$app->db->quote($this->dataRecord["domain"])."', '@".$app->db->quote($this->dataRecord["domain"])."', 'Y')";
 				$app->db->datalogInsert('spamfilter_users', $insert_data, 'id');
 				unset($tmp_domain);
 			}
@@ -357,50 +329,7 @@ class page_action extends tform_actions {
 				$app->db->datalogDelete('spamfilter_users', 'id', $tmp_user["id"]);
 			}
 		} // endif spamfilter policy
-		//** If the domain name or owner has been changed, change the domain and owner in all mailbox records
-		if($this->oldDataRecord['domain'] != $this->dataRecord['domain'] || (isset($this->dataRecord['client_group_id']) && $this->oldDataRecord['sys_groupid'] != $this->dataRecord['client_group_id'])) {
-			$app->uses('getconf');
-			$mail_config = $app->getconf->get_server_config($this->dataRecord["server_id"], 'mail');
-
-			//* Update the mailboxes
-			$mailusers = $app->db->queryAllRecords("SELECT * FROM mail_user WHERE email like '%@".$app->db->quote($this->oldDataRecord['domain'])."'");
-			$sys_groupid = $app->functions->intval((isset($this->dataRecord['client_group_id']))?$this->dataRecord['client_group_id']:$this->oldDataRecord['sys_groupid']);
-			$tmp = $app->db->queryOneRecord("SELECT userid FROM sys_user WHERE default_group = $client_group_id");
-			$client_user_id = $app->functions->intval(($tmp['userid'] > 0)?$tmp['userid']:1);
-			if(is_array($mailusers)) {
-				foreach($mailusers as $rec) {
-					// setting Maildir, Homedir, UID and GID
-					$mail_parts = explode("@", $rec['email']);
-					$maildir = str_replace("[domain]", $this->dataRecord['domain'], $mail_config["maildir_path"]);
-					$maildir = str_replace("[localpart]", $mail_parts[0], $maildir);
-					$maildir = $app->db->quote($maildir);
-					$email = $app->db->quote($mail_parts[0].'@'.$this->dataRecord['domain']);
-					$app->db->datalogUpdate('mail_user', "maildir = '$maildir', email = '$email', sys_userid = $client_user_id, sys_groupid = '$sys_groupid'", 'mailuser_id', $rec['mailuser_id']);
-				}
-			}
-
-			//* Update the aliases
-			$forwardings = $app->db->queryAllRecords("SELECT * FROM mail_forwarding WHERE source like '%@".$app->db->quote($this->oldDataRecord['domain'])."' OR destination like '%@".$app->db->quote($this->oldDataRecord['domain'])."'");
-			if(is_array($forwardings)) {
-				foreach($forwardings as $rec) {
-					$destination = $app->db->quote(str_replace($this->oldDataRecord['domain'], $this->dataRecord['domain'], $rec['destination']));
-					$source = $app->db->quote(str_replace($this->oldDataRecord['domain'], $this->dataRecord['domain'], $rec['source']));
-					$app->db->datalogUpdate('mail_forwarding', "source = '$source', destination = '$destination', sys_userid = $client_user_id, sys_groupid = '$sys_groupid'", 'forwarding_id', $rec['forwarding_id']);
-				}
-			}
-
-			//* Update the mailinglist
-			$app->db->query("UPDATE mail_mailinglist SET sys_userid = $client_user_id, sys_groupid = $sys_groupid WHERE domain = '".$app->db->quote($this->oldDataRecord['domain'])."'");
-
-			//* Delete the old spamfilter record
-			$tmp = $app->db->queryOneRecord("SELECT id FROM spamfilter_users WHERE email = '@".$app->db->quote($this->oldDataRecord["domain"])."'");
-			$app->db->datalogDelete('spamfilter_users', 'id', $tmp["id"]);
-			unset($tmp);
-
-		} // end if domain name changed
-
 	}
-
 }
 
 $page = new page_action;
diff --git a/interface/web/sites/webdav_user_edit.php b/interface/web/sites/webdav_user_edit.php
index 97b2bcc8522a664abb62d6aebae52efe7e20114f..56b019c000e1d3344ba371794e5b395f6e5f9bf1 100644
--- a/interface/web/sites/webdav_user_edit.php
+++ b/interface/web/sites/webdav_user_edit.php
@@ -139,15 +139,6 @@ class page_action extends tform_actions {
 			 */
 			$hash = md5($this->dataRecord["username"] . ':' . $this->dataRecord["dir"] . ':' . $this->dataRecord["password"]);
 			$this->dataRecord["password"] = $hash;
-
-			/*
-			*  Get the data of the domain, owning the webdav user
-			*/
-			$web = $app->db->queryOneRecord("SELECT * FROM web_domain WHERE domain_id = ".$app->functions->intval($this->dataRecord["parent_domain_id"]));
-			/* The server is the server of the domain */
-			$this->dataRecord["server_id"] = $web["server_id"];
-			/* The Webdav user shall be owned by the same group then the website */
-			$this->dataRecord["sys_groupid"] = $web['sys_groupid'];
 		}
 
 		parent::onBeforeInsert();
@@ -155,6 +146,15 @@ class page_action extends tform_actions {
 
 	function onAfterInsert() {
 		global $app, $conf;
+
+		$web = $app->db->queryOneRecord("SELECT * FROM web_domain WHERE domain_id = ".$app->functions->intval($this->dataRecord["parent_domain_id"]));
+		$server_id = $app->functions->intval($web["server_id"]);
+
+		// The webdav user shall be owned by the same group then the website
+		$sys_groupid = $app->functions->intval($web['sys_groupid']);
+
+		$sql = "UPDATE webdav_user SET server_id = $server_id, sys_groupid = '$sys_groupid' WHERE webdav_user_id = ".$this->id;
+		$app->db->query($sql);
 	}
 
 	function onBeforeUpdate() {
@@ -184,6 +184,18 @@ class page_action extends tform_actions {
 
 	function onAfterUpdate() {
 		global $app, $conf;
+
+		//* When the site of the webdav user has been changed
+		if(isset($this->dataRecord['parent_domain_id']) && $this->oldDataRecord['parent_domain_id'] != $this->dataRecord['parent_domain_id']) {
+			$web = $app->db->queryOneRecord("SELECT * FROM web_domain WHERE domain_id = ".$app->functions->intval($this->dataRecord["parent_domain_id"]));
+			$server_id = $app->functions->intval($web["server_id"]);
+
+			// The webdav user shall be owned by the same group then the website
+			$sys_groupid = $app->functions->intval($web['sys_groupid']);
+
+			$sql = "UPDATE webdav_user SET server_id = $server_id, sys_groupid = '$sys_groupid' WHERE webdav_user_id = ".$this->id;
+			$app->db->query($sql);
+		}
 	}
 
 }