adding a function : to_header_string -> filter to execute at the beginning
authorPierre Habouzit <madcoder@debian.org>
Mon, 22 Sep 2003 15:49:25 +0000 (15:49 +0000)
committerPierre Habouzit <madcoder@debian.org>
Mon, 22 Sep 2003 15:49:25 +0000 (15:49 +0000)
    of the procmailrc to avoid for example mail loops. do not implement if
    the action/match doesn't need it.
first implementation of autoreply

philter/philter/include/plugin.inc.php
philter/philter/include/plugin_autoreply.inc.php

index 71894c3..851cce4 100644 (file)
@@ -54,6 +54,8 @@ class Plugin {
      */
     function to_string($_data) { return ""; }
 
+    function to_header_string() { return ""; }
+
     /** returns the function that creates the form in javascript (@see FwdPlugin for one example).
      * @return  the string containing the javascript code
      */
index 4b12b29..cc517e0 100644 (file)
@@ -13,20 +13,36 @@ class AutoReplyPlugin extends ActionPlugin {
     function name() { return _i18n('2_auto_reply'); }
 
     function to_js() {
-        $res  = "function(Node, data) {\n"
-            .   "    var i,j;\n"
-            .   "    var ta = document.createElement('textarea');\n"
-            .   "    ta.setAttribute('name', Node.name+'[1]');\n"
-            .   "    ta.setAttribute('style', 'width:100%;');\n"
-            .   "    ta.setAttribute('rows', '10');\n"
-            .   "    if(data[1]) ta.value = data[1];\n"
-            .   "\n"
-            .   "    Node.appendChild(document.createElement('br'));\n"
-            .   "    Node.appendChild(ta);\n"
-            .   "}";
-
+        return <<<EOF
+function(Node, data) {
+    var i,j;
+    var ta = document.createElement('textarea');
+    ta.setAttribute('name', Node.name+'[1]');
+    ta.setAttribute('style', 'width:100%;');
+    ta.setAttribute('rows', '10');
+    if(data[1]) ta.value = data[1];
+            
+    Node.appendChild(document.createElement('br'));
+    Node.appendChild(ta);
+}
+EOF;
         return $res;
     }
+    
+    function to_string($_data) {
+        $uid = get_user_id();
+        $text = explode("\n",$_data[1]);
+        $res = "| ( formail -rA'X-Philter-Autoreply: $uid; \ \n";
+        foreach($text as $line)
+            $res .= "    echo ".escapeshellarg($line)."; \ \n";
+        $res .= " ) | $"."SENDMAIL -oi -t\n";
+    }
+
+    function to_header_string() {
+        return "* ^X-Philter-Autoreply:".get_user_id()."\n"
+            .  "/dev/null\n"
+            .  "\n";
+    }
 }
 
 /********************************************************************************