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