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