| 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 | /* SquirrelMail required files. */ |
| 15 | require_once(SM_PATH . 'functions/imap.php'); |
| 16 | require_once(SM_PATH . 'functions/array.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 | /* Define the optpage load function for the personal options page. */ |
| 25 | function load_optpage_data_personal() { |
| 26 | global $data_dir, $username, $edit_identity, $edit_name, |
| 27 | $full_name, $reply_to, $email_address, $signature; |
| 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'); |
| 32 | $email_address = getPref($data_dir, $username, 'email_address'); |
| 33 | $signature = getSig($data_dir, $username, 'g'); |
| 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 | /******************************************************/ |
| 42 | |
| 43 | /*** Load the Contact Information Options into the array ***/ |
| 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 | |
| 50 | if (!isset($edit_identity)) { |
| 51 | $edit_identity = TRUE; |
| 52 | } |
| 53 | |
| 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 | } |
| 71 | |
| 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 | } |
| 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 | |
| 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 | |
| 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 | } |
| 120 | |
| 121 | if ( !ini_get("safe_mode") ) { |
| 122 | $TZ_ARRAY[SMPREF_NONE] = _("Same as server"); |
| 123 | $fd = fopen('../locale/timezones.cfg','r'); |
| 124 | while (!feof ($fd)) { |
| 125 | $zone = fgets($fd, 1024); |
| 126 | if( $zone ) { |
| 127 | $zone = trim($zone); |
| 128 | $TZ_ARRAY["$zone"] = "$zone"; |
| 129 | } |
| 130 | } |
| 131 | fclose ($fd); |
| 132 | |
| 133 | $optgrps[SMOPT_GRP_TZ] = _("Timezone Options"); |
| 134 | $optvals[SMOPT_GRP_TZ] = array(); |
| 135 | |
| 136 | $optvals[SMOPT_GRP_TZ][] = array( |
| 137 | 'name' => 'timezone', |
| 138 | 'caption' => _("Your current timezone"), |
| 139 | 'type' => SMOPT_TYPE_STRLIST, |
| 140 | 'refresh' => SMOPT_REFRESH_NONE, |
| 141 | 'posvals' => $TZ_ARRAY |
| 142 | ); |
| 143 | } |
| 144 | |
| 145 | /*** Load the Reply Citation Options into the array ***/ |
| 146 | $optgrps[SMOPT_GRP_REPLY] = _("Reply Citation Options"); |
| 147 | $optvals[SMOPT_GRP_REPLY] = array(); |
| 148 | |
| 149 | $optvals[SMOPT_GRP_REPLY][] = array( |
| 150 | 'name' => 'reply_citation_style', |
| 151 | 'caption' => _("Reply Citation Style"), |
| 152 | 'type' => SMOPT_TYPE_STRLIST, |
| 153 | 'refresh' => SMOPT_REFRESH_NONE, |
| 154 | 'posvals' => array(SMPREF_NONE => _("No Citation"), |
| 155 | 'author_said' => _("AUTHOR Said"), |
| 156 | 'quote_who' => _("Quote Who XML"), |
| 157 | 'user-defined' => _("User-Defined")) |
| 158 | ); |
| 159 | |
| 160 | $optvals[SMOPT_GRP_REPLY][] = array( |
| 161 | 'name' => 'reply_citation_start', |
| 162 | 'caption' => _("User-Defined Citation Start"), |
| 163 | 'type' => SMOPT_TYPE_STRING, |
| 164 | 'refresh' => SMOPT_REFRESH_NONE, |
| 165 | 'size' => SMOPT_SIZE_MEDIUM |
| 166 | ); |
| 167 | |
| 168 | $optvals[SMOPT_GRP_REPLY][] = array( |
| 169 | 'name' => 'reply_citation_end', |
| 170 | 'caption' => _("User-Defined Citation End"), |
| 171 | 'type' => SMOPT_TYPE_STRING, |
| 172 | 'refresh' => SMOPT_REFRESH_NONE, |
| 173 | 'size' => SMOPT_SIZE_MEDIUM |
| 174 | ); |
| 175 | |
| 176 | /*** Load the Signature Options into the array ***/ |
| 177 | $optgrps[SMOPT_GRP_SIG] = _("Signature Options"); |
| 178 | $optvals[SMOPT_GRP_SIG] = array(); |
| 179 | |
| 180 | $optvals[SMOPT_GRP_SIG][] = array( |
| 181 | 'name' => 'use_signature', |
| 182 | 'caption' => _("Use Signature"), |
| 183 | 'type' => SMOPT_TYPE_BOOLEAN, |
| 184 | 'refresh' => SMOPT_REFRESH_NONE |
| 185 | ); |
| 186 | |
| 187 | $optvals[SMOPT_GRP_SIG][] = array( |
| 188 | 'name' => 'prefix_sig', |
| 189 | 'caption' => _("Prefix Signature with '-- ' Line"), |
| 190 | 'type' => SMOPT_TYPE_BOOLEAN, |
| 191 | 'refresh' => SMOPT_REFRESH_NONE |
| 192 | ); |
| 193 | |
| 194 | /* Assemble all this together and return it as our result. */ |
| 195 | $result = array( |
| 196 | 'grps' => $optgrps, |
| 197 | 'vals' => $optvals |
| 198 | ); |
| 199 | return ($result); |
| 200 | } |
| 201 | |
| 202 | /******************************************************************/ |
| 203 | /** Define any specialized save functions for this option page. ***/ |
| 204 | /******************************************************************/ |
| 205 | |
| 206 | function save_option_signature($option) { |
| 207 | global $data_dir, $username; |
| 208 | setSig($data_dir, $username, 'g', $option->new_value); |
| 209 | } |
| 210 | |
| 211 | ?> |