tbrehm
2009-10-28 c2f53e76fde1ab534e67a9227d4f0adcde05dfa4
server/plugins-available/maildrop_plugin.inc.php
@@ -36,6 +36,19 @@
   
   var $mailfilter_config_dir = '';
   
   //* This function is called during ispconfig installation to determine
   //  if a symlink shall be created for this plugin.
   function onInstall() {
      global $conf;
      if($conf['services']['mail'] == true) {
         return true;
      } else {
         return false;
      }
   }
   /*
       This function is called when the plugin is loaded
   */
@@ -103,6 +116,10 @@
         if(is_file($file)) unlink($file) or $app->log("Unable to delete file: $file",LOGLEVEL_WARN);
         $file = $this->mailfilter_config_dir.'/'.$email_parts[1].'/'.$email_parts[0].'/.vacation.lst';
         if(is_file($file)) unlink($file) or $app->log("Unable to delete file: $file",LOGLEVEL_WARN);
         $file = $this->mailfilter_config_dir.'/'.$email_parts[1].'/'.$email_parts[0].'/.vacation.lst.gdbm';
         if(is_file($file)) unlink($file) or $app->log("Unable to delete file: $file",LOGLEVEL_WARN);
         $file = $this->mailfilter_config_dir.'/'.$email_parts[1].'/'.$email_parts[0].'/.vacation.lst.lock';
         if(is_file($file)) unlink($file) or $app->log("Unable to delete file: $file",LOGLEVEL_WARN);
         $file = $this->mailfilter_config_dir.'/'.$email_parts[1].'/'.$email_parts[0].'/.vacation.msg';
         if(is_file($file)) unlink($file) or $app->log("Unable to delete file: $file",LOGLEVEL_WARN);
         $file = $this->mailfilter_config_dir.'/'.$email_parts[1].'/'.$email_parts[0].'/.autoresponder';
@@ -137,12 +154,11 @@
         }
      }
         
         $app->log("HERE",LOGLEVEL_DEBUG);
         // 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"]) != '') {
            if(trim($data["new"]["custom_mailfilter"]) != '' or $data["new"]["move_junk"] != 'n') {
               // Delete the old filter recipe
               $email_parts = explode("@",$data["old"]["email"]);
               $file = $this->mailfilter_config_dir.'/'.$email_parts[1].'/'.$email_parts[0].'/.mailfilter';
@@ -155,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");