@@ -155,7 +155,8 @@ function update($event_name,$data) {
155155 }
156156
157157 // Write the custom mailfilter script, if mailfilter recipe has changed
158- if ($ data ["old " ]["custom_mailfilter " ] != $ data ["new " ]["custom_mailfilter " ]) {
158+ if ($ data ["old " ]["custom_mailfilter " ] != $ data ["new " ]["custom_mailfilter " ] or
159+ $ data ["old " ]["move_junk " ] != $ data ["new " ]["move_junk " ]) {
159160 $ app ->log ("Mailfilter config has been changed " ,LOGLEVEL_DEBUG );
160161 if (trim ($ data ["new " ]["custom_mailfilter " ]) != '' ) {
161162 // Delete the old filter recipe
@@ -170,7 +171,14 @@ function update($event_name,$data) {
170171 $ email_parts = explode ("@ " ,$ data ["old " ]["email " ]);
171172 }
172173 $ config_file_path = $ this ->mailfilter_config_dir .'/ ' .$ email_parts [1 ].'/ ' .$ email_parts [0 ].'/.mailfilter ' ;
173- file_put_contents ($ config_file_path ,$ data ["new " ]["custom_mailfilter " ]);
174+
175+ $ mailfilter_content = '' ;
176+ if ($ data ["new " ]["move_junk " ] == 'y ' ) {
177+ $ mailfilter_content .= file_get_contents ($ conf ["rootpath " ].'/conf/mailfilter_move_junk.master ' )."\n" ;
178+ }
179+ $ mailfilter_content .= $ data ["new " ]["custom_mailfilter " ];
180+
181+ file_put_contents ($ config_file_path ,$ mailfilter_content );
174182 $ app ->log ("Writing new custom Mailfiter " .$ config_file_path ,LOGLEVEL_DEBUG );
175183 exec ("chmod 770 $ config_file_path " );
176184 exec ("chown vmail $ config_file_path " );
0 commit comments