one more identity action to process
[squirrelmail.git] / include / options / personal.php
1 <?php
2
3 /**
4 * options_personal.php
5 *
6 * Copyright (c) 1999-2005 The SquirrelMail Project Team
7 * Licensed under the GNU GPL. For full terms see the file COPYING.
8 *
9 * Displays all options relating to personal information
10 *
11 * @version $Id$
12 * @package squirrelmail
13 */
14
15 /** SquirrelMail required files. */
16 require_once(SM_PATH . 'functions/imap.php');
17 require_once(SM_PATH . 'include/timezones.php');
18
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);
23 define('SMOPT_GRP_TZ', 3);
24
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 */
38 function load_optpage_data_personal() {
39 global $data_dir, $username, $edit_identity, $edit_name,
40 $full_name, $reply_to, $email_address, $signature, $tzChangeAllowed,
41 $color, $timeZone;
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');
46 $email_address = getPref($data_dir, $username, 'email_address');
47 $signature = getSig($data_dir, $username, 'g');
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 /******************************************************/
56
57 /*** Load the Contact Information Options into the array ***/
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
64 if (!isset($edit_identity)) {
65 $edit_identity = TRUE;
66 }
67
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 }
85
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 }
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
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
121 if ($edit_identity) {
122 $identities_link_value = '<a href="options_identities.php">'
123 . _("Edit Advanced Identities")
124 . '</a> '
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 }
134
135 if ( $tzChangeAllowed ) {
136 $TZ_ARRAY[SMPREF_NONE] = _("Same as server");
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 {
170 $message = _("Error opening timezone config, contact administrator.");
171 }
172
173 // TODO: make error user friendly
174 if (isset($message)) {
175 plain_error_message($message, $color);
176 exit;
177 }
178
179 $optgrps[SMOPT_GRP_TZ] = _("Timezone Options");
180 $optvals[SMOPT_GRP_TZ] = array();
181
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 }
190
191 /*** Load the Reply Citation Options into the array ***/
192 $optgrps[SMOPT_GRP_REPLY] = _("Reply Citation Options");
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"),
201 'author_said' => _("AUTHOR Wrote"),
202 'date_time_author' => _("On DATE, AUTHOR Wrote"),
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
223 /*** Load the Signature Options into the array ***/
224 $optgrps[SMOPT_GRP_SIG] = _("Signature Options");
225 $optvals[SMOPT_GRP_SIG] = array();
226
227 $optvals[SMOPT_GRP_SIG][] = array(
228 'name' => 'use_signature',
229 'caption' => _("Use Signature"),
230 'type' => SMOPT_TYPE_BOOLEAN,
231 'refresh' => SMOPT_REFRESH_NONE
232 );
233
234 $optvals[SMOPT_GRP_SIG][] = array(
235 'name' => 'prefix_sig',
236 'caption' => _("Prefix Signature with '-- ' Line"),
237 'type' => SMOPT_TYPE_BOOLEAN,
238 'refresh' => SMOPT_REFRESH_NONE
239 );
240
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 }
248
249 /******************************************************************/
250 /** Define any specialized save functions for this option page. ***/
251 /******************************************************************/
252
253 /**
254 * Saves the signature option.
255 */
256 function save_option_signature($option) {
257 global $data_dir, $username;
258 setSig($data_dir, $username, 'g', $option->new_value);
259 }
260
261 ?>