aaf9abef |
1 | <?php |
895905c0 |
2 | |
35586184 |
3 | /** |
4 | * options_identities.php |
5 | * |
6c84ba1e |
6 | * Copyright (c) 1999-2005 The SquirrelMail Project Team |
35586184 |
7 | * Licensed under the GNU GPL. For full terms see the file COPYING. |
8 | * |
9 | * Display Identities Options |
10 | * |
30967a1e |
11 | * @version $Id$ |
8f6f9ba5 |
12 | * @package squirrelmail |
ca479ad1 |
13 | * @subpackage prefs |
35586184 |
14 | */ |
15 | |
30967a1e |
16 | /** |
17 | * Path for SquirrelMail required files. |
18 | * @ignore |
19 | */ |
86725763 |
20 | define('SM_PATH','../'); |
21 | |
22 | /* SquirrelMail required files. */ |
08185f2a |
23 | require_once(SM_PATH . 'include/validate.php'); |
ca479ad1 |
24 | include_once(SM_PATH . 'functions/global.php'); |
25 | include_once(SM_PATH . 'functions/display_messages.php'); |
26 | include_once(SM_PATH . 'functions/html.php'); |
e7f9c987 |
27 | include_once(SM_PATH . 'functions/identity.php'); |
aaf9abef |
28 | |
e7f9c987 |
29 | if (!sqgetGlobalVar('identities', $identities, SQ_SESSION)) { |
30 | $identities = get_identities(); |
fe369c70 |
31 | } |
e7f9c987 |
32 | sqgetGlobalVar('newidentities', $newidentities, SQ_POST); |
33 | sqgetGlobalVar('smaction', $smaction, SQ_POST); |
34 | sqgetGlobalVar('return', $return, SQ_POST); |
fe369c70 |
35 | |
e7f9c987 |
36 | // First lets see if there are any actions to perform // |
37 | if (!empty($smaction) && is_array($smaction)) { |
91e0dccc |
38 | |
e7f9c987 |
39 | $doaction = ''; |
40 | $identid = 0; |
91e0dccc |
41 | |
e7f9c987 |
42 | foreach($smaction as $action=>$row) { |
43 | // we only need to extract the action and the identity we are |
44 | // altering |
91e0dccc |
45 | |
e7f9c987 |
46 | foreach($row as $key=>$data) { |
47 | $identid = $key; |
48 | } |
49 | |
50 | $doaction = $action; |
32f4e318 |
51 | } |
91e0dccc |
52 | |
e7f9c987 |
53 | $identities = sqfixidentities( $newidentities , $identid , $action ); |
54 | save_identities($identities); |
55 | } |
e697b6cc |
56 | |
e7f9c987 |
57 | if (!empty($return)) { |
58 | header('Location: ' . get_location() . '/options_personal.php'); |
59 | exit; |
60 | } |
e697b6cc |
61 | |
e7f9c987 |
62 | displayPageHeader($color, 'None'); |
e697b6cc |
63 | |
e7f9c987 |
64 | do_hook('options_identities_top'); |
91e0dccc |
65 | |
e7f9c987 |
66 | $td_str = ''; |
67 | $td_str .= '<form name="f" action="options_identities.php" method="post"><br />' . "\n"; |
68 | $td_str .= '<table border="0" cellspacing="0" cellpadding="0" width="100%">' . "\n"; |
69 | $cnt = count($identities); |
70 | foreach( $identities as $key=>$ident ) { |
e697b6cc |
71 | |
e7f9c987 |
72 | if ($key == 0) { |
73 | $hdr_str = _("Default Identity"); |
74 | } else { |
75 | $hdr_str = sprintf( _("Alternate Identity %d"), $key); |
e697b6cc |
76 | } |
77 | |
e7f9c987 |
78 | $td_str .= ShowIdentityInfo( $hdr_str, $ident, $key ); |
e697b6cc |
79 | |
e7f9c987 |
80 | } |
81 | |
82 | $td_str .= ShowIdentityInfo( _("Add a New Identity"), array('full_name'=>'','email_address'=>'','reply_to'=>'','signature'=>''), $cnt); |
83 | $td_str .= '</table>' . "\n"; |
84 | $td_str .= '</form>'; |
85 | |
86 | echo '<br /> ' . "\n" . |
87 | html_tag('table', "\n" . |
88 | html_tag('tr', "\n" . |
89 | html_tag('td' , "\n" . |
90 | '<b>' . _("Options") . ' - ' . _("Advanced Identities") . '</b><br />' . |
91 | html_tag('table', "\n" . |
92 | html_tag('tr', "\n" . |
93 | html_tag('td', "\n" . |
94 | html_tag('table' , "\n" . |
95 | html_tag('tr' , "\n" . |
96 | html_tag('td', "\n" . $td_str ,'','', 'style="text-align:center;"') |
97 | ), |
98 | '', '', 'width="80%" cellpadding="2" cellspacing="0" border="0"' ) , |
99 | 'center', $color[4]) |
100 | ), |
101 | '', '', 'width="100%" border="0" cellpadding="1" cellspacing="1"' )) , |
102 | 'center', $color[0]), |
103 | 'center', '', 'width="95%" border="0" cellpadding="2" cellspacing="0"' ) . '</body></html>'; |
104 | |
105 | |
106 | function ShowIdentityInfo($title, $identity, $id ) { |
107 | global $color; |
108 | |
109 | if (empty($identity['full_name']) && empty($identity['email_address']) && empty($identity['reply_to']) && empty($identity['signature'])) { |
110 | $bg = ''; |
111 | $empty = true; |
112 | } else { |
113 | $bg = ' style="background-color:' . $color[0] . ';"'; |
114 | |
e697b6cc |
115 | } |
116 | |
e7f9c987 |
117 | $name = 'newidentities[%d][%s]'; |
118 | |
e697b6cc |
119 | |
e7f9c987 |
120 | $return_str = ''; |
121 | |
122 | $return_str .= '<tr>' . "\n"; |
123 | $return_str .= ' <th style="text-align:center;background-color:' . $color[9] . ';" colspan="2">' . $title . '</th> '. "\n"; |
124 | $return_str .= '</tr>' . "\n"; |
125 | $return_str .= sti_input( _("Full Name") , sprintf($name, $id, 'full_name'), $identity['full_name'], $bg); |
126 | $return_str .= sti_input( _("E-Mail Address") , sprintf($name, $id, 'email_address'), $identity['email_address'], $bg); |
127 | $return_str .= sti_input( _("Reply To"), sprintf($name, $id, 'reply_to'), $identity['reply_to'], $bg); |
128 | $return_str .= sti_textarea( _("Signature"), sprintf($name, $id, 'signature'), $identity['signature'], $bg); |
129 | $return_str .= concat_hook_function('options_identities_table', array($bg, $empty, $id)); |
130 | $return_str .= '<tr' . $bg . '> ' . "\n"; |
131 | $return_str .= ' <td> </td>' . "\n"; |
132 | $return_str .= ' <td>' . "\n"; |
133 | $return_str .= ' <input type="submit" name="smaction[save][' . $id . ']" value="' . _("Save / Update") . '" />' . "\n"; |
134 | |
135 | if (!$empty && $id > 0) { |
136 | $return_str .= ' <input type="submit" name="smaction[makedefault][' . $id . ']" value="' . _("Make Default") . '" />' . "\n"; |
137 | $return_str .= ' <input type="submit" name="smaction[delete]['.$id.']" value="' . _("Delete") . '" />' . "\n"; |
138 | |
139 | if ($id > 1) { |
140 | $return_str .= ' <input type="submit" name="smaction[move]['.$id.']" value="' . _("Move Up") . '" />' . "\n"; |
141 | } |
e697b6cc |
142 | |
e697b6cc |
143 | } |
144 | |
e7f9c987 |
145 | $return_str .= concat_hook_function('options_identities_buttons', array($empty, $id)); |
146 | $return_str .= ' </td>' . "\n"; |
147 | $return_str .= '</tr>' . "\n"; |
148 | $return_str .= '<tr>' . "\n"; |
149 | $return_str .= ' <td colspan="2"> </td>' . "\n"; |
150 | $return_str .= '</tr>'; |
151 | |
152 | return $return_str; |
aaf9abef |
153 | |
01265fba |
154 | } |
155 | |
e7f9c987 |
156 | function sti_input( $title, $name, $data, $bgcolor ) { |
157 | $str = ''; |
158 | $str .= '<tr' . $bgcolor . ">\n"; |
159 | $str .= ' <td style="white-space: nowrap;text-align:right;">' . $title . ' </td>' . "\n"; |
160 | $str .= ' <td> <input type="text" name="' . $name . '" size="50" value="'. htmlspecialchars($data) . '"> </td>' . "\n"; |
161 | $str .= '</tr>'; |
162 | |
163 | return $str; |
aaf9abef |
164 | |
e7f9c987 |
165 | } |
166 | |
167 | function sti_textarea( $title, $name, $data, $bgcolor ) { |
168 | $str = ''; |
169 | $str .= '<tr' . $bgcolor . ">\n"; |
170 | $str .= ' <td style="white-space: nowrap;text-align:right;">' . $title . ' </td>' . "\n"; |
171 | $str .= ' <td> <textarea name="' . $name . '" cols="50" rows="5">'. htmlspecialchars($data) . '</textarea> </td>' . "\n"; |
172 | $str .= '</tr>'; |
173 | |
174 | return $str; |
545238b1 |
175 | |
aaf9abef |
176 | } |
a2b193bc |
177 | |
e7f9c987 |
178 | ?> |