trying maildrop
[old-projects.git] / philter / philter / include / plugin_header.inc.php
CommitLineData
ee524d70
PH
1<?php
2/********************************************************************************
3* include/plugin_header.inc.php : The class for Header Based Match
4* -----------------------------
5*
6* This file is part of the philter distribution
7* Copyright: See COPYING files that comes with this distribution
8********************************************************************************/
9
10class HdrPlugin extends MatchPlugin {
11 function HdrPlugin($glob) { $this->MatchPlugin(false); }
12 function rtti() { return 2; }
13 function name() { return _i18n('2_hdr'); }
14
15 function to_js() {
50f4c0cf
PH
16 $_2_dests = _i18n('2_dests');
17 $_2_contains = _i18n('2_contains');
18 $_2_not_contains = _i18n('2_not_contains');
27c46cc1
PH
19 return <<<EOF
20function(Node, data) {
ee524d70
PH
21 var i,j;
22 var sel = 0;
23
24 Node.appendChild(document.createTextNode(' '));
25
26 var hdr_s = document.createElement('select');
27 hdr_s.setAttribute('name', Node.name+'[1]');
28 Node.appendChild(hdr_s);
29
50f4c0cf 30 hdr_s.options[0] = new Option('<$_2_dests>',0,false,data[1]==0);
ee524d70
PH
31 hdr_s.options[1] = new Option('Subject:',1,false,data[1]==1);
32 hdr_s.options[2] = new Option('From:',2,false,data[1]==2);
33 hdr_s.options[3] = new Option('To:',3,false,data[1]==3);
34 hdr_s.options[4] = new Option('Cc:',4,false,data[1]==4);
35 hdr_s.options[5] = new Option('Reply-To:',5,false,data[1]==5);
36 hdr_s.options[6] = new Option('Organization:',6,false,data[1]==6);
37 hdr_s.options[7] = new Option('List-Id:',7,false,data[1]==7);
38 hdr_s.options[8] = new Option('X-Mailing-List:',8,false,data[1]==8);
ee524d70
PH
39 hdr_s.selectIndex = data[1];
40
f1abd4dd 41 Node.appendChild(document.createTextNode(' '));
ee524d70
PH
42 var op_s = document.createElement('select');
43 op_s.setAttribute('name', Node.name+'[2]');
44 Node.appendChild(op_s);
45
50f4c0cf
PH
46 op_s.options[0] = new Option('$_2_contains',0,false,data[2]==0);
47 op_s.options[1] = new Option('$_2_not_contains',1,false,data[2]==1);
ee524d70
PH
48 op_s.options[2] = new Option(' = ',2,false,data[2]==2);
49 op_s.options[3] = new Option(' != ',3,false,data[2]==3);
ee524d70
PH
50 op_s.selectIndex = data[2];
51
f1abd4dd 52 Node.appendChild(document.createTextNode(' '));
ee524d70
PH
53 var txt_i = document.createElement('input');
54 txt_i.setAttribute('type','text');
55 txt_i.setAttribute('name', Node.name+'[3]');
e20c62c3 56 txt_i.setAttribute('value', (data[3] ? data[3] : '') );
ee524d70 57 Node.appendChild(txt_i);
27c46cc1
PH
58}
59EOF;
ee524d70 60 }
ca052371
PH
61
62 function to_string($_data) {
63 switch($_data[1]) {
5534b9a9
PH
64 case 0:
65 $res = '^(^((Original-)?(Resent-)?(To|Cc|Bcc)|(X-Envelope|Apparently(-Resent)?)-To):(.*[^-a-zA-Z0-9_.])?)';
66 break;
ca052371
PH
67 case 1: $res = '^Subject:'; break;
68 case 2: $res = '^From:'; break;
69 case 3: $res = '^To:'; break;
70 case 4: $res = '^Cc:'; break;
71 case 5: $res = '^Reply-To:'; break;
72 case 6: $res = '^Organization:'; break;
73 case 7: $res = '^List-Id:'; break;
74 case 8: $res = '^X-Mailing-List:'; break;
75 }
76 switch($_data[2]) {
5534b9a9
PH
77 case 0: $res = "(/$res.*{$_data[3]}/:h)"; break;
78 case 1: $res = "!(/$res.*{$_data[3]}/:h)"; break;
79 case 2: $res = "(/$res {$_data[3]}$/:h)"; break;
80 case 3: $res = "!(/$res {$_data[3]}$/:h)"; break;
ca052371
PH
81 }
82 return $res;
83 }
ee524d70
PH
84}
85
86/********************************************************************************
87* $Id$
88* vim: set expandtab shiftwidth=4 tabstop=4 softtabstop=4 textwidth=100:
89********************************************************************************/
90?>