Changed default value for SpamFilters_YourHop
[squirrelmail.git] / src / options_identities.php
CommitLineData
aaf9abef 1<?php
895905c0 2
aaf9abef 3 /**
4 ** options_identities.php
5 **
895905c0 6 ** Copyright (c) 1999-2001 The SquirrelMail development team
7 ** Licensed under the GNU GPL. For full terms see the file COPYING.
8 **
9 ** Display Identities Options
10 **
aaf9abef 11 ** $Id$
12 **/
13
ff8a98e7 14 require_once('../src/validate.php');
15 require_once('../functions/display_messages.php');
aaf9abef 16
17 if (isset($return)) {
18 SaveUpdateFunction();
19 header('Location: options_personal.php');
20 exit();
21 }
22
23 displayPageHeader($color, 'None');
24
0f101579 25 $Info = do_hook('options_identities_process', 0);
26 if ($Info[1])
27 SaveUpdateFunction();
28
aaf9abef 29 if (CheckAndDoDefault() || CheckAndDoPromote()) {
30 SaveUpdateFunction();
31 }
d20f2df6 32 if (isset($update) || CheckForDelete())
aaf9abef 33 SaveUpdateFunction();
34
35 LoadInfo($full_name, $email_address, $reply_to, '');
36
37?>
38<br>
39<table width=95% align=center border=0 cellpadding=2 cellspacing=0>
e7db48af 40<tr><td bgcolor="<?php echo $color[0] ?>" align="center">
41
42 <b><?php echo _("Options") . ' - ' . _("Advanced Identities"); ?></b>
43
44 <table width="100%" border="0" cellpadding="1" cellspacing="1">
45 <tr><td bgcolor="<?php echo $color[4] ?>" align="center">
aaf9abef 46
e7db48af 47<form name=f action="options_identities.php" method=post><br>
8d4949e4 48
0f101579 49<?PHP do_hook('options_identities_top'); ?>
50
e7db48af 51<table width=80% cellpadding=2 cellspacing=0 border=0>
aaf9abef 52 <tr bgcolor="<?PHP echo $color[9] ?>">
53 <th colspan=2 align=center><?PHP echo _("Default Identity") ?></th>
54 </tr>
55<?PHP
56
57 ShowTableInfo($full_name, $email_address, $reply_to, '');
58
59 $num = 1;
60 while (LoadInfo($full_name, $email_address, $reply_to, $num))
61 {
62?>
63 <tr bgcolor="<?PHP echo $color[9] ?>">
64 <th colspan=2 align=center><?PHP printf (_("Alternate Identity %d"),
65 $num) ?></th>
66 </tr>
67<?PHP
68 ShowTableInfo($full_name, $email_address, $reply_to, $num);
69 $num ++;
70 }
71
72?>
73 <tr bgcolor="<?PHP echo $color[9] ?>">
74 <th colspan=2 align=center><?PHP echo _("Add a New Identity") ?></th>
75 </tr>
76<?
77
78 ShowTableInfo('', '', '', $num);
79?>
e697b6cc 80</table>
aaf9abef 81</form>
e7db48af 82
83 </td></tr>
84 </table>
85
86</td></tr>
87</table>
aaf9abef 88</body></html>
e7db48af 89
aaf9abef 90<?PHP
91
e697b6cc 92 function SaveUpdateFunction() {
93 global $username, $data_dir, $full_name, $email_address, $reply_to;
aaf9abef 94
e697b6cc 95 $i = 1;
96 $fakeI = 1;
97 $name = 'form_for_' . $i;
98 global $$name;
99 while (isset($$name))
100 {
101 $name = 'delete_' . $i;
102 global $$name;
103 if (isset($$name)) {
104 $fakeI --;
105 } else {
106 do_hook('options_identities_renumber', $i, $fakeI);
107 $filled = 0;
aaf9abef 108
e697b6cc 109 $name = 'full_name' . $i;
110 global $$name;
111 if ($$name != '')
112 $filled ++;
113 setPref($data_dir, $username, 'full_name' . $fakeI, $$name);
aaf9abef 114
e697b6cc 115 $name = 'email_address' . $i;
116 global $$name;
117 if ($$name != '')
118 $filled ++;
119 setPref($data_dir, $username, 'email_address' . $fakeI, $$name);
d20f2df6 120
e697b6cc 121 $name = 'reply_to' . $i;
122 global $$name;
123 if ($$name != '')
124 $filled ++;
125 setPref($data_dir, $username, 'reply_to' . $fakeI, $$name);
126
127 if ($filled == 0)
128 $fakeI --;
129 }
130
131 $fakeI ++;
132 $i ++;
133 $name = 'form_for_' . $i;
134 global $$name;
135 }
136
137 setPref($data_dir, $username, 'identities', $fakeI);
138
139 while ($fakeI != $i)
140 {
141 removePref($data_dir, $username, 'full_name' . $fakeI);
142 removePref($data_dir, $username, 'email_address' . $fakeI);
143 removePref($data_dir, $username, 'reply_to' . $fakeI);
144 $fakeI ++;
145 }
146
147 setPref($data_dir, $username, 'full_name', $full_name);
148 setPref($data_dir, $username, 'email_address', $email_address);
149 setPref($data_dir, $username, 'reply_to', $reply_to);
150 }
151
152 function CheckAndDoDefault() {
153 global $username, $data_dir, $full_name, $email_address, $reply_to;
154
155 $i = 1;
156 $name = 'form_for_' . $i;
157 global $$name;
158 while (isset($$name))
159 {
160 $name = 'make_default_' . $i;
161 global $$name;
162 if (isset($$name)) {
163 do_hook('options_identities_renumber', $i, 'default');
164 global $full_name, $email_address, $reply_to;
165
166 $name = 'full_name' . $i;
167 global $$name;
168 $temp = $full_name;
169 $full_name = $$name;
170 $$name = $temp;
171
172 $name = 'email_address' . $i;
173 global $$name;
174 $temp = $email_address;
175 $email_address = $$name;
176 $$name = $temp;
177
178 $name = 'reply_to' . $i;
179 global $$name;
180 $temp = $reply_to;
181 $reply_to = $$name;
182 $$name = $temp;
183
184 return true;
185 }
186
187 $i ++;
188 $name = 'form_for_' . $i;
189 global $$name;
190 }
191 return FALSE;
192 }
193
194 function CheckForDelete() {
195 global $username, $data_dir, $full_name, $email_address, $reply_to;
aaf9abef 196
e697b6cc 197 $i = 1;
198 $name = 'form_for_' . $i;
199 global $$name;
200 while (isset($$name))
201 {
202 $name = 'delete_' . $i;
203 global $$name;
204 if (isset($$name)) {
205 return true;
206 }
aaf9abef 207
e697b6cc 208 $i ++;
209 $name = 'form_for_' . $i;
210 global $$name;
211 }
212 return false;
213 }
214
215 function CheckAndDoPromote() {
216 global $username, $data_dir, $full_name, $email_address, $reply_to;
217
218 $i = 1;
219 $name = 'form_for_' . $i;
220 global $$name;
221 while (isset($$name)) {
222 $name = 'promote_' . $i;
223 global $$name;
224 if (isset($$name) && $i > 1) {
225 do_hook('options_identities_renumber', $i, $i - 1);
226
227 $nameA = 'full_name' . $i;
228 $nameB = 'full_name' . ($i - 1);
229 global $$nameA, $$nameB;
230 $temp = $$nameA;
231 $$nameA = $$nameB;
232 $$nameB = $temp;
233
234 $nameA = 'email_address' . $i;
235 $nameB = 'email_address' . ($i - 1);
236 global $$nameA, $$nameB;
237 $temp = $$nameA;
238 $$nameA = $$nameB;
239 $$nameB = $temp;
240
241 $nameA = 'reply_to' . $i;
242 $nameB = 'reply_to' . ($i - 1);
243 global $$nameA, $$nameB;
244 $temp = $$nameA;
245 $$nameA = $$nameB;
246 $$nameB = $temp;
247
248 return true;
249 }
250
251 $i ++;
252 $name = 'form_for_' . $i;
253 global $$name;
254 }
255 return false;
256 }
257
258 function LoadInfo(&$n, &$e, &$r, $post) {
259 global $username, $data_dir;
260
261 $n = getPref($data_dir, $username, 'full_name' . $post);
262 $e = getPref($data_dir, $username, 'email_address' . $post);
263 $r = getPref($data_dir, $username, 'reply_to' . $post);
264
265 if ($n != '' || $e != '' || $r != '')
266 return true;
267 }
268
269function sti_input( $title, $hd, $data, $post, $bg ) {
270
271 echo "<tr$bg><td align=right nowrap>$title:".
272 '</td><td>'.
273 '<input size=50 type=text value="' . htmlspecialchars($data) .
274 "\" name=\"$hd$post\"></td></tr>";
aaf9abef 275
aaf9abef 276}
277
e697b6cc 278function ShowTableInfo($full_name, $email_address, $reply_to, $post) {
279 global $color;
aaf9abef 280
e697b6cc 281 $OtherBG = ' bgcolor="' . $color[0] . '"';
282 if ($full_name == '' && $email_address == '' && $reply_to == '')
283 $OtherBG = '';
aaf9abef 284
e697b6cc 285 if ($full_name == '' && $email_address == '' && $reply_to == '')
286 $isEmptySection = true;
287 else
288 $isEmptySection = false;
289
290 sti_input( _("Full Name"), 'full_name', $full_name, $post, $OtherBG );
291 sti_input( _("E-Mail Address"), 'email_address', $email_address, $post, $OtherBG );
292 sti_input( _("Reply To"), 'reply_to', $reply_to, $post, $OtherBG );
293
294 do_hook('options_identities_table', $OtherBG, $isEmptySection, $post);
295 echo "<tr$OtherBG>".
296 '<td>&nbsp;</td><td>'.
297 "<input type=hidden name=\"form_for_$post\" value=\"1\">".
298 '<input type=submit name="update" value="'.
299 _("Save / Update") . '">';
300 if (! $isEmptySection && $post != '') {
301 echo "<input type=submit name=\"make_default_$post\" value=\"".
302 _("Make Default") . '">'.
303 "<input type=submit name=\"delete_$post\" value=\"".
304 _("Delete") . '">';
305 }
306 if (! $isEmptySection && $post != '' && $post > 1) {
307 echo '<input type=submit name="promote_' . $post . '" value="'.
308 _("Move Up") . '">';
309 }
310 do_hook('options_identities_buttons', $isEmptySection, $post);
311 echo '</td></tr>'.
312 '<tr><td colspan="2">&nbsp;</td></tr>';
aaf9abef 313}
ff8a98e7 314?>