more modules
[old-projects.git] / philter / philter / include / plugin_autoreply.inc.php
1 <?php
2 /********************************************************************************
3 * include/plugin_autoreply.inc.php : The class for auto-replies
4 * --------------------------------
5 *
6 * This file is part of the philter distribution
7 * Copyright: See COPYING files that comes with this distribution
8 ********************************************************************************/
9
10 class AutoReplyPlugin extends ActionPlugin {
11 function FwdPlugin() { $this->ActionPlugin(); }
12 function rtti() { return 2; }
13 function name() { return _i18n('2_auto_reply'); }
14
15 function to_js() {
16 return <<<EOF
17 function(Node, data) {
18 var i,j;
19 var ta = document.createElement('textarea');
20 ta.setAttribute('name', Node.name+'[1]');
21 ta.setAttribute('style', 'width:100%;');
22 ta.setAttribute('rows', '10');
23 if(data[1]) ta.value = data[1];
24
25 Node.appendChild(document.createElement('br'));
26 Node.appendChild(ta);
27 }
28 EOF;
29 return $res;
30 }
31
32 function to_string($_data) {
33 $uid = get_user_id();
34 $text = explode("\n",$_data[1]);
35 $res = " :0 hc\n"
36 . " * !^FROM_DAEMON\n"
37 . " * !^X-Philter-Autoreply: $uid\n"
38 . " | ( formail -rI'Precedence: junk' -A'X-Philter-Autoreply: $uid; \ \n";
39 foreach($text as $line)
40 $res .= " echo ".escapeshellarg(chop($line))."; \ \n";
41 $res.= " ) | $"."SENDMAIL -oi -t\n";
42 return $res;
43 }
44 }
45
46 /********************************************************************************
47 * $Id$
48 * vim: set expandtab shiftwidth=4 tabstop=4 softtabstop=4 textwidth=100:
49 ********************************************************************************/
50 ?>