Replacing tabs with spaces, trimming white space at EOL and newline at EOF
[squirrelmail.git] / include / options / personal.php
1 <?php
2
3 /**
4 * options_personal.php
5 *
6 * Copyright (c) 1999-2004 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
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;
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' => _("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 }
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 $tzfile = SM_PATH . 'locale/timezones.cfg';
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 }
144 while (!feof ($fd)) {
145 $zone = fgets($fd, 1024);
146 if( $zone ) {
147 $zone = trim($zone);
148 $TZ_ARRAY[$zone] = $zone;
149 }
150 }
151 fclose ($fd);
152
153 $optgrps[SMOPT_GRP_TZ] = _("Timezone Options");
154 $optvals[SMOPT_GRP_TZ] = array();
155
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
165 /*** Load the Reply Citation Options into the array ***/
166 $optgrps[SMOPT_GRP_REPLY] = _("Reply Citation Options");
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"),
176 'date_time_author' => _("On DATE, AUTHOR Said"),
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
197 /*** Load the Signature Options into the array ***/
198 $optgrps[SMOPT_GRP_SIG] = _("Signature Options");
199 $optvals[SMOPT_GRP_SIG] = array();
200
201 $optvals[SMOPT_GRP_SIG][] = array(
202 'name' => 'use_signature',
203 'caption' => _("Use Signature"),
204 'type' => SMOPT_TYPE_BOOLEAN,
205 'refresh' => SMOPT_REFRESH_NONE
206 );
207
208 $optvals[SMOPT_GRP_SIG][] = array(
209 'name' => 'prefix_sig',
210 'caption' => _("Prefix Signature with '-- ' Line"),
211 'type' => SMOPT_TYPE_BOOLEAN,
212 'refresh' => SMOPT_REFRESH_NONE
213 );
214
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 }
222
223 /******************************************************************/
224 /** Define any specialized save functions for this option page. ***/
225 /******************************************************************/
226
227 /**
228 * Saves the signature option.
229 */
230 function save_option_signature($option) {
231 global $data_dir, $username;
232 setSig($data_dir, $username, 'g', $option->new_value);
233 }
234
235 ?>