one PHP waning less
[squirrelmail.git] / src / options_personal.php
1 <?php
2
3 /**
4 * options_personal.php
5 *
6 * Copyright (c) 1999-2002 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 */
13
14 require_once('../functions/imap.php');
15 require_once('../functions/array.php');
16
17 /* Define the group constants for the personal options page. */
18 define('SMOPT_GRP_CONTACT', 0);
19 define('SMOPT_GRP_REPLY', 1);
20 define('SMOPT_GRP_SIG', 2);
21 define('SMOPT_GRP_TZ', 3);
22
23 /* Define the optpage load function for the personal options page. */
24 function load_optpage_data_personal() {
25 global $data_dir, $username, $edit_identity, $edit_name,
26 $full_name, $reply_to, $email_address, $signature;
27
28 /* Set the values of some global variables. */
29 $full_name = getPref($data_dir, $username, 'full_name');
30 $reply_to = getPref($data_dir, $username, 'reply_to');
31 $email_address = getPref($data_dir, $username, 'email_address');
32 $signature = getSig($data_dir, $username, 'g');
33
34 /* Build a simple array into which we will build options. */
35 $optgrps = array();
36 $optvals = array();
37
38 /******************************************************/
39 /* LOAD EACH GROUP OF OPTIONS INTO THE OPTIONS ARRAY. */
40 /******************************************************/
41
42 /*** Load the Contact Information Options into the array ***/
43 $optgrps[SMOPT_GRP_CONTACT] = _("Name and Address Options");
44 $optvals[SMOPT_GRP_CONTACT] = array();
45
46 /* Build a simple array into which we will build options. */
47 $optvals = array();
48
49 if ($edit_identity || $edit_name) {
50 $optvals[SMOPT_GRP_CONTACT][] = array(
51 'name' => 'full_name',
52 'caption' => _("Full Name"),
53 'type' => SMOPT_TYPE_STRING,
54 'refresh' => SMOPT_REFRESH_NONE,
55 'size' => SMOPT_SIZE_HUGE
56 );
57 } else {
58 $optvals[SMOPT_GRP_CONTACT][] = array(
59 'name' => 'full_name',
60 'caption' => _("Full Name"),
61 'type' => SMOPT_TYPE_COMMENT,
62 'refresh' => SMOPT_REFRESH_NONE,
63 'comment' => $full_name
64 );
65 }
66
67 if ($edit_identity) {
68 $optvals[SMOPT_GRP_CONTACT][] = array(
69 'name' => 'email_address',
70 'caption' => _("Email Address"),
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' => 'email_address',
78 'caption' => _("Email Address"),
79 'type' => SMOPT_TYPE_COMMENT,
80 'refresh' => SMOPT_REFRESH_NONE,
81 'comment' => $email_address
82 );
83 }
84
85 $optvals[SMOPT_GRP_CONTACT][] = array(
86 'name' => 'reply_to',
87 'caption' => _("Reply To"),
88 'type' => SMOPT_TYPE_STRING,
89 'refresh' => SMOPT_REFRESH_NONE,
90 'size' => SMOPT_SIZE_HUGE
91 );
92
93 $optvals[SMOPT_GRP_CONTACT][] = array(
94 'name' => 'signature',
95 'caption' => _("Signature"),
96 'type' => SMOPT_TYPE_TEXTAREA,
97 'refresh' => SMOPT_REFRESH_NONE,
98 'size' => SMOPT_SIZE_MEDIUM,
99 'save' => 'save_option_signature'
100 );
101
102 if ($edit_identity) {
103 $identities_link_value = '<A HREF="options_identities.php">'
104 . _("Edit Advanced Identities")
105 . '</A> '
106 . _("(discards changes made on this form so far)");
107 $optvals[SMOPT_GRP_CONTACT][] = array(
108 'name' => 'identities_link',
109 'caption' => _("Multiple Identities"),
110 'type' => SMOPT_TYPE_COMMENT,
111 'refresh' => SMOPT_REFRESH_NONE,
112 'comment' => $identities_link_value
113 );
114 }
115
116 $TZ_ARRAY[SMPREF_NONE] = _("Same as server");
117 $fd = fopen('../locale/timezones.cfg','r');
118 while (!feof ($fd)) {
119 $zone = fgets($fd, 1024);
120 if( $zone ) {
121 $zone = trim($zone);
122 $TZ_ARRAY["$zone"] = "$zone";
123 }
124 }
125 fclose ($fd);
126
127 $optgrps[SMOPT_GRP_TZ] = _("Timezone Options");
128 $optvals[SMOPT_GRP_TZ] = array();
129
130 $optvals[SMOPT_GRP_TZ][] = array(
131 'name' => 'timezone',
132 'caption' => _("Your current timezone"),
133 'type' => SMOPT_TYPE_STRLIST,
134 'refresh' => SMOPT_REFRESH_NONE,
135 'posvals' => $TZ_ARRAY
136 );
137
138 /*** Load the Reply Citation Options into the array ***/
139 $optgrps[SMOPT_GRP_REPLY] = _("Reply Citation Options");
140 $optvals[SMOPT_GRP_REPLY] = array();
141
142 $optvals[SMOPT_GRP_REPLY][] = array(
143 'name' => 'reply_citation_style',
144 'caption' => _("Reply Citation Style"),
145 'type' => SMOPT_TYPE_STRLIST,
146 'refresh' => SMOPT_REFRESH_NONE,
147 'posvals' => array(SMPREF_NONE => _("No Citation"),
148 'author_said' => _("AUTHOR Said"),
149 'quote_who' => _("Quote Who XML"),
150 'user-defined' => _("User-Defined"))
151 );
152
153 $optvals[SMOPT_GRP_REPLY][] = array(
154 'name' => 'reply_citation_start',
155 'caption' => _("User-Defined Citation Start"),
156 'type' => SMOPT_TYPE_STRING,
157 'refresh' => SMOPT_REFRESH_NONE,
158 'size' => SMOPT_SIZE_MEDIUM
159 );
160
161 $optvals[SMOPT_GRP_REPLY][] = array(
162 'name' => 'reply_citation_end',
163 'caption' => _("User-Defined Citation End"),
164 'type' => SMOPT_TYPE_STRING,
165 'refresh' => SMOPT_REFRESH_NONE,
166 'size' => SMOPT_SIZE_MEDIUM
167 );
168
169 /*** Load the Signature Options into the array ***/
170 $optgrps[SMOPT_GRP_SIG] = _("Signature Options");
171 $optvals[SMOPT_GRP_SIG] = array();
172
173 $optvals[SMOPT_GRP_SIG][] = array(
174 'name' => 'use_signature',
175 'caption' => _("Use Signature"),
176 'type' => SMOPT_TYPE_BOOLEAN,
177 'refresh' => SMOPT_REFRESH_NONE
178 );
179
180 $optvals[SMOPT_GRP_SIG][] = array(
181 'name' => 'prefix_sig',
182 'caption' => _("Prefix Signature with '-- ' Line"),
183 'type' => SMOPT_TYPE_BOOLEAN,
184 'refresh' => SMOPT_REFRESH_NONE
185 );
186
187 /* Assemble all this together and return it as our result. */
188 $result = array(
189 'grps' => $optgrps,
190 'vals' => $optvals
191 );
192 return ($result);
193 }
194
195 /******************************************************************/
196 /** Define any specialized save functions for this option page. ***/
197 /******************************************************************/
198
199 function save_option_signature($option) {
200 global $data_dir, $username;
201 setSig($data_dir, $username, 'g', $option->new_value);
202 }
203
204 ?>