From 95ed0d3ceb9e98749a635327ff220f034dc3c7bb Mon Sep 17 00:00:00 2001
From: tbrehm <t.brehm@ispconfig.org>
Date: Thu, 28 Jan 2010 06:33:07 -0500
Subject: [PATCH] Fixed: FS#959 - Changeing email alias

---
 interface/web/mail/mail_user_edit.php |   14 ++++++++++++++
 1 files changed, 14 insertions(+), 0 deletions(-)

diff --git a/interface/web/mail/mail_user_edit.php b/interface/web/mail/mail_user_edit.php
index 50683ee..02b1f94 100644
--- a/interface/web/mail/mail_user_edit.php
+++ b/interface/web/mail/mail_user_edit.php
@@ -303,6 +303,20 @@
 			$app->db->query($sql);
 		}
 		
+		//** If the email address has been changed, change it in all aliases too
+		if($this->oldDataRecord['email'] != $this->dataRecord['email']) {
+			
+			//* Update the aliases
+			$forwardings = $app->db->queryAllRecords("SELECT * FROM mail_forwarding WHERE destination = '".$app->db->quote($this->oldDataRecord['email'])."'");
+			if(is_array($forwardings)) {
+				foreach($forwardings as $rec) {
+					$destination = $app->db->quote($this->dataRecord['email']);
+					$app->db->datalogUpdate('mail_forwarding', "destination = '$destination'", 'forwarding_id', $rec['forwarding_id']);
+				}
+			}
+			
+		} // end if email addess changed
+		
 	}
 	
 }

--
Gitblit v1.9.1