c36ed9cf |
1 | <?php |
cd2b7182 |
2 | |
35586184 |
3 | /** |
4 | * options_personal.php |
5 | * |
35586184 |
6 | * Displays all options relating to personal information |
7 | * |
4b5049de |
8 | * @copyright © 1999-2007 The SquirrelMail Project Team |
4b4abf93 |
9 | * @license http://opensource.org/licenses/gpl-license.php GNU Public License |
763b63fe |
10 | * @version $Id$ |
2b646597 |
11 | * @package squirrelmail |
35586184 |
12 | */ |
cbe5423b |
13 | |
2b646597 |
14 | /** SquirrelMail required files. */ |
2d3a630b |
15 | require_once(SM_PATH . 'include/timezones.php'); |
01265fba |
16 | |
cbe5423b |
17 | /* Define the group constants for the personal options page. */ |
18 | define('SMOPT_GRP_CONTACT', 0); |
19 | define('SMOPT_GRP_REPLY', 1); |
20 | define('SMOPT_GRP_SIG', 2); |
397ddb13 |
21 | define('SMOPT_GRP_TZ', 3); |
cbe5423b |
22 | |
48af4b64 |
23 | /** |
24 | * This function builds an array with all the information about |
25 | * the options available to the user, and returns it. The options |
26 | * are grouped by the groups in which they are displayed. |
27 | * For each option, the following information is stored: |
28 | * - name: the internal (variable) name |
29 | * - caption: the description of the option in the UI |
30 | * - type: one of SMOPT_TYPE_* |
31 | * - refresh: one of SMOPT_REFRESH_* |
32 | * - size: one of SMOPT_SIZE_* |
33 | * - save: the name of a function to call when saving this option |
34 | * @return array all option information |
35 | */ |
cbe5423b |
36 | function load_optpage_data_personal() { |
01265fba |
37 | global $data_dir, $username, $edit_identity, $edit_name, |
df442a10 |
38 | $full_name, $reply_to, $email_address, $signature, $tzChangeAllowed, |
ce8c6f42 |
39 | $timeZone, $domain; |
cbe5423b |
40 | |
41 | /* Set the values of some global variables. */ |
42 | $full_name = getPref($data_dir, $username, 'full_name'); |
43 | $reply_to = getPref($data_dir, $username, 'reply_to'); |
8d6a0eb2 |
44 | $email_address = getPref($data_dir, $username, 'email_address',SMPREF_NONE); |
01265fba |
45 | $signature = getSig($data_dir, $username, 'g'); |
8d6a0eb2 |
46 | |
47 | // set email_address to default value, if it is not set in user's preferences |
48 | if ($email_address == SMPREF_NONE) { |
49 | if (preg_match("/(.+)@(.+)/",$username)) { |
50 | $email_address = $username; |
51 | } else { |
52 | $email_address = $username . '@' . $domain ; |
53 | } |
54 | } |
bbcafebd |
55 | |
56 | /* Build a simple array into which we will build options. */ |
57 | $optgrps = array(); |
58 | $optvals = array(); |
59 | |
60 | /******************************************************/ |
61 | /* LOAD EACH GROUP OF OPTIONS INTO THE OPTIONS ARRAY. */ |
62 | /******************************************************/ |
bbcafebd |
63 | |
8a2e4d5b |
64 | /*** Load the Contact Information Options into the array ***/ |
bbcafebd |
65 | $optgrps[SMOPT_GRP_CONTACT] = _("Name and Address Options"); |
66 | $optvals[SMOPT_GRP_CONTACT] = array(); |
67 | |
68 | /* Build a simple array into which we will build options. */ |
69 | $optvals = array(); |
70 | |
26e2d3ef |
71 | if (!isset($edit_identity)) { |
72 | $edit_identity = TRUE; |
73 | } |
74 | |
8a7d0669 |
75 | if ($edit_identity || $edit_name) { |
76 | $optvals[SMOPT_GRP_CONTACT][] = array( |
77 | 'name' => 'full_name', |
78 | 'caption' => _("Full Name"), |
79 | 'type' => SMOPT_TYPE_STRING, |
80 | 'refresh' => SMOPT_REFRESH_NONE, |
81 | 'size' => SMOPT_SIZE_HUGE |
82 | ); |
83 | } else { |
84 | $optvals[SMOPT_GRP_CONTACT][] = array( |
85 | 'name' => 'full_name', |
86 | 'caption' => _("Full Name"), |
87 | 'type' => SMOPT_TYPE_COMMENT, |
88 | 'refresh' => SMOPT_REFRESH_NONE, |
89 | 'comment' => $full_name |
90 | ); |
91 | } |
bbcafebd |
92 | |
8a7d0669 |
93 | if ($edit_identity) { |
94 | $optvals[SMOPT_GRP_CONTACT][] = array( |
95 | 'name' => 'email_address', |
674a2ca2 |
96 | 'caption' => _("E-mail Address"), |
8a7d0669 |
97 | 'type' => SMOPT_TYPE_STRING, |
98 | 'refresh' => SMOPT_REFRESH_NONE, |
99 | 'size' => SMOPT_SIZE_HUGE |
100 | ); |
101 | } else { |
102 | $optvals[SMOPT_GRP_CONTACT][] = array( |
103 | 'name' => 'email_address', |
674a2ca2 |
104 | 'caption' => _("E-mail Address"), |
8a7d0669 |
105 | 'type' => SMOPT_TYPE_COMMENT, |
106 | 'refresh' => SMOPT_REFRESH_NONE, |
8d6a0eb2 |
107 | 'comment' => htmlspecialchars($email_address) |
8a7d0669 |
108 | ); |
109 | } |
bbcafebd |
110 | |
111 | $optvals[SMOPT_GRP_CONTACT][] = array( |
112 | 'name' => 'reply_to', |
113 | 'caption' => _("Reply To"), |
114 | 'type' => SMOPT_TYPE_STRING, |
115 | 'refresh' => SMOPT_REFRESH_NONE, |
116 | 'size' => SMOPT_SIZE_HUGE |
117 | ); |
118 | |
01265fba |
119 | $optvals[SMOPT_GRP_CONTACT][] = array( |
120 | 'name' => 'signature', |
121 | 'caption' => _("Signature"), |
122 | 'type' => SMOPT_TYPE_TEXTAREA, |
123 | 'refresh' => SMOPT_REFRESH_NONE, |
124 | 'size' => SMOPT_SIZE_MEDIUM, |
125 | 'save' => 'save_option_signature' |
126 | ); |
127 | |
8a7d0669 |
128 | if ($edit_identity) { |
6fd95361 |
129 | $identities_link_value = '<a href="options_identities.php">' |
8a7d0669 |
130 | . _("Edit Advanced Identities") |
6fd95361 |
131 | . '</a> ' |
8a7d0669 |
132 | . _("(discards changes made on this form so far)"); |
133 | $optvals[SMOPT_GRP_CONTACT][] = array( |
134 | 'name' => 'identities_link', |
135 | 'caption' => _("Multiple Identities"), |
136 | 'type' => SMOPT_TYPE_COMMENT, |
137 | 'refresh' => SMOPT_REFRESH_NONE, |
138 | 'comment' => $identities_link_value |
139 | ); |
140 | } |
91e0dccc |
141 | |
867fed37 |
142 | if ( $tzChangeAllowed || function_exists('date_default_timezone_set')) { |
4b50568d |
143 | $TZ_ARRAY[SMPREF_NONE] = _("Same as server"); |
2d3a630b |
144 | |
145 | $aTimeZones = sq_get_tz_array(); |
146 | unset($message); |
147 | if (! empty($aTimeZones)) { |
148 | // check if current timezone is linked to other TZ and update it |
149 | if ($timeZone != SMPREF_NONE && $timeZone != "" && |
150 | isset($aTimeZones[$timeZone]['LINK'])) { |
151 | $timeZone = $aTimeZones[$timeZone]['LINK']; |
152 | // TODO: recheck setting of $timeZone |
153 | // setPref($data_dir,$username,'timezone',$timeZone); |
154 | } |
155 | |
156 | // sort time zones by name. sq_get_tz_array() returns sorted by key. |
157 | // asort($aTimeZones); |
158 | |
159 | // add all 'TZ' entries to TZ_ARRAY |
160 | foreach ($aTimeZones as $TzKey => $TzData) { |
161 | if (! isset($TzData['LINK'])) { |
162 | // Old display format |
163 | $TZ_ARRAY[$TzKey] = $TzKey; |
164 | |
165 | // US Eastern standard time (America/New_York) - needs asort($aTimeZones) |
166 | //$TZ_ARRAY[$TzKey] = (isset($TzData['NAME']) ? $TzData['NAME']." ($TzKey)" : "($TzKey)"); |
167 | |
168 | // US Eastern standard time if NAME is present or America/New_York if NAME not present |
169 | // needs sorting after all data is added or uasort() |
170 | //$TZ_ARRAY[$TzKey] = (isset($TzData['NAME']) ? $TzData['NAME'] : $TzKey); |
171 | |
172 | // (America/New_Your) US Eastern standard time |
173 | //$TZ_ARRAY[$TzKey] = "($TzKey)" . (isset($TzData['NAME']) ? ' '.$TzData['NAME'] : ''); |
174 | } |
175 | } |
176 | } else { |
bb7173fa |
177 | $message = _("Error opening timezone config, contact administrator."); |
178 | } |
2d3a630b |
179 | |
180 | // TODO: make error user friendly |
bb7173fa |
181 | if (isset($message)) { |
ce8c6f42 |
182 | plain_error_message($message); |
bb7173fa |
183 | exit; |
184 | } |
7e235a1a |
185 | |
4b50568d |
186 | $optgrps[SMOPT_GRP_TZ] = _("Timezone Options"); |
187 | $optvals[SMOPT_GRP_TZ] = array(); |
7e235a1a |
188 | |
4b50568d |
189 | $optvals[SMOPT_GRP_TZ][] = array( |
190 | 'name' => 'timezone', |
191 | 'caption' => _("Your current timezone"), |
192 | 'type' => SMOPT_TYPE_STRLIST, |
193 | 'refresh' => SMOPT_REFRESH_NONE, |
194 | 'posvals' => $TZ_ARRAY |
195 | ); |
196 | } |
91e0dccc |
197 | |
8a2e4d5b |
198 | /*** Load the Reply Citation Options into the array ***/ |
199 | $optgrps[SMOPT_GRP_REPLY] = _("Reply Citation Options"); |
bbcafebd |
200 | $optvals[SMOPT_GRP_REPLY] = array(); |
201 | |
202 | $optvals[SMOPT_GRP_REPLY][] = array( |
203 | 'name' => 'reply_citation_style', |
204 | 'caption' => _("Reply Citation Style"), |
205 | 'type' => SMOPT_TYPE_STRLIST, |
206 | 'refresh' => SMOPT_REFRESH_NONE, |
207 | 'posvals' => array(SMPREF_NONE => _("No Citation"), |
0e1a248b |
208 | 'author_said' => _("AUTHOR Wrote"), |
209 | 'date_time_author' => _("On DATE, AUTHOR Wrote"), |
bbcafebd |
210 | 'quote_who' => _("Quote Who XML"), |
211 | 'user-defined' => _("User-Defined")) |
212 | ); |
213 | |
214 | $optvals[SMOPT_GRP_REPLY][] = array( |
215 | 'name' => 'reply_citation_start', |
216 | 'caption' => _("User-Defined Citation Start"), |
217 | 'type' => SMOPT_TYPE_STRING, |
218 | 'refresh' => SMOPT_REFRESH_NONE, |
219 | 'size' => SMOPT_SIZE_MEDIUM |
220 | ); |
221 | |
222 | $optvals[SMOPT_GRP_REPLY][] = array( |
223 | 'name' => 'reply_citation_end', |
224 | 'caption' => _("User-Defined Citation End"), |
225 | 'type' => SMOPT_TYPE_STRING, |
226 | 'refresh' => SMOPT_REFRESH_NONE, |
227 | 'size' => SMOPT_SIZE_MEDIUM |
228 | ); |
229 | |
8a2e4d5b |
230 | /*** Load the Signature Options into the array ***/ |
231 | $optgrps[SMOPT_GRP_SIG] = _("Signature Options"); |
232 | $optvals[SMOPT_GRP_SIG] = array(); |
bbcafebd |
233 | |
8a2e4d5b |
234 | $optvals[SMOPT_GRP_SIG][] = array( |
bbcafebd |
235 | 'name' => 'use_signature', |
236 | 'caption' => _("Use Signature"), |
237 | 'type' => SMOPT_TYPE_BOOLEAN, |
238 | 'refresh' => SMOPT_REFRESH_NONE |
239 | ); |
240 | |
8a2e4d5b |
241 | $optvals[SMOPT_GRP_SIG][] = array( |
bbcafebd |
242 | 'name' => 'prefix_sig', |
243 | 'caption' => _("Prefix Signature with '-- ' Line"), |
244 | 'type' => SMOPT_TYPE_BOOLEAN, |
245 | 'refresh' => SMOPT_REFRESH_NONE |
246 | ); |
247 | |
cbe5423b |
248 | /* Assemble all this together and return it as our result. */ |
249 | $result = array( |
250 | 'grps' => $optgrps, |
251 | 'vals' => $optvals |
252 | ); |
253 | return ($result); |
254 | } |
e7db48af |
255 | |
cbe5423b |
256 | /******************************************************************/ |
257 | /** Define any specialized save functions for this option page. ***/ |
258 | /******************************************************************/ |
e7db48af |
259 | |
48af4b64 |
260 | /** |
261 | * Saves the signature option. |
262 | */ |
cbe5423b |
263 | function save_option_signature($option) { |
264 | global $data_dir, $username; |
01265fba |
265 | setSig($data_dir, $username, 'g', $option->new_value); |
cbe5423b |
266 | } |
209e24bb |
267 | |