error message i18n handling
[old-projects.git] / philter / philter / index.php
CommitLineData
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
10require("include/header.inc.php");
11require("include/philter.inc.php");
12require("include/config.inc.php");
13
14$mail_pool = new EmailPool(get_user_id());
15$filter = new Filter(get_user_id());
16
17if(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
38require("include/js_factory.inc.php");
39
40/********** globals plugins **********/
86b5093c 41?>
5ae3e923 42<div class="rubrique"><?php i18n('global_title'); ?></div>
86b5093c 43<?php
0cff7bb6 44i18n('global_help');
dd8de1ec 45if(count($philter->config['global_plugin'])) {
242c14dc 46 echo "<form action=\"{$_SERVER['REQUEST_URI']}\" method=\"post\">\n"
86b5093c 47 ."<table width=\"95%\" class=\"bicol\" cellspacing=\"1\" cellpadding=\"1\" align=\"center\">\n";
dd8de1ec
PH
48
49 foreach($philter->config['global_plugin'] as $g_plugin) {
50 echo "<tr><td>\n";
51 echo $g_plugin->to_form(/* data */);
52 echo "</td></tr>\n";
53
54 }
55
56 echo "</table>\n"
57 ."</form>\n";
58}
59
60/********** emails **********/
61?>
86b5093c 62<br />
5ae3e923 63<div class="rubrique"><?php i18n('pool_title'); ?></div>
dd8de1ec 64<?php
0cff7bb6 65i18n('pool_help');
dd8de1ec
PH
66echo $mail_pool->to_form();
67
dd8de1ec
PH
68/********** filters **********/
69?>
70
86b5093c 71<br />
5ae3e923 72<div class="rubrique"><?php i18n('filter_title'); ?></div>
0cff7bb6
PH
73<?php
74i18n('filter_help');
75?>
86b5093c
PH
76<table width="95%" cellspacing="0" cellpadding="2" align="center">
77<tr><td width="25%" valign="top">
693b6ec6 78 <form action="<?php echo $_SERVER['REQUEST_URI']?>" method="post" id="order" name="order" onsubmit="return false;">
86b5093c 79 <table class="bicol" width="100%" cellpadding="1" cellspacing="1">
5ae3e923 80 <tr><th><?php i18n('filter_list_title');?></th></tr>
dd8de1ec
PH
81 <tr><td>
82<?php
83 foreach($filter->rules as $id=>$rule)
242c14dc 84 echo "<input type=\"hidden\" id=\"order$id\" name=\"order[$id]\" value=\"{$rule->rank}\" />\n";
dd8de1ec
PH
85
86 $presel = (isset($_POST['rule']['id']) ? $_POST['rule']['id']
87 : (isset($_POST['order']['select']) ? $_POST['order']['select'] : 0));
88
602a1c49 89 echo "<select size=\"16\" style=\"width:100%;\" id=\"orderSelect\" name=\"order[select]\" onchange=\"createRuleForm()\">\n";
5ae3e923
PH
90 echo "<option value=\"0\" ".($presel ? "" : " selected=\"selected\"").">";
91 i18n('new_rule');
92 echo "</option>\n";
dd8de1ec
PH
93
94 foreach($filter->rules as $id=>$rule)
95 echo "<option value=\"$id\""
96 .($presel==$id ? " selected=\"selected\"":"")
97 .">{$rule->name}</option>\n";
98?>
99 </select>
100 </td></tr><tr><td>
5ae3e923
PH
101 <input type="submit" value="<?php i18n('up');?>" name="order[up]" onclick="order_up();" />
102 <input type="submit" value="<?php i18n('dn');?>" name="order[dn]" onclick="order_dn();" /><br />
103 <input type="submit" value="<?php i18n('del');?>" name="order[delete]" onclick="order_submit(this)" />
104 <input type="submit" value="<?php i18n('submit');?>" name="order[submit]" onclick="order_submit(this)" />
dd8de1ec
PH
105 <input type="hidden" value="" name="order[action]" />
106 </td></tr>
107 </table>
108 </form>
109 </td>
110 <td valign="top">
693b6ec6 111 <form action="<?php echo $_SERVER['REQUEST_URI']?>" method="post" id="rule" name="rule" onsubmit="return false;">
86b5093c 112 <table width="100%" class="bicol" cellspacing="1" cellpadding="1">
a33c86a6
PH
113 <tr><th><?php i18n('rule_name'); ?>
114 </th></tr><tr><td>
115 <input type="text" value="" id="ruleName" name="rule[name]" style="width: 100%;"
5ae3e923
PH
116 onfocus="text_onfocus(this,'<?php i18n('new_rule');?>')"
117 onblur="text_onblur(this,'<?php i18n('new_rule');?>')" />
a33c86a6
PH
118 </td></tr>
119 <tr class="impair"><th><?php i18n('filter_rule_conf');?>
120 </th></tr><tr class="impair"><td>
5ae3e923
PH
121 <input type="radio" value="1" id="ruleAll1" name="rule[all]" /><?php i18n('all_matches');?>
122 <input type="radio" value="0" id="ruleAll0" name="rule[all]" /><?php i18n('one_match');?>
dd8de1ec 123 <br />
5ae3e923
PH
124 <input type="checkbox" checked="checked" id="ruleBlock" name="rule[block]" />
125 <?php i18n('blocking_rule');?>
126 </td></tr><tr class="impair"><th><?php i18n('filter_matches_list');?>
86b5093c 127 </th></tr><tr class="impair"><td id="matchesRow">
5ae3e923 128 </td></tr><tr class="impair"><th><?php i18n('filter_actions_list');?>
86b5093c 129 </th></tr><tr class="impair"><td id="actionsRow">
602a1c49 130 </td></tr><tr class="impair"><td>
a33c86a6 131 <input type="hidden" value="0" id="ruleId" name="rule[id]" />
5ae3e923
PH
132 <input type="submit" value="<?php i18n('new_match');?>" name="rule[new_match]" onclick="newMatch() "/>
133 <input type="submit" value="<?php i18n('new_action');?>" name="rule[new_action]" onclick="newAction()" />
134 <input type="submit" value="<?php i18n('submit');?>" name="rule[submit]" onclick="this.form.submit()" />
dd8de1ec
PH
135 </td></tr>
136 </table>
137 </form>
138 </td>
139</tr>
140</table>
141
142<script type="text/javascript">
143 createRuleForm();
144</script>
145
146<?php
147/********** footer **********/
148
149require("include/footer.inc.php");
150
151/********************************************************************************
152* $id: header.inc.php,v 1.2 2003/08/03 16:02:41 madcoder exp $
153* vim: set expandtab shiftwidth=4 tabstop=4 softtabstop=4 textwidth=100:
154********************************************************************************/
155?>