4 * options_identities.php
6 * Copyright (c) 1999-2002 The SquirrelMail Project Team
7 * Licensed under the GNU GPL. For full terms see the file COPYING.
9 * Display Identities Options
14 require_once('../src/validate.php');
15 require_once('../functions/display_messages.php');
19 header('Location: options_personal.php');
23 displayPageHeader($color, 'None');
25 $Info = do_hook('options_identities_process', 0);
30 if (CheckAndDoDefault() ||
CheckAndDoPromote()) {
33 if (isset($update) ||
CheckForDelete()) {
37 LoadInfo($full_name, $email_address, $reply_to, $signature, '');
41 <table width
="95%" align
=center border
=0 cellpadding
=2 cellspacing
=0>
42 <tr
><td bgcolor
="<?php echo $color[0] ?>" align
="center">
44 <b
><?php
echo _("Options") . ' - ' . _("Advanced Identities"); ?
></b
>
46 <table width
="100%" border
="0" cellpadding
="1" cellspacing
="1">
47 <tr
><td bgcolor
="<?php echo $color[4] ?>" align
="center">
49 <form name
="f" action
="options_identities.php" method
="post"><br
>
51 <?php
do_hook('options_identities_top'); ?
>
53 <table width
="80%" cellpadding
=2 cellspacing
=0 border
=0>
54 <tr bgcolor
="<?php echo $color[9] ?>">
55 <th colspan
=2 align
=center
><?php
echo _("Default Identity") ?
></th
>
59 ShowTableInfo($full_name, $email_address, $reply_to, $signature, '');
62 while (LoadInfo($full_name, $email_address, $reply_to, $signature, $num))
65 <tr bgcolor
="<?PHP echo $color[9] ?>">
66 <th colspan
=2 align
=center
><?PHP
printf (_("Alternate Identity %d"),
70 ShowTableInfo($full_name, $email_address, $reply_to, $signature, $num);
75 <tr bgcolor
="<?php echo $color[9] ?>">
76 <th colspan
=2 align
=center
><?PHP
echo _("Add a New Identity") ?
></th
>
79 ShowTableInfo('', '', '', '', $num);
93 function SaveUpdateFunction() {
94 global $username, $data_dir, $full_name, $email_address, $reply_to, $signature;
98 $name = 'form_for_' . $i;
100 while (isset($
$name))
102 $name = 'delete_' . $i;
107 do_hook('options_identities_renumber', $i, $fakeI);
110 $name = 'full_name' . $i;
114 setPref($data_dir, $username, 'full_name' . $fakeI, $
$name);
116 $name = 'email_address' . $i;
120 setPref($data_dir, $username, 'email_address' . $fakeI, $
$name);
122 $name = 'reply_to' . $i;
126 setPref($data_dir, $username, 'reply_to' . $fakeI, $
$name);
128 $name = 'signature' . $i;
132 setSig($data_dir, $username, $fakeI, $
$name);
140 $name = 'form_for_' . $i;
144 setPref($data_dir, $username, 'identities', $fakeI);
148 removePref($data_dir, $username, 'full_name' . $fakeI);
149 removePref($data_dir, $username, 'email_address' . $fakeI);
150 removePref($data_dir, $username, 'reply_to' . $fakeI);
151 setSig($data_dir, $username, $fakeI, "");
155 setPref($data_dir, $username, 'full_name', $full_name);
156 setPref($data_dir, $username, 'email_address', $email_address);
157 setPref($data_dir, $username, 'reply_to', $reply_to);
158 setSig($data_dir, $username, "g", $signature);
162 function CheckAndDoDefault() {
163 global $username, $data_dir, $full_name, $email_address, $reply_to, $signature;
166 $name = 'form_for_' . $i;
168 while (isset($
$name))
170 $name = 'make_default_' . $i;
173 do_hook('options_identities_renumber', $i, 'default');
174 global $full_name, $email_address, $reply_to, $signature;
176 $name = 'full_name' . $i;
182 $name = 'email_address' . $i;
184 $temp = $email_address;
185 $email_address = $
$name;
188 $name = 'reply_to' . $i;
194 $name = 'signature' . $i;
205 $name = 'form_for_' . $i;
211 function CheckForDelete() {
212 global $username, $data_dir, $full_name, $email_address, $reply_to, $signature;
215 $name = 'form_for_' . $i;
217 while (isset($
$name))
219 $name = 'delete_' . $i;
226 $name = 'form_for_' . $i;
232 function CheckAndDoPromote() {
233 global $username, $data_dir, $full_name, $email_address, $reply_to;
236 $name = 'form_for_' . $i;
238 while (isset($
$name)) {
239 $name = 'promote_' . $i;
241 if (isset($
$name) && $i > 1) {
242 do_hook('options_identities_renumber', $i, $i - 1);
244 $nameA = 'full_name' . $i;
245 $nameB = 'full_name' . ($i - 1);
246 global $
$nameA, $
$nameB;
251 $nameA = 'email_address' . $i;
252 $nameB = 'email_address' . ($i - 1);
253 global $
$nameA, $
$nameB;
258 $nameA = 'reply_to' . $i;
259 $nameB = 'reply_to' . ($i - 1);
260 global $
$nameA, $
$nameB;
265 $nameA = 'signature' . $i;
266 $nameB = 'signature' . ($i - 1);
267 global $
$nameA, $
$nameB;
276 $name = 'form_for_' . $i;
282 function LoadInfo(&$n, &$e, &$r, &$s, $post) {
283 global $username, $data_dir;
285 $n = getPref($data_dir, $username, 'full_name' . $post);
286 $e = getPref($data_dir, $username, 'email_address' . $post);
287 $r = getPref($data_dir, $username, 'reply_to' . $post);
290 $s = getSig($data_dir,$username,$post);
292 if ($n != '' ||
$e != '' ||
$r != '' ||
$s != '')
296 function sti_input( $title, $hd, $data, $post, $bg ) {
298 echo "<tr$bg><td align=right nowrap>$title:".
300 '<input size=50 type=text value="' . htmlspecialchars($data) .
301 "\" name=\"$hd$post\"></td></tr>";
305 function sti_textarea( $title, $hd, $data, $post, $bg ) {
307 echo "<tr$bg><td align=right nowrap>$title:".
309 "<textarea cols=50 rows=5 name=\"$hd$post\">" . htmlspecialchars($data) .
310 "</textarea></td></tr>";
314 function ShowTableInfo($full_name, $email_address, $reply_to, $signature, $post) {
317 $OtherBG = ' bgcolor="' . $color[0] . '"';
318 if ($full_name == '' && $email_address == '' && $reply_to == '' && $signature == '')
321 if ($full_name == '' && $email_address == '' && $reply_to == '' && $signature == '')
322 $isEmptySection = true;
324 $isEmptySection = false;
326 sti_input( _("Full Name"), 'full_name', $full_name, $post, $OtherBG );
327 sti_input( _("E-Mail Address"), 'email_address', $email_address, $post, $OtherBG );
328 sti_input( _("Reply To"), 'reply_to', $reply_to, $post, $OtherBG );
329 sti_textarea( _("Signature"), 'signature', $signature, $post, $OtherBG );
331 do_hook('options_identities_table', $OtherBG, $isEmptySection, $post);
333 '<td> </td><td>'.
334 "<input type=hidden name=\"form_for_$post\" value=\"1\">".
335 '<input type=submit name="update" value="'.
336 _("Save / Update") . '">';
337 if (! $isEmptySection && $post != '') {
338 echo "<input type=submit name=\"make_default_$post\" value=\"".
339 _("Make Default") . '">'.
340 "<input type=submit name=\"delete_$post\" value=\"".
343 if (! $isEmptySection && $post != '' && $post > 1) {
344 echo '<input type=submit name="promote_' . $post . '" value="'.
347 do_hook('options_identities_buttons', $isEmptySection, $post);
349 '<tr><td colspan="2"> </td></tr>';