From fe11e42178ec8055beae832627284eb7db937551 Mon Sep 17 00:00:00 2001
From: tbrehm <t.brehm@ispconfig.org>
Date: Fri, 01 Aug 2008 14:09:28 -0400
Subject: [PATCH] Bugfix: Custom rules field not emptied when a custom mail filter is deleted.

---
 interface/web/mail/mail_user_filter_del.php |   36 ++++++++++++++++++++++++++++++++++--
 1 files changed, 34 insertions(+), 2 deletions(-)

diff --git a/interface/web/mail/mail_user_filter_del.php b/interface/web/mail/mail_user_filter_del.php
index ef033fc..dac44ae 100644
--- a/interface/web/mail/mail_user_filter_del.php
+++ b/interface/web/mail/mail_user_filter_del.php
@@ -45,7 +45,39 @@
 //* Check permissions for module
 $app->auth->check_module_permissions('mail');
 
-$app->uses("tform_actions");
-$app->tform_actions->onDelete();
+// Loading classes
+$app->uses('tpl,tform,tform_actions');
+$app->load('tform_actions');
+
+class page_action extends tform_actions {
+	
+	function onAfterDelete() {
+		global $app, $conf;
+		
+		$mailuser = $app->db->queryOneRecord("SELECT custom_mailfilter FROM mail_user WHERE mailuser_id = ".$this->dataRecord["mailuser_id"]);
+		$skip = false;
+		$lines = explode("\n",$mailuser['custom_mailfilter']);
+		$out = '';
+		
+		foreach($lines as $line) {
+			$line = trim($line);
+			if($line == '### BEGIN FILTER_ID:'.$this->id) {
+				$skip = true;
+			}
+			if($skip == false && $line != '') $out .= $line ."\n";
+			if($line == '### END FILTER_ID:'.$this->id) {
+				$skip = false;
+			}
+		}
+		
+		$out = addslashes($out);
+		$app->db->datalogUpdate('mail_user', "custom_mailfilter = '$out'", 'mailuser_id', $this->dataRecord["mailuser_id"]);
+	
+	}
+	
+}
+
+$page = new page_action;
+$page->onDelete();
 
 ?>
\ No newline at end of file

--
Gitblit v1.9.1