@@ -104,11 +104,12 @@ function update($event_name,$data) {
104104 exec ("chmod 770 " .$ this ->mailfilter_config_dir .'/ ' .$ email_parts [1 ].'/ ' .$ email_parts [0 ]);
105105 }
106106
107-
108107 // Check if something has been changed regarding the autoresponders
109108 if ($ data ["old " ]["autoresponder_text " ] != $ data ["new " ]["autoresponder_text " ]
110109 or $ data ["old " ]["autoresponder " ] != $ data ["new " ]["autoresponder " ]
111- or (isset ($ data ["new " ]["email " ]) and $ data ["old " ]["email " ] != $ data ["new " ]["email " ])) {
110+ or (isset ($ data ["new " ]["email " ]) and $ data ["old " ]["email " ] != $ data ["new " ]["email " ])
111+ or $ data ["old " ]["autoresponder_start_date " ] != $ data ["new " ]["autoresponder_start_date " ]
112+ or $ data ["old " ]["autoresponder_end_date " ] != $ data ["new " ]["autoresponder_end_date " ]) {
112113
113114 // We delete the old autoresponder, if it exists
114115 $ email_parts = explode ("@ " ,$ data ["old " ]["email " ]);
@@ -123,8 +124,9 @@ function update($event_name,$data) {
123124 $ file = $ this ->mailfilter_config_dir .'/ ' .$ email_parts [1 ].'/ ' .$ email_parts [0 ].'/.vacation.msg ' ;
124125 if (is_file ($ file )) unlink ($ file ) or $ app ->log ("Unable to delete file: $ file " ,LOGLEVEL_WARN );
125126 $ file = $ this ->mailfilter_config_dir .'/ ' .$ email_parts [1 ].'/ ' .$ email_parts [0 ].'/.autoresponder ' ;
126- if (is_file ($ file )) unlink ($ file ) or $ app ->log ("Unable to delete file: $ file " ,LOGLEVEL_WARN );
127-
127+ if (is_file ($ file )) unlink ($ ar_file ) or $ app ->log ("Unable to delete file: $ ar_file " ,LOGLEVEL_WARN );
128+
129+
128130 //Now we create the new autoresponder, if it is enabled
129131 if ($ data ["new " ]["autoresponder " ] == 'y ' ) {
130132 if (isset ($ data ["new " ]["email " ])) {
@@ -136,6 +138,15 @@ function update($event_name,$data) {
136138 // Load the master template
137139 $ tpl = file_get_contents ($ conf ["rootpath " ].'/conf/autoresponder.master ' );
138140 $ tpl = str_replace ('{vmail_mailbox_base} ' ,$ mail_config ["homedir_path " ],$ tpl );
141+
142+ if ($ data ["new " ]["autoresponder_start_date " ] != '0000-00-00 00:00:00 ' ) { // Dates have been set
143+ $ tpl = str_replace ('{start_date} ' ,strtotime ($ data ["new " ]["autoresponder_start_date " ]),$ tpl );
144+ $ tpl = str_replace ('{end_date} ' ,strtotime ($ data ["new " ]["autoresponder_end_date " ]),$ tpl );
145+ } else {
146+ $ tpl = str_replace ('{start_date} ' ,-7200 ,$ tpl );
147+ $ tpl = str_replace ('{end_date} ' ,2147464800 ,$ tpl );
148+ }
149+
139150 // Write the config file.
140151 $ config_file_path = $ this ->mailfilter_config_dir .'/ ' .$ email_parts [1 ].'/ ' .$ email_parts [0 ].'/.autoresponder ' ;
141152 file_put_contents ($ config_file_path ,$ tpl );
0 commit comments