474aee50774318aabac4fa6d2a2c979806933726
6 * Copyright (c) 1999-2005 The SquirrelMail Project Team
7 * Licensed under the GNU GPL. For full terms see the file COPYING.
9 * Displays all options relating to personal information
12 * @package squirrelmail
15 /** SquirrelMail required files. */
16 require_once(SM_PATH
. 'functions/imap.php');
17 require_once(SM_PATH
. 'include/timezones.php');
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);
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
38 function load_optpage_data_personal() {
39 global $data_dir, $username, $edit_identity, $edit_name,
40 $full_name, $reply_to, $email_address, $signature, $tzChangeAllowed,
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');
49 /* Build a simple array into which we will build options. */
53 /******************************************************/
54 /* LOAD EACH GROUP OF OPTIONS INTO THE OPTIONS ARRAY. */
55 /******************************************************/
57 /*** Load the Contact Information Options into the array ***/
58 $optgrps[SMOPT_GRP_CONTACT
] = _("Name and Address Options");
59 $optvals[SMOPT_GRP_CONTACT
] = array();
61 /* Build a simple array into which we will build options. */
64 if (!isset($edit_identity)) {
65 $edit_identity = TRUE;
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
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
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
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
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
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'
121 if ($edit_identity) {
122 $identities_link_value = '<a href="options_identities.php">'
123 . _("Edit Advanced Identities")
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
135 if ( $tzChangeAllowed ) {
136 $TZ_ARRAY[SMPREF_NONE
] = _("Same as server");
138 $aTimeZones = sq_get_tz_array();
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);
149 // sort time zones by name. sq_get_tz_array() returns sorted by key.
150 // asort($aTimeZones);
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;
158 // US Eastern standard time (America/New_York) - needs asort($aTimeZones)
159 //$TZ_ARRAY[$TzKey] = (isset($TzData['NAME']) ? $TzData['NAME']." ($TzKey)" : "($TzKey)");
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);
165 // (America/New_Your) US Eastern standard time
166 //$TZ_ARRAY[$TzKey] = "($TzKey)" . (isset($TzData['NAME']) ? ' '.$TzData['NAME'] : '');
170 $message = _("Error opening timezone config, contact administrator.");
173 // TODO: make error user friendly
174 if (isset($message)) {
175 plain_error_message($message, $color);
179 $optgrps[SMOPT_GRP_TZ
] = _("Timezone Options");
180 $optvals[SMOPT_GRP_TZ
] = array();
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
191 /*** Load the Reply Citation Options into the array ***/
192 $optgrps[SMOPT_GRP_REPLY
] = _("Reply Citation Options");
193 $optvals[SMOPT_GRP_REPLY
] = array();
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"))
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
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
223 /*** Load the Signature Options into the array ***/
224 $optgrps[SMOPT_GRP_SIG
] = _("Signature Options");
225 $optvals[SMOPT_GRP_SIG
] = array();
227 $optvals[SMOPT_GRP_SIG
][] = array(
228 'name' => 'use_signature',
229 'caption' => _("Use Signature"),
230 'type' => SMOPT_TYPE_BOOLEAN
,
231 'refresh' => SMOPT_REFRESH_NONE
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
241 /* Assemble all this together and return it as our result. */
249 /******************************************************************/
250 /** Define any specialized save functions for this option page. ***/
251 /******************************************************************/
254 * Saves the signature option.
256 function save_option_signature($option) {
257 global $data_dir, $username;
258 setSig($data_dir, $username, 'g', $option->new_value
);