New icon theming. Also added basic template for left_main.php
[squirrelmail.git] / include / options / personal.php
1 <?php
2
3 /**
4 * options_personal.php
5 *
6 * Displays all options relating to personal information
7 *
8 * @copyright &copy; 1999-2006 The SquirrelMail Project Team
9 * @license http://opensource.org/licenses/gpl-license.php GNU Public License
10 * @version $Id$
11 * @package squirrelmail
12 */
13
14 /** SquirrelMail required files. */
15 require_once(SM_PATH . 'functions/imap.php');
16 require_once(SM_PATH . 'include/timezones.php');
17
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);
22 define('SMOPT_GRP_TZ', 3);
23
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 */
37 function load_optpage_data_personal() {
38 global $data_dir, $username, $edit_identity, $edit_name,
39 $full_name, $reply_to, $email_address, $signature, $tzChangeAllowed,
40 $color, $timeZone;
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');
45 $email_address = getPref($data_dir, $username, 'email_address');
46 $signature = getSig($data_dir, $username, 'g');
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 /******************************************************/
55
56 /*** Load the Contact Information Options into the array ***/
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
63 if (!isset($edit_identity)) {
64 $edit_identity = TRUE;
65 }
66
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 }
84
85 if ($edit_identity) {
86 $optvals[SMOPT_GRP_CONTACT][] = array(
87 'name' => 'email_address',
88 'caption' => _("E-mail 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' => _("E-mail Address"),
97 'type' => SMOPT_TYPE_COMMENT,
98 'refresh' => SMOPT_REFRESH_NONE,
99 'comment' => $email_address
100 );
101 }
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
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
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 }
133
134 if ( $tzChangeAllowed ) {
135 $TZ_ARRAY[SMPREF_NONE] = _("Same as server");
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 {
169 $message = _("Error opening timezone config, contact administrator.");
170 }
171
172 // TODO: make error user friendly
173 if (isset($message)) {
174 plain_error_message($message, $color);
175 exit;
176 }
177
178 $optgrps[SMOPT_GRP_TZ] = _("Timezone Options");
179 $optvals[SMOPT_GRP_TZ] = array();
180
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 }
189
190 /*** Load the Reply Citation Options into the array ***/
191 $optgrps[SMOPT_GRP_REPLY] = _("Reply Citation Options");
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"),
200 'author_said' => _("AUTHOR Wrote"),
201 'date_time_author' => _("On DATE, AUTHOR Wrote"),
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
222 /*** Load the Signature Options into the array ***/
223 $optgrps[SMOPT_GRP_SIG] = _("Signature Options");
224 $optvals[SMOPT_GRP_SIG] = array();
225
226 $optvals[SMOPT_GRP_SIG][] = array(
227 'name' => 'use_signature',
228 'caption' => _("Use Signature"),
229 'type' => SMOPT_TYPE_BOOLEAN,
230 'refresh' => SMOPT_REFRESH_NONE
231 );
232
233 $optvals[SMOPT_GRP_SIG][] = array(
234 'name' => 'prefix_sig',
235 'caption' => _("Prefix Signature with '-- ' Line"),
236 'type' => SMOPT_TYPE_BOOLEAN,
237 'refresh' => SMOPT_REFRESH_NONE
238 );
239
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 }
247
248 /******************************************************************/
249 /** Define any specialized save functions for this option page. ***/
250 /******************************************************************/
251
252 /**
253 * Saves the signature option.
254 */
255 function save_option_signature($option) {
256 global $data_dir, $username;
257 setSig($data_dir, $username, 'g', $option->new_value);
258 }
259
260 ?>