Add some basic documentation, and remove some long-obsolete functions.
[squirrelmail.git] / include / options / personal.php
1 <?php
2
3 /**
4 * options_personal.php
5 *
6 * Copyright (c) 1999-2003 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 * $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 'quote_who' => _("Quote Who XML"),
177 'user-defined' => _("User-Defined"))
178 );
179
180 $optvals[SMOPT_GRP_REPLY][] = array(
181 'name' => 'reply_citation_start',
182 'caption' => _("User-Defined Citation Start"),
183 'type' => SMOPT_TYPE_STRING,
184 'refresh' => SMOPT_REFRESH_NONE,
185 'size' => SMOPT_SIZE_MEDIUM
186 );
187
188 $optvals[SMOPT_GRP_REPLY][] = array(
189 'name' => 'reply_citation_end',
190 'caption' => _("User-Defined Citation End"),
191 'type' => SMOPT_TYPE_STRING,
192 'refresh' => SMOPT_REFRESH_NONE,
193 'size' => SMOPT_SIZE_MEDIUM
194 );
195
196 /*** Load the Signature Options into the array ***/
197 $optgrps[SMOPT_GRP_SIG] = _("Signature Options");
198 $optvals[SMOPT_GRP_SIG] = array();
199
200 $optvals[SMOPT_GRP_SIG][] = array(
201 'name' => 'use_signature',
202 'caption' => _("Use Signature"),
203 'type' => SMOPT_TYPE_BOOLEAN,
204 'refresh' => SMOPT_REFRESH_NONE
205 );
206
207 $optvals[SMOPT_GRP_SIG][] = array(
208 'name' => 'prefix_sig',
209 'caption' => _("Prefix Signature with '-- ' Line"),
210 'type' => SMOPT_TYPE_BOOLEAN,
211 'refresh' => SMOPT_REFRESH_NONE
212 );
213
214 /* Assemble all this together and return it as our result. */
215 $result = array(
216 'grps' => $optgrps,
217 'vals' => $optvals
218 );
219 return ($result);
220 }
221
222 /******************************************************************/
223 /** Define any specialized save functions for this option page. ***/
224 /******************************************************************/
225
226 /**
227 * Saves the signature option.
228 */
229 function save_option_signature($option) {
230 global $data_dir, $username;
231 setSig($data_dir, $username, 'g', $option->new_value);
232 }
233
234 ?>