to_string basis
[old-projects.git] / philter / philter / include / rule.inc.php
index 5f1736d..dbb7b26 100644 (file)
@@ -89,13 +89,34 @@ class Rule {
     function to_string() {
         global $philter;
         
-        $res = ($this->block ? ":0\n" : ":0 c\n");
-        foreach($this->matches as $match)
-            $res .= $philter->config['match_plugins'][$match[0]]->to_string($match);
+        $res = $this->block  ? ":0\n" : ":0 c\n";
+
+        if($this->all) {
+            foreach($this->matches as $match)
+                $res .= $philter->config['match_plugins'][$match[0]]->to_string($match);
+        } else {
+            $i = 0; $res = '';
+            foreach($this->matches as $match) {
+                $res .= (empty($i) ? ":0 f\n" : ":0 fE");
+                $res .= $philter->config['match_plugins'][$match[0]]->to_string($match);
+                $res .= "| formail -I'X-Philter-Or: yes'\n";
+                $i++;
+            }
+
+            $res.= "\n"
+                .  ":0 f\n"
+                .  "* ^X-Philter-Or: yes\n"
+                .  "| formail -I'X-Philter-Or'\n"
+                .  "\n"
+                .  ($this->block ? ":0\n" : ":0 c\n");
+        }
+        
         $res.= "{\n";
         foreach($this->actions as $action)
-            $res .= $philter->config['actioh_plugins'][$action[0]]->to_string($action);
-        $res.= "}\n\n";
+            $res .= $philter->config['action_plugins'][$action[0]]->to_string($action);
+        $res.= "    :0\n"
+            .  "    /dev/null\n"
+            .  "}\n\n";
 
         return $res;
     }