From 5619c7dd99b674af0922e29ccfd00d58a08979c5 Mon Sep 17 00:00:00 2001
From: tbrehm <t.brehm@ispconfig.org>
Date: Thu, 15 Jul 2010 08:36:47 -0400
Subject: [PATCH] Fixed: FS#1229 - ISPConfig3 creates the desired e-mail domain twice (on master server AND on the selected Slave) 

---
 install/tpl/mysql-virtual_domains.cf.master            |    2 +-
 install/tpl/mysql-virtual_forwardings.cf.master        |    2 +-
 install/tpl/mysql-virtual_mailboxes.cf.master          |    2 +-
 server/lib/classes/modules.inc.php                     |    9 +++++++++
 install/tpl/mysql-virtual_sender.cf.master             |    2 +-
 install/tpl/mysql-virtual_transports.cf.master         |    2 +-
 install/tpl/mysql-virtual_recipient.cf.master          |    2 +-
 install/tpl/mysql-virtual_relayrecipientmaps.cf.master |    2 +-
 install/tpl/mysql-virtual_email2email.cf.master        |    2 +-
 install/tpl/mysql-virtual_relaydomains.cf.master       |    2 +-
 10 files changed, 18 insertions(+), 9 deletions(-)

diff --git a/install/tpl/mysql-virtual_domains.cf.master b/install/tpl/mysql-virtual_domains.cf.master
index 729c677..5b71142 100644
--- a/install/tpl/mysql-virtual_domains.cf.master
+++ b/install/tpl/mysql-virtual_domains.cf.master
@@ -4,5 +4,5 @@
 table = mail_domain
 select_field = domain
 where_field = domain
-additional_conditions = and active = 'y'
+additional_conditions = and active = 'y' and server_id = {server_id}
 hosts = {mysql_server_ip}
\ No newline at end of file
diff --git a/install/tpl/mysql-virtual_email2email.cf.master b/install/tpl/mysql-virtual_email2email.cf.master
index 1e19591..e18ef24 100644
--- a/install/tpl/mysql-virtual_email2email.cf.master
+++ b/install/tpl/mysql-virtual_email2email.cf.master
@@ -4,5 +4,5 @@
 table = mail_user
 select_field = email
 where_field = email
-additional_conditions = and postfix = 'y'
+additional_conditions = and postfix = 'y' and server_id = {server_id}
 hosts = {mysql_server_ip}
\ No newline at end of file
diff --git a/install/tpl/mysql-virtual_forwardings.cf.master b/install/tpl/mysql-virtual_forwardings.cf.master
index 01281e3..b3f3325 100644
--- a/install/tpl/mysql-virtual_forwardings.cf.master
+++ b/install/tpl/mysql-virtual_forwardings.cf.master
@@ -4,5 +4,5 @@
 table = mail_forwarding
 select_field = destination
 where_field = source
-additional_conditions = and active = 'y'
+additional_conditions = and active = 'y' and server_id = {server_id}
 hosts = {mysql_server_ip}
\ No newline at end of file
diff --git a/install/tpl/mysql-virtual_mailboxes.cf.master b/install/tpl/mysql-virtual_mailboxes.cf.master
index 570f069..d013c34 100644
--- a/install/tpl/mysql-virtual_mailboxes.cf.master
+++ b/install/tpl/mysql-virtual_mailboxes.cf.master
@@ -4,5 +4,5 @@
 table = mail_user
 select_field = CONCAT(SUBSTRING_INDEX(email,'@',-1),'/',SUBSTRING_INDEX(email,'@',1),'/')
 where_field = email
-additional_conditions = and postfix = 'y'
+additional_conditions = and postfix = 'y' and server_id = {server_id}
 hosts = {mysql_server_ip}
\ No newline at end of file
diff --git a/install/tpl/mysql-virtual_recipient.cf.master b/install/tpl/mysql-virtual_recipient.cf.master
index 254cfe5..49024f3 100644
--- a/install/tpl/mysql-virtual_recipient.cf.master
+++ b/install/tpl/mysql-virtual_recipient.cf.master
@@ -4,5 +4,5 @@
 table        = mail_access
 select_field = access
 where_field  = source
-additional_conditions = and type = 'recipient' and active = 'y'
+additional_conditions = and type = 'recipient' and active = 'y' and server_id = {server_id}
 hosts = {mysql_server_ip}
\ No newline at end of file
diff --git a/install/tpl/mysql-virtual_relaydomains.cf.master b/install/tpl/mysql-virtual_relaydomains.cf.master
index 0856467..fb7bec1 100644
--- a/install/tpl/mysql-virtual_relaydomains.cf.master
+++ b/install/tpl/mysql-virtual_relaydomains.cf.master
@@ -4,5 +4,5 @@
 table = mail_transport
 select_field = domain
 where_field = domain
-additional_conditions = and active = 'y'
+additional_conditions = and active = 'y' and server_id = {server_id}
 hosts = {mysql_server_ip}
\ No newline at end of file
diff --git a/install/tpl/mysql-virtual_relayrecipientmaps.cf.master b/install/tpl/mysql-virtual_relayrecipientmaps.cf.master
index 4822f3b..a6304fe 100644
--- a/install/tpl/mysql-virtual_relayrecipientmaps.cf.master
+++ b/install/tpl/mysql-virtual_relayrecipientmaps.cf.master
@@ -4,5 +4,5 @@
 table = mail_relay_recipient
 select_field = access
 where_field = source
-additional_conditions = and active = 'y'
+additional_conditions = and active = 'y' and server_id = {server_id}
 hosts = {mysql_server_ip}
\ No newline at end of file
diff --git a/install/tpl/mysql-virtual_sender.cf.master b/install/tpl/mysql-virtual_sender.cf.master
index 7531451..0ef634a 100644
--- a/install/tpl/mysql-virtual_sender.cf.master
+++ b/install/tpl/mysql-virtual_sender.cf.master
@@ -4,5 +4,5 @@
 table        = mail_access
 select_field = access
 where_field  = source
-additional_conditions = and type = 'sender' and active = 'y'
+additional_conditions = and type = 'sender' and active = 'y' and server_id = {server_id}
 hosts = {mysql_server_ip}
\ No newline at end of file
diff --git a/install/tpl/mysql-virtual_transports.cf.master b/install/tpl/mysql-virtual_transports.cf.master
index 0040d1d..048a7a8 100644
--- a/install/tpl/mysql-virtual_transports.cf.master
+++ b/install/tpl/mysql-virtual_transports.cf.master
@@ -4,5 +4,5 @@
 table = mail_transport
 select_field = transport
 where_field = domain
-additional_conditions = and active = 'y'
+additional_conditions = and active = 'y' and server_id = {server_id}
 hosts = {mysql_server_ip}
\ No newline at end of file
diff --git a/server/lib/classes/modules.inc.php b/server/lib/classes/modules.inc.php
index 408f4d3..ed855b8 100644
--- a/server/lib/classes/modules.inc.php
+++ b/server/lib/classes/modules.inc.php
@@ -109,6 +109,15 @@
 				
 				$this->current_datalog_id = $d["datalog_id"];
 				
+				/*
+				* If we are in a mirror setup, rewrite the server_id of records that originally 
+				* belonged to the mirrored server to the local server_id
+				*/
+				if($conf["mirror_server_id"] > 0 && $d['dbtable'] != 'server') {
+					if(isset($data['new']['server_id']) && $data['new']['server_id'] == $conf["mirror_server_id"]) $data['new']['server_id'] = $conf["server_id"];
+					if(isset($data['old']['server_id']) && $data['old']['server_id'] == $conf["mirror_server_id"]) $data['old']['server_id'] = $conf["server_id"];
+				}
+				
 				if(count($data['new']) > 0) {
 					if($d["action"] == 'i' || $d["action"] == 'u') {
 						$idx = explode(":",$d["dbidx"]);

--
Gitblit v1.9.1