From b6108193aa434a0502261e4057a897344e465f94 Mon Sep 17 00:00:00 2001
From: tbrehm <t.brehm@ispconfig.org>
Date: Wed, 28 Oct 2009 13:51:18 -0400
Subject: [PATCH] Added: FS#873 - Option to redirect spam into a .Junk directory

---
 server/plugins-available/maildrop_plugin.inc.php |   12 ++++++++++--
 1 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/server/plugins-available/maildrop_plugin.inc.php b/server/plugins-available/maildrop_plugin.inc.php
index b748c0f..7b990c6 100644
--- a/server/plugins-available/maildrop_plugin.inc.php
+++ b/server/plugins-available/maildrop_plugin.inc.php
@@ -155,7 +155,8 @@
 		}
 			
 			// Write the custom mailfilter script, if mailfilter recipe has changed
-			if($data["old"]["custom_mailfilter"] != $data["new"]["custom_mailfilter"]) {
+			if($data["old"]["custom_mailfilter"] != $data["new"]["custom_mailfilter"] or
+			   $data["old"]["move_junk"] != $data["new"]["move_junk"]) {
 				$app->log("Mailfilter config has been changed",LOGLEVEL_DEBUG);
 				if(trim($data["new"]["custom_mailfilter"]) != '') {
 					// Delete the old filter recipe
@@ -170,7 +171,14 @@
 						$email_parts = explode("@",$data["old"]["email"]);
 					}
 					$config_file_path = $this->mailfilter_config_dir.'/'.$email_parts[1].'/'.$email_parts[0].'/.mailfilter';
-					file_put_contents($config_file_path,$data["new"]["custom_mailfilter"]);
+					
+					$mailfilter_content = '';
+					if($data["new"]["move_junk"] == 'y') {
+						$mailfilter_content .= file_get_contents($conf["rootpath"].'/conf/mailfilter_move_junk.master')."\n";
+					}
+					$mailfilter_content .= $data["new"]["custom_mailfilter"];
+					
+					file_put_contents($config_file_path,$mailfilter_content);
 					$app->log("Writing new custom Mailfiter".$config_file_path,LOGLEVEL_DEBUG);
 					exec("chmod 770 $config_file_path");
 					exec("chown vmail $config_file_path");

--
Gitblit v1.9.1