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