Commit | Line | Data |
---|---|---|
dd8de1ec PH |
1 | <?php |
2 | /******************************************************************************** | |
3 | * index.php : index page | |
4 | * --------- | |
5 | * | |
6 | * This file is part of the philter distribution | |
7 | * Copyright: See COPYING files that comes with this distribution | |
8 | ********************************************************************************/ | |
9 | ||
10 | require("include/header.inc.php"); | |
11 | require("include/philter.inc.php"); | |
12 | require("include/config.inc.php"); | |
13 | ||
14 | $mail_pool = new EmailPool(get_user_id()); | |
15 | $filter = new Filter(get_user_id()); | |
16 | ||
17 | if(count($_POST)) { // a FORM has been submitted | |
18 | if(isset($_POST['emails'])) // FORM emails | |
19 | if(!$mail_pool->handle_form()) | |
20 | echo "<p style=\"color:red;\">".$philter->error()."</p>\n"; | |
21 | ||
22 | if(!empty($_POST['order']['action'])) // FORM order | |
23 | if($_POST['order']['action']=='submit') { | |
24 | foreach($filter->rules as $id=>$rule) | |
25 | if(isset($_POST['order'][$id])) | |
26 | $filter->rules[$id]->move_to($_POST['order'][$id], $filter->uid, $id); | |
27 | uasort($filter->rules, 'rule_cmp'); | |
28 | } elseif($_POST['order']['action']=='delete' && !empty($_POST['order']['select'])) { | |
29 | $filter->delete_rule($_POST['order']['select']); | |
30 | $_POST['order']['select'] = min(count($filter->rules),$_POST['order']['select']); | |
31 | } | |
32 | ||
33 | if(!empty($_POST['rule'])) // FORM rule | |
34 | if(!$filter->handle_form()) | |
35 | echo "<p style=\"color:red;\">".$philter->error()."</p>\n"; | |
36 | } | |
37 | ||
38 | require("include/js_factory.inc.php"); | |
39 | ||
40 | /********** globals plugins **********/ | |
41 | ||
42 | if(count($philter->config['global_plugin'])) { | |
43 | echo "<tr><td>\n" | |
44 | ."<form action=\"{$_SERVER['REQUEST_URI']}\" method=\"post\">\n" | |
45 | ."<table width=\"100%\">\n" | |
46 | ."<tr><th>Global rules</th></tr>"; | |
47 | ||
48 | foreach($philter->config['global_plugin'] as $g_plugin) { | |
49 | echo "<tr><td>\n"; | |
50 | echo $g_plugin->to_form(/* data */); | |
51 | echo "</td></tr>\n"; | |
52 | ||
53 | } | |
54 | ||
55 | echo "</table>\n" | |
56 | ."</form>\n"; | |
57 | } | |
58 | ||
59 | /********** emails **********/ | |
60 | ?> | |
61 | ||
62 | <table width="100%"> | |
63 | <tr><th>Emails pool</th></tr> | |
64 | <tr><td> | |
65 | <?php | |
66 | echo $mail_pool->to_form(); | |
67 | ||
68 | echo "</td></tr>\n</table>\n"; | |
69 | ||
70 | /********** filters **********/ | |
71 | ?> | |
72 | ||
73 | <table width="100%"> | |
74 | <tr><th colspan="2">Filtering rules</th></tr> | |
75 | <tr><td width="25%" valign="top"> | |
693b6ec6 | 76 | <form action="<?php echo $_SERVER['REQUEST_URI']?>" method="post" id="order" name="order" onsubmit="return false;"> |
dd8de1ec PH |
77 | <table width="100%"> |
78 | <tr><td> | |
79 | <?php | |
80 | foreach($filter->rules as $id=>$rule) | |
693b6ec6 | 81 | echo "<input type=\"hidden\" id=\"order[$id]\" name=\"order[$id]\" value=\"{$rule->rank}\" />\n"; |
dd8de1ec PH |
82 | |
83 | $presel = (isset($_POST['rule']['id']) ? $_POST['rule']['id'] | |
84 | : (isset($_POST['order']['select']) ? $_POST['order']['select'] : 0)); | |
85 | ||
693b6ec6 | 86 | echo "<select size=\"16\" id=\"order[select]\" name=\"order[select]\" onchange=\"createRuleForm()\">\n"; |
dd8de1ec PH |
87 | echo "<option value=\"0\" ".($presel ? "" : " selected=\"selected\"") |
88 | .">[ new rule ]</option>\n"; | |
89 | ||
90 | foreach($filter->rules as $id=>$rule) | |
91 | echo "<option value=\"$id\"" | |
92 | .($presel==$id ? " selected=\"selected\"":"") | |
93 | .">{$rule->name}</option>\n"; | |
94 | ?> | |
95 | </select> | |
96 | </td></tr><tr><td> | |
97 | <input type="submit" value="Up" name="order[up]" onclick="order_up();" /> | |
98 | <input type="submit" value="Down" name="order[dn]" onclick="order_dn();" /> | |
99 | <input type="submit" value="Delete" name="order[delete]" onclick="order_submit(this)" /> | |
100 | <input type="submit" value="Submit" name="order[submit]" onclick="order_submit(this)" /> | |
101 | <input type="hidden" value="" name="order[action]" /> | |
102 | </td></tr> | |
103 | </table> | |
104 | </form> | |
105 | </td> | |
106 | <td valign="top"> | |
693b6ec6 | 107 | <form action="<?php echo $_SERVER['REQUEST_URI']?>" method="post" id="rule" name="rule" onsubmit="return false;"> |
dd8de1ec PH |
108 | <table width="100%"> |
109 | <tr><th>Rule Configuration | |
110 | </th></tr><tr><td> | |
693b6ec6 | 111 | <input type="hidden" value="0" id="rule[id]" name="rule[id]" /> |
dd8de1ec | 112 | Name of this rule : |
693b6ec6 | 113 | <input type="text" size="60" value="" id="rule[name]" name="rule[name]" |
dd8de1ec PH |
114 | onfocus="text_onfocus(this,'[ new rule ]')" onblur="text_onblur(this,'[ new rule ]')" /> |
115 | <br /> | |
693b6ec6 PH |
116 | <input type="radio" value="1" id="rule[all1]" name="rule[all]">All matches</input> |
117 | <input type="radio" value="0" id="rule[all0]" name="rule[all]">One match</input> | |
dd8de1ec | 118 | <br /> |
693b6ec6 | 119 | <input type="checkbox" checked="checked" id="rule[block]" name="rule[block]">Blocking Rule</input> |
dd8de1ec | 120 | </td></tr><tr><th>Matches List |
693b6ec6 | 121 | </th></tr><tr><td id="matchesRow" name="matches_row"> |
dd8de1ec | 122 | </td></tr><tr><th>Actions List |
693b6ec6 | 123 | </th></tr><tr><td id="actionsRow" name="actions_row"> |
dd8de1ec PH |
124 | </td></tr><tr><td> |
125 | <input type="submit" value="New Match" name="rule[new_match]" onclick="newMatch() "/> | |
126 | <input type="submit" value="New Action" name="rule[new_action]" onclick="newAction()" /> | |
127 | <input type="submit" value="Submit" name="rule[submit]" onclick="this.form.submit()" /> | |
128 | </td></tr> | |
129 | </table> | |
130 | </form> | |
131 | </td> | |
132 | </tr> | |
133 | </table> | |
134 | ||
135 | <script type="text/javascript"> | |
136 | createRuleForm(); | |
137 | </script> | |
138 | ||
139 | <?php | |
140 | /********** footer **********/ | |
141 | ||
142 | require("include/footer.inc.php"); | |
143 | ||
144 | /******************************************************************************** | |
145 | * $id: header.inc.php,v 1.2 2003/08/03 16:02:41 madcoder exp $ | |
146 | * vim: set expandtab shiftwidth=4 tabstop=4 softtabstop=4 textwidth=100: | |
147 | ********************************************************************************/ | |
148 | ?> |