more modules
[old-projects.git] / philter / philter / include / plugin_autoreply.inc.php
index c1924aa..25a9788 100644 (file)
@@ -13,20 +13,32 @@ 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('cols', '74');\n"
-            .   "    ta.setAttribute('rows', '10');\n"
-            .   "    if(data[1]) ta.value = data[1];\n"
-            .   "\n"
-            .   "    Node.appendChild(document.createElement('br'));\n"
-            .   "    Node.appendChild(document.createTextNode('"._i18n('2_your_mail')."'));\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 = "    :0 hc\n"
+            .  "    * !^FROM_DAEMON\n"
+            .  "    * !^X-Philter-Autoreply: $uid\n"
+            .  "    | ( formail -rI'Precedence: junk' -A'X-Philter-Autoreply: $uid; \ \n";
+        foreach($text as $line)
+            $res .= "        echo ".escapeshellarg(chop($line))."; \ \n";
+        $res.= "      ) | $"."SENDMAIL -oi -t\n";
         return $res;
     }
 }