layout and 'tutoiement'
[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
de47756d
PH
18 if(isset($_POST['global'])) { // FORM global
19 foreach($philter->config['global_plugins'] as $id=>$g_plugin)
20 if(isset($_POST['global'][$id]))
21 $filter->set_global_data($id,$_POST['global'][$id]);
22 $filter->rules[0]->sql_store(get_user_id(),0);
23 }
dd8de1ec
PH
24 if(isset($_POST['emails'])) // FORM emails
25 if(!$mail_pool->handle_form())
26 echo "<p style=\"color:red;\">".$philter->error()."</p>\n";
27
28 if(!empty($_POST['order']['action'])) // FORM order
29 if($_POST['order']['action']=='submit') {
30 foreach($filter->rules as $id=>$rule)
31 if(isset($_POST['order'][$id]))
32 $filter->rules[$id]->move_to($_POST['order'][$id], $filter->uid, $id);
33 uasort($filter->rules, 'rule_cmp');
34 } elseif($_POST['order']['action']=='delete' && !empty($_POST['order']['select'])) {
35 $filter->delete_rule($_POST['order']['select']);
36 $_POST['order']['select'] = min(count($filter->rules),$_POST['order']['select']);
37 }
38
39 if(!empty($_POST['rule'])) // FORM rule
40 if(!$filter->handle_form())
41 echo "<p style=\"color:red;\">".$philter->error()."</p>\n";
42}
43
44require("include/js_factory.inc.php");
45
46/********** globals plugins **********/
86b5093c 47?>
5ae3e923 48<div class="rubrique"><?php i18n('global_title'); ?></div>
86b5093c 49<?php
0cff7bb6 50i18n('global_help');
de47756d 51if(count($philter->config['global_plugins'])) {
242c14dc 52 echo "<form action=\"{$_SERVER['REQUEST_URI']}\" method=\"post\">\n"
86b5093c 53 ."<table width=\"95%\" class=\"bicol\" cellspacing=\"1\" cellpadding=\"1\" align=\"center\">\n";
dd8de1ec 54
4a20d54f 55 $pair = 0;
de47756d 56 foreach($philter->config['global_plugins'] as $id=>$g_plugin) {
4a20d54f 57 echo "<tr><td class='".($pair ? 'pair':'impair')."'>\n";
de47756d 58 echo $g_plugin->to_form($filter->get_global_data($id));
dd8de1ec 59 echo "</td></tr>\n";
4a20d54f 60 $pair = 1 - $pair;
dd8de1ec 61 }
4a20d54f
PH
62
63 echo "</table><br />\n"
64 ."<center><input type='submit' name='global[submit]' value='"
65 ._i18n('apply_changes')."'/></center\n"
dd8de1ec
PH
66 ."</form>\n";
67}
68
69/********** emails **********/
70?>
86b5093c 71<br />
5ae3e923 72<div class="rubrique"><?php i18n('pool_title'); ?></div>
dd8de1ec 73<?php
0cff7bb6 74i18n('pool_help');
dd8de1ec
PH
75echo $mail_pool->to_form();
76
dd8de1ec
PH
77/********** filters **********/
78?>
79
86b5093c 80<br />
5ae3e923 81<div class="rubrique"><?php i18n('filter_title'); ?></div>
0cff7bb6
PH
82<?php
83i18n('filter_help');
84?>
86b5093c
PH
85<table width="95%" cellspacing="0" cellpadding="2" align="center">
86<tr><td width="25%" valign="top">
693b6ec6 87 <form action="<?php echo $_SERVER['REQUEST_URI']?>" method="post" id="order" name="order" onsubmit="return false;">
86b5093c 88 <table class="bicol" width="100%" cellpadding="1" cellspacing="1">
5ae3e923 89 <tr><th><?php i18n('filter_list_title');?></th></tr>
dd8de1ec
PH
90 <tr><td>
91<?php
92 foreach($filter->rules as $id=>$rule)
de47756d
PH
93 if($id)
94 echo "<input type=\"hidden\" id=\"order$id\" name=\"order[$id]\" value=\"{$rule->rank}\" />\n";
dd8de1ec
PH
95
96 $presel = (isset($_POST['rule']['id']) ? $_POST['rule']['id']
97 : (isset($_POST['order']['select']) ? $_POST['order']['select'] : 0));
98
602a1c49 99 echo "<select size=\"16\" style=\"width:100%;\" id=\"orderSelect\" name=\"order[select]\" onchange=\"createRuleForm()\">\n";
5ae3e923
PH
100 echo "<option value=\"0\" ".($presel ? "" : " selected=\"selected\"").">";
101 i18n('new_rule');
102 echo "</option>\n";
dd8de1ec
PH
103
104 foreach($filter->rules as $id=>$rule)
de47756d
PH
105 if($id)
106 echo "<option value=\"$id\""
107 .($presel==$id ? " selected=\"selected\"":"")
108 .">{$rule->name}</option>\n";
dd8de1ec
PH
109?>
110 </select>
111 </td></tr><tr><td>
5ae3e923
PH
112 <input type="submit" value="<?php i18n('up');?>" name="order[up]" onclick="order_up();" />
113 <input type="submit" value="<?php i18n('dn');?>" name="order[dn]" onclick="order_dn();" /><br />
114 <input type="submit" value="<?php i18n('del');?>" name="order[delete]" onclick="order_submit(this)" />
115 <input type="submit" value="<?php i18n('submit');?>" name="order[submit]" onclick="order_submit(this)" />
dd8de1ec
PH
116 <input type="hidden" value="" name="order[action]" />
117 </td></tr>
118 </table>
119 </form>
120 </td>
121 <td valign="top">
693b6ec6 122 <form action="<?php echo $_SERVER['REQUEST_URI']?>" method="post" id="rule" name="rule" onsubmit="return false;">
86b5093c 123 <table width="100%" class="bicol" cellspacing="1" cellpadding="1">
a33c86a6
PH
124 <tr><th><?php i18n('rule_name'); ?>
125 </th></tr><tr><td>
126 <input type="text" value="" id="ruleName" name="rule[name]" style="width: 100%;"
5ae3e923
PH
127 onfocus="text_onfocus(this,'<?php i18n('new_rule');?>')"
128 onblur="text_onblur(this,'<?php i18n('new_rule');?>')" />
a33c86a6
PH
129 </td></tr>
130 <tr class="impair"><th><?php i18n('filter_rule_conf');?>
131 </th></tr><tr class="impair"><td>
5ae3e923
PH
132 <input type="radio" value="1" id="ruleAll1" name="rule[all]" /><?php i18n('all_matches');?>
133 <input type="radio" value="0" id="ruleAll0" name="rule[all]" /><?php i18n('one_match');?>
dd8de1ec 134 <br />
5ae3e923
PH
135 <input type="checkbox" checked="checked" id="ruleBlock" name="rule[block]" />
136 <?php i18n('blocking_rule');?>
137 </td></tr><tr class="impair"><th><?php i18n('filter_matches_list');?>
86b5093c 138 </th></tr><tr class="impair"><td id="matchesRow">
5ae3e923 139 </td></tr><tr class="impair"><th><?php i18n('filter_actions_list');?>
86b5093c 140 </th></tr><tr class="impair"><td id="actionsRow">
602a1c49 141 </td></tr><tr class="impair"><td>
a33c86a6 142 <input type="hidden" value="0" id="ruleId" name="rule[id]" />
5ae3e923
PH
143 <input type="submit" value="<?php i18n('new_match');?>" name="rule[new_match]" onclick="newMatch() "/>
144 <input type="submit" value="<?php i18n('new_action');?>" name="rule[new_action]" onclick="newAction()" />
145 <input type="submit" value="<?php i18n('submit');?>" name="rule[submit]" onclick="this.form.submit()" />
dd8de1ec
PH
146 </td></tr>
147 </table>
148 </form>
149 </td>
150</tr>
151</table>
152
153<script type="text/javascript">
154 createRuleForm();
155</script>
156
157<?php
158/********** footer **********/
159
160require("include/footer.inc.php");
161
162/********************************************************************************
163* $id: header.inc.php,v 1.2 2003/08/03 16:02:41 madcoder exp $
164* vim: set expandtab shiftwidth=4 tabstop=4 softtabstop=4 textwidth=100:
165********************************************************************************/
166?>