script could be loaded when $edit_identity is set to false
[squirrelmail.git] / include / options / personal.php
CommitLineData
c36ed9cf 1<?php
cd2b7182 2
35586184 3/**
4 * options_personal.php
5 *
35586184 6 * Displays all options relating to personal information
7 *
47ccfad4 8 * @copyright &copy; 1999-2006 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. */
86725763 15require_once(SM_PATH . 'functions/imap.php');
2d3a630b 16require_once(SM_PATH . 'include/timezones.php');
01265fba 17
cbe5423b 18/* Define the group constants for the personal options page. */
19define('SMOPT_GRP_CONTACT', 0);
20define('SMOPT_GRP_REPLY', 1);
21define('SMOPT_GRP_SIG', 2);
397ddb13 22define('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 37function load_optpage_data_personal() {
01265fba 38 global $data_dir, $username, $edit_identity, $edit_name,
df442a10 39 $full_name, $reply_to, $email_address, $signature, $tzChangeAllowed,
2d3a630b 40 $color, $timeZone;
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',
674a2ca2 88 'caption' => _("E-mail Address"),
8a7d0669 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',
674a2ca2 96 'caption' => _("E-mail Address"),
8a7d0669 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) {
6fd95361 121 $identities_link_value = '<a href="options_identities.php">'
8a7d0669 122 . _("Edit Advanced Identities")
6fd95361 123 . '</a> '
8a7d0669 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 }
91e0dccc 133
867fed37 134 if ( $tzChangeAllowed || function_exists('date_default_timezone_set')) {
4b50568d 135 $TZ_ARRAY[SMPREF_NONE] = _("Same as server");
2d3a630b 136
137 $aTimeZones = sq_get_tz_array();
138 unset($message);
139 if (! empty($aTimeZones)) {
140 // check if current timezone is linked to other TZ and update it
141 if ($timeZone != SMPREF_NONE && $timeZone != "" &&
142 isset($aTimeZones[$timeZone]['LINK'])) {
143 $timeZone = $aTimeZones[$timeZone]['LINK'];
144 // TODO: recheck setting of $timeZone
145 // setPref($data_dir,$username,'timezone',$timeZone);
146 }
147
148 // sort time zones by name. sq_get_tz_array() returns sorted by key.
149 // asort($aTimeZones);
150
151 // add all 'TZ' entries to TZ_ARRAY
152 foreach ($aTimeZones as $TzKey => $TzData) {
153 if (! isset($TzData['LINK'])) {
154 // Old display format
155 $TZ_ARRAY[$TzKey] = $TzKey;
156
157 // US Eastern standard time (America/New_York) - needs asort($aTimeZones)
158 //$TZ_ARRAY[$TzKey] = (isset($TzData['NAME']) ? $TzData['NAME']." ($TzKey)" : "($TzKey)");
159
160 // US Eastern standard time if NAME is present or America/New_York if NAME not present
161 // needs sorting after all data is added or uasort()
162 //$TZ_ARRAY[$TzKey] = (isset($TzData['NAME']) ? $TzData['NAME'] : $TzKey);
163
164 // (America/New_Your) US Eastern standard time
165 //$TZ_ARRAY[$TzKey] = "($TzKey)" . (isset($TzData['NAME']) ? ' '.$TzData['NAME'] : '');
166 }
167 }
168 } else {
bb7173fa 169 $message = _("Error opening timezone config, contact administrator.");
170 }
2d3a630b 171
172 // TODO: make error user friendly
bb7173fa 173 if (isset($message)) {
174 plain_error_message($message, $color);
175 exit;
176 }
7e235a1a 177
4b50568d 178 $optgrps[SMOPT_GRP_TZ] = _("Timezone Options");
179 $optvals[SMOPT_GRP_TZ] = array();
7e235a1a 180
4b50568d 181 $optvals[SMOPT_GRP_TZ][] = array(
182 'name' => 'timezone',
183 'caption' => _("Your current timezone"),
184 'type' => SMOPT_TYPE_STRLIST,
185 'refresh' => SMOPT_REFRESH_NONE,
186 'posvals' => $TZ_ARRAY
187 );
188 }
91e0dccc 189
8a2e4d5b 190 /*** Load the Reply Citation Options into the array ***/
191 $optgrps[SMOPT_GRP_REPLY] = _("Reply Citation Options");
bbcafebd 192 $optvals[SMOPT_GRP_REPLY] = array();
193
194 $optvals[SMOPT_GRP_REPLY][] = array(
195 'name' => 'reply_citation_style',
196 'caption' => _("Reply Citation Style"),
197 'type' => SMOPT_TYPE_STRLIST,
198 'refresh' => SMOPT_REFRESH_NONE,
199 'posvals' => array(SMPREF_NONE => _("No Citation"),
0e1a248b 200 'author_said' => _("AUTHOR Wrote"),
201 'date_time_author' => _("On DATE, AUTHOR Wrote"),
bbcafebd 202 'quote_who' => _("Quote Who XML"),
203 'user-defined' => _("User-Defined"))
204 );
205
206 $optvals[SMOPT_GRP_REPLY][] = array(
207 'name' => 'reply_citation_start',
208 'caption' => _("User-Defined Citation Start"),
209 'type' => SMOPT_TYPE_STRING,
210 'refresh' => SMOPT_REFRESH_NONE,
211 'size' => SMOPT_SIZE_MEDIUM
212 );
213
214 $optvals[SMOPT_GRP_REPLY][] = array(
215 'name' => 'reply_citation_end',
216 'caption' => _("User-Defined Citation End"),
217 'type' => SMOPT_TYPE_STRING,
218 'refresh' => SMOPT_REFRESH_NONE,
219 'size' => SMOPT_SIZE_MEDIUM
220 );
221
8a2e4d5b 222 /*** Load the Signature Options into the array ***/
223 $optgrps[SMOPT_GRP_SIG] = _("Signature Options");
224 $optvals[SMOPT_GRP_SIG] = array();
bbcafebd 225
8a2e4d5b 226 $optvals[SMOPT_GRP_SIG][] = array(
bbcafebd 227 'name' => 'use_signature',
228 'caption' => _("Use Signature"),
229 'type' => SMOPT_TYPE_BOOLEAN,
230 'refresh' => SMOPT_REFRESH_NONE
231 );
232
8a2e4d5b 233 $optvals[SMOPT_GRP_SIG][] = array(
bbcafebd 234 'name' => 'prefix_sig',
235 'caption' => _("Prefix Signature with '-- ' Line"),
236 'type' => SMOPT_TYPE_BOOLEAN,
237 'refresh' => SMOPT_REFRESH_NONE
238 );
239
cbe5423b 240 /* Assemble all this together and return it as our result. */
241 $result = array(
242 'grps' => $optgrps,
243 'vals' => $optvals
244 );
245 return ($result);
246}
e7db48af 247
cbe5423b 248/******************************************************************/
249/** Define any specialized save functions for this option page. ***/
250/******************************************************************/
e7db48af 251
48af4b64 252/**
253 * Saves the signature option.
254 */
cbe5423b 255function save_option_signature($option) {
256 global $data_dir, $username;
01265fba 257 setSig($data_dir, $username, 'g', $option->new_value);
cbe5423b 258}
e7db48af 259
6fd95361 260?>