custom header plugin header plugin bugfix : undefined was as a value when
authorPierre Habouzit <madcoder@debian.org>
Fri, 12 Sep 2003 07:37:56 +0000 (07:37 +0000)
committerPierre Habouzit <madcoder@debian.org>
Fri, 12 Sep 2003 07:37:56 +0000 (07:37 +0000)
    data[3] was null

philter/philter/include/plugin_custheader.inc.php [new file with mode: 0644]
philter/philter/include/plugin_header.inc.php
philter/philter/install.d/config.inc.php
philter/philter/locales/plugins/custheader.en.inc.php [new file with mode: 0644]
philter/philter/locales/plugins/custheader.fr.inc.php [new file with mode: 0644]

diff --git a/philter/philter/include/plugin_custheader.inc.php b/philter/philter/include/plugin_custheader.inc.php
new file mode 100644 (file)
index 0000000..ca179ba
--- /dev/null
@@ -0,0 +1,57 @@
+<?php
+/********************************************************************************
+* include/plugin_custheader.inc.php : The class for Custom Header Based Match
+* ---------------------------------
+*
+* This file is part of the philter distribution
+* Copyright: See COPYING files that comes with this distribution
+********************************************************************************/
+
+class CustHdrPlugin extends MatchPlugin {
+    function HdrPlugin($glob) { $this->MatchPlugin(false); }
+    function rtti() { return 3; }
+    function name() { return _i18n('3_cust_hdr'); }
+
+    function to_js() {
+        return
+"function(Node, data) {
+    var i,j;
+    var sel = 0;
+    
+    Node.appendChild(document.createTextNode(' '));
+    var txt_i = document.createElement('input');
+    txt_i.setAttribute('type','text');
+    txt_i.setAttribute('name', Node.name+'[1]');
+    txt_i.setAttribute('value', (data[1] ? data[1] :'') );
+    Node.appendChild(txt_i);
+    
+    Node.appendChild(document.createTextNode(' '));
+    var op_s = document.createElement('select');
+    op_s.setAttribute('name', Node.name+'[2]');
+    Node.appendChild(op_s);
+
+    op_s.options[0] = new Option('"._i18n('3_contains')."',0,false,data[2]==0);
+    op_s.options[1] = new Option('"._i18n('3_not_contains')."',1,false,data[2]==1);
+    op_s.options[2] = new Option(' = ',2,false,data[2]==2);
+    op_s.options[3] = new Option(' != ',3,false,data[2]==3);
+    op_s.options[4] = new Option(' >= ',4,false,data[2]==4);
+    op_s.options[5] = new Option(' > ',5,false,data[2]==5);
+    op_s.options[6] = new Option(' <= ',6,false,data[2]==6);
+    op_s.options[7] = new Option(' < ',7,false,data[2]==7);
+    op_s.selectIndex = data[2];
+
+    Node.appendChild(document.createTextNode(' '));
+    var txt_i = document.createElement('input');
+    txt_i.setAttribute('type','text');
+    txt_i.setAttribute('name', Node.name+'[3]');
+    txt_i.setAttribute('value', (data[3] ? data[3] : '') );
+    Node.appendChild(txt_i);
+}";
+    }
+}
+
+/********************************************************************************
+* $Id$
+* vim: set expandtab shiftwidth=4 tabstop=4 softtabstop=4 textwidth=100:
+********************************************************************************/
+?>
index 96dad0f..8b044c5 100644 (file)
@@ -55,7 +55,7 @@ class HdrPlugin extends MatchPlugin {
     var txt_i = document.createElement('input');
     txt_i.setAttribute('type','text');
     txt_i.setAttribute('name', Node.name+'[3]');
-    txt_i.setAttribute('value', data[3]);
+    txt_i.setAttribute('value', (data[3] ? data[3] : '') );
     Node.appendChild(txt_i);
 }";
     }
index bad906d..622c835 100644 (file)
@@ -32,6 +32,7 @@ $philter->config['path']['spool']    = "/var/spool/philter";
 $philter->register_global_plugin(new BogoPlugin(true));
 
 $philter->register_plugin(new HdrPlugin(false));
+$philter->register_plugin(new CustHdrPlugin(false));
 
 $philter->register_plugin(new FwdPlugin());
 $philter->register_plugin(new AutoReplyPlugin());
diff --git a/philter/philter/locales/plugins/custheader.en.inc.php b/philter/philter/locales/plugins/custheader.en.inc.php
new file mode 100644 (file)
index 0000000..0903eb2
--- /dev/null
@@ -0,0 +1,17 @@
+<?php
+/********************************************************************************
+* i18n file
+*
+* This file is part of the philter distribution
+* Copyright: See COPYING files that comes with this distribution
+********************************************************************************/
+
+$philter->config['i18n']['3_cust_hdr'] = 'Custom Header';
+$philter->config['i18n']['3_contains'] = 'contains';
+$philter->config['i18n']['3_not_contains'] = 'contains not';
+
+/********************************************************************************
+* $Id$
+* vim: set expandtab shiftwidth=4 tabstop=4 softtabstop=4 textwidth=100:
+********************************************************************************/
+?>
diff --git a/philter/philter/locales/plugins/custheader.fr.inc.php b/philter/philter/locales/plugins/custheader.fr.inc.php
new file mode 100644 (file)
index 0000000..965f11f
--- /dev/null
@@ -0,0 +1,17 @@
+<?php
+/********************************************************************************
+* i18n file
+*
+* This file is part of the philter distribution
+* Copyright: See COPYING files that comes with this distribution
+********************************************************************************/
+
+$philter->config['i18n']['3_hdr'] = 'EntĂȘte Perso.';
+$philter->config['i18n']['3_contains'] = 'contient';
+$philter->config['i18n']['3_not_contains'] = 'ne contient pas';
+
+/********************************************************************************
+* $Id$
+* vim: set expandtab shiftwidth=4 tabstop=4 softtabstop=4 textwidth=100:
+********************************************************************************/
+?>