| 1 | <?php |
|---|
| 2 | |
|---|
| 3 | /* |
|---|
| 4 | +-----------------------------------------------------------------------+ |
|---|
| 5 | | program/steps/settings/func.inc | |
|---|
| 6 | | | |
|---|
| 7 | | This file is part of the RoundCube Webmail client | |
|---|
| 8 | | Copyright (C) 2005-2007, RoundCube Dev. - Switzerland | |
|---|
| 9 | | Licensed under the GNU GPL | |
|---|
| 10 | | | |
|---|
| 11 | | PURPOSE: | |
|---|
| 12 | | Provide functionality for user's settings & preferences | |
|---|
| 13 | | | |
|---|
| 14 | +-----------------------------------------------------------------------+ |
|---|
| 15 | | Author: Thomas Bruederli <roundcube@gmail.com> | |
|---|
| 16 | +-----------------------------------------------------------------------+ |
|---|
| 17 | |
|---|
| 18 | $Id$ |
|---|
| 19 | |
|---|
| 20 | */ |
|---|
| 21 | |
|---|
| 22 | if (!$OUTPUT->ajax_call) |
|---|
| 23 | $OUTPUT->set_pagetitle(rcube_label('preferences')); |
|---|
| 24 | |
|---|
| 25 | |
|---|
| 26 | // similar function as /steps/settings/identities.inc::rcmail_identity_frame() |
|---|
| 27 | function rcmail_preferences_frame($attrib) |
|---|
| 28 | { |
|---|
| 29 | global $OUTPUT; |
|---|
| 30 | |
|---|
| 31 | if (!$attrib['id']) |
|---|
| 32 | $attrib['id'] = 'rcmprefsframe'; |
|---|
| 33 | |
|---|
| 34 | $attrib['name'] = $attrib['id']; |
|---|
| 35 | |
|---|
| 36 | $OUTPUT->set_env('contentframe', $attrib['name']); |
|---|
| 37 | $OUTPUT->set_env('blankpage', $attrib['src'] ? $OUTPUT->abs_url($attrib['src']) : 'program/blank.gif'); |
|---|
| 38 | |
|---|
| 39 | return html::iframe($attrib); |
|---|
| 40 | } |
|---|
| 41 | |
|---|
| 42 | |
|---|
| 43 | function rcmail_sections_list($attrib) |
|---|
| 44 | { |
|---|
| 45 | global $RCMAIL; |
|---|
| 46 | |
|---|
| 47 | // add id to message list table if not specified |
|---|
| 48 | if (!strlen($attrib['id'])) |
|---|
| 49 | $attrib['id'] = 'rcmsectionslist'; |
|---|
| 50 | |
|---|
| 51 | list($list, $cols) = rcmail_user_prefs(); |
|---|
| 52 | |
|---|
| 53 | // create XHTML table |
|---|
| 54 | $out = rcube_table_output($attrib, $list, $cols, 'id'); |
|---|
| 55 | |
|---|
| 56 | // set client env |
|---|
| 57 | $RCMAIL->output->add_gui_object('sectionslist', $attrib['id']); |
|---|
| 58 | $RCMAIL->output->include_script('list.js'); |
|---|
| 59 | |
|---|
| 60 | return $out; |
|---|
| 61 | } |
|---|
| 62 | |
|---|
| 63 | |
|---|
| 64 | function rcmail_identities_list($attrib) |
|---|
| 65 | { |
|---|
| 66 | global $OUTPUT, $USER, $RCMAIL; |
|---|
| 67 | |
|---|
| 68 | // add id to message list table if not specified |
|---|
| 69 | if (!strlen($attrib['id'])) |
|---|
| 70 | $attrib['id'] = 'rcmIdentitiesList'; |
|---|
| 71 | |
|---|
| 72 | // get all identites from DB and define list of cols to be displayed |
|---|
| 73 | $plugin = $RCMAIL->plugins->exec_hook('list_identities', array( |
|---|
| 74 | 'list' => $USER->list_identities(), |
|---|
| 75 | 'cols' => array('name', 'email'))); |
|---|
| 76 | |
|---|
| 77 | // create XHTML table |
|---|
| 78 | $out = rcube_table_output($attrib, $plugin['list'], $plugin['cols'], 'identity_id'); |
|---|
| 79 | |
|---|
| 80 | // set client env |
|---|
| 81 | $OUTPUT->add_gui_object('identitieslist', $attrib['id']); |
|---|
| 82 | |
|---|
| 83 | return $out; |
|---|
| 84 | } |
|---|
| 85 | |
|---|
| 86 | |
|---|
| 87 | // similar function as in /steps/addressbook/edit.inc |
|---|
| 88 | function get_form_tags($attrib, $action, $id = null, $hidden = null) |
|---|
| 89 | { |
|---|
| 90 | global $EDIT_FORM, $RCMAIL; |
|---|
| 91 | |
|---|
| 92 | $form_start = $form_end = ''; |
|---|
| 93 | |
|---|
| 94 | if (empty($EDIT_FORM)) { |
|---|
| 95 | $request_key = $action . (isset($id) ? '.'.$id : ''); |
|---|
| 96 | $form_start = $RCMAIL->output->request_form(array( |
|---|
| 97 | 'name' => 'form', 'method' => 'post', |
|---|
| 98 | 'task' => $RCMAIL->task, 'action' => $action, |
|---|
| 99 | 'request' => $request_key, 'noclose' => true) + $attrib); |
|---|
| 100 | |
|---|
| 101 | if (is_array($hidden)) { |
|---|
| 102 | $hiddenfields = new html_hiddenfield($hidden); |
|---|
| 103 | $form_start .= $hiddenfields->show(); |
|---|
| 104 | } |
|---|
| 105 | |
|---|
| 106 | $form_end = !strlen($attrib['form']) ? '</form>' : ''; |
|---|
| 107 | |
|---|
| 108 | $EDIT_FORM = !empty($attrib['form']) ? $attrib['form'] : 'form'; |
|---|
| 109 | $RCMAIL->output->add_gui_object('editform', $EDIT_FORM); |
|---|
| 110 | } |
|---|
| 111 | |
|---|
| 112 | return array($form_start, $form_end); |
|---|
| 113 | } |
|---|
| 114 | |
|---|
| 115 | |
|---|
| 116 | function rcmail_user_prefs($current=null) |
|---|
| 117 | { |
|---|
| 118 | global $RCMAIL; |
|---|
| 119 | |
|---|
| 120 | $sections['general'] = array('id' => 'general', 'section' => rcube_label('uisettings')); |
|---|
| 121 | $sections['mailbox'] = array('id' => 'mailbox', 'section' => rcube_label('mailboxview')); |
|---|
| 122 | $sections['compose'] = array('id' => 'compose', 'section' => rcube_label('messagescomposition')); |
|---|
| 123 | $sections['mailview'] = array('id' => 'mailview','section' => rcube_label('messagesdisplaying')); |
|---|
| 124 | $sections['folders'] = array('id' => 'folders', 'section' => rcube_label('specialfolders')); |
|---|
| 125 | $sections['server'] = array('id' => 'server', 'section' => rcube_label('serversettings')); |
|---|
| 126 | |
|---|
| 127 | // hook + define list cols |
|---|
| 128 | $plugin = $RCMAIL->plugins->exec_hook('list_prefs_sections', |
|---|
| 129 | array('list' => $sections, 'cols' => array('section'))); |
|---|
| 130 | |
|---|
| 131 | $sections = $plugin['list']; |
|---|
| 132 | |
|---|
| 133 | $config = $RCMAIL->config->all(); |
|---|
| 134 | $no_override = array_flip($RCMAIL->config->get('dont_override', array())); |
|---|
| 135 | |
|---|
| 136 | foreach ($sections as $idx => $sect) { |
|---|
| 137 | |
|---|
| 138 | if ($current && $sect['id'] != $current) |
|---|
| 139 | continue; |
|---|
| 140 | |
|---|
| 141 | $blocks = array(); |
|---|
| 142 | |
|---|
| 143 | switch ($sect['id']) { |
|---|
| 144 | // general |
|---|
| 145 | case 'general': |
|---|
| 146 | |
|---|
| 147 | $blocks = array( |
|---|
| 148 | 'main' => array('name' => Q(rcube_label('mainoptions'))), |
|---|
| 149 | 'list' => array('name' => Q(rcube_label('listoptions'))), |
|---|
| 150 | ); |
|---|
| 151 | |
|---|
| 152 | // language selection |
|---|
| 153 | if (!isset($no_override['language'])) { |
|---|
| 154 | $a_lang = $RCMAIL->list_languages(); |
|---|
| 155 | asort($a_lang); |
|---|
| 156 | |
|---|
| 157 | $field_id = 'rcmfd_lang'; |
|---|
| 158 | $select_lang = new html_select(array('name' => '_language', 'id' => $field_id)); |
|---|
| 159 | $select_lang->add(array_values($a_lang), array_keys($a_lang)); |
|---|
| 160 | |
|---|
| 161 | $blocks['main']['options']['language'] = array( |
|---|
| 162 | 'title' => html::label($field_id, Q(rcube_label('language'))), |
|---|
| 163 | 'content' => $select_lang->show($RCMAIL->user->language), |
|---|
| 164 | ); |
|---|
| 165 | } |
|---|
| 166 | |
|---|
| 167 | // show page size selection |
|---|
| 168 | if (!isset($no_override['timezone'])) { |
|---|
| 169 | $field_id = 'rcmfd_timezone'; |
|---|
| 170 | $select_timezone = new html_select(array('name' => '_timezone', 'id' => $field_id, 'onchange' => "document.getElementById('rcmfd_dst').disabled=this.selectedIndex==0")); |
|---|
| 171 | $select_timezone->add(rcube_label('autodetect'), 'auto'); |
|---|
| 172 | $select_timezone->add('(GMT -11:00) Midway Island, Samoa', '-11'); |
|---|
| 173 | $select_timezone->add('(GMT -10:00) Hawaii', '-10'); |
|---|
| 174 | $select_timezone->add('(GMT -9:30) Marquesas Islands', '-9.5'); |
|---|
| 175 | $select_timezone->add('(GMT -9:00) Alaska', '-9'); |
|---|
| 176 | $select_timezone->add('(GMT -8:00) Pacific Time (US/Canada)', '-8'); |
|---|
| 177 | $select_timezone->add('(GMT -7:00) Mountain Time (US/Canada)', '-7'); |
|---|
| 178 | $select_timezone->add('(GMT -6:00) Central Time (US/Canada), Mexico City', '-6'); |
|---|
| 179 | $select_timezone->add('(GMT -5:00) Eastern Time (US/Canada), Bogota, Lima', '-5'); |
|---|
| 180 | $select_timezone->add('(GMT -4:30) Caracas', '-4.5'); |
|---|
| 181 | $select_timezone->add('(GMT -4:00) Atlantic Time (Canada), La Paz', '-4'); |
|---|
| 182 | $select_timezone->add('(GMT -3:30) Nfld Time (Canada), Nfld, S. Labador', '-3.5'); |
|---|
| 183 | $select_timezone->add('(GMT -3:00) Brazil, Buenos Aires, Georgetown', '-3'); |
|---|
| 184 | $select_timezone->add('(GMT -2:00) Mid-Atlantic', '-2'); |
|---|
| 185 | $select_timezone->add('(GMT -1:00) Azores, Cape Verde Islands', '-1'); |
|---|
| 186 | $select_timezone->add('(GMT) Western Europe, London, Lisbon, Casablanca', '0'); |
|---|
| 187 | $select_timezone->add('(GMT +1:00) Central European Time', '1'); |
|---|
| 188 | $select_timezone->add('(GMT +2:00) EET: Tallinn, Helsinki, Kaliningrad, South Africa', '2'); |
|---|
| 189 | $select_timezone->add('(GMT +3:00) Baghdad, Kuwait, Riyadh, Moscow, Nairobi', '3'); |
|---|
| 190 | $select_timezone->add('(GMT +3:30) Tehran', '3.5'); |
|---|
| 191 | $select_timezone->add('(GMT +4:00) Abu Dhabi, Muscat, Baku, Tbilisi', '4'); |
|---|
| 192 | $select_timezone->add('(GMT +4:30) Kabul', '4.5'); |
|---|
| 193 | $select_timezone->add('(GMT +5:00) Ekaterinburg, Islamabad, Karachi', '5'); |
|---|
| 194 | $select_timezone->add('(GMT +5:30) Chennai, Kolkata, Mumbai, New Delhi', '5.5'); |
|---|
| 195 | $select_timezone->add('(GMT +5:45) Kathmandu', '5.75'); |
|---|
| 196 | $select_timezone->add('(GMT +6:00) Almaty, Dhaka, Colombo', '6'); |
|---|
| 197 | $select_timezone->add('(GMT +6:30) Cocos Islands, Myanmar', '6.5'); |
|---|
| 198 | $select_timezone->add('(GMT +7:00) Bangkok, Hanoi, Jakarta', '7'); |
|---|
| 199 | $select_timezone->add('(GMT +8:00) Beijing, Perth, Singapore, Taipei', '8'); |
|---|
| 200 | $select_timezone->add('(GMT +8:45) Caiguna, Eucla, Border Village', '8.75'); |
|---|
| 201 | $select_timezone->add('(GMT +9:00) Tokyo, Seoul, Yakutsk', '9'); |
|---|
| 202 | $select_timezone->add('(GMT +9:30) Adelaide, Darwin', '9.5'); |
|---|
| 203 | $select_timezone->add('(GMT +10:00) EAST/AEST: Sydney, Guam, Vladivostok', '10'); |
|---|
| 204 | $select_timezone->add('(GMT +10:30) New South Wales', '10.5'); |
|---|
| 205 | $select_timezone->add('(GMT +11:00) Magadan, Solomon Islands', '11'); |
|---|
| 206 | $select_timezone->add('(GMT +11:30) Norfolk Island', '11.5'); |
|---|
| 207 | $select_timezone->add('(GMT +12:00) Auckland, Wellington, Kamchatka', '12'); |
|---|
| 208 | $select_timezone->add('(GMT +12:45) Chatham Islands', '12.75'); |
|---|
| 209 | $select_timezone->add('(GMT +13:00) Tonga, Pheonix Islands', '13'); |
|---|
| 210 | $select_timezone->add('(GMT +14:00) Kiribati', '14'); |
|---|
| 211 | |
|---|
| 212 | $blocks['main']['options']['timezone'] = array( |
|---|
| 213 | 'title' => html::label($field_id, Q(rcube_label('timezone'))), |
|---|
| 214 | 'content' => $select_timezone->show((string)$config['timezone']), |
|---|
| 215 | ); |
|---|
| 216 | } |
|---|
| 217 | |
|---|
| 218 | // daylight savings |
|---|
| 219 | if (!isset($no_override['dst_active'])) { |
|---|
| 220 | $field_id = 'rcmfd_dst'; |
|---|
| 221 | $input_dst = new html_checkbox(array('name' => '_dst_active', 'id' => $field_id, 'value' => 1, 'disabled' => ($config['timezone'] === 'auto'))); |
|---|
| 222 | |
|---|
| 223 | $blocks['main']['options']['dstactive'] = array( |
|---|
| 224 | 'title' => html::label($field_id, Q(rcube_label('dstactive'))), |
|---|
| 225 | 'content' => $input_dst->show($config['dst_active']), |
|---|
| 226 | ); |
|---|
| 227 | } |
|---|
| 228 | |
|---|
| 229 | // MM: Show checkbox for toggling 'pretty dates' |
|---|
| 230 | if (!isset($no_override['prettydate'])) { |
|---|
| 231 | $field_id = 'rcmfd_prettydate'; |
|---|
| 232 | $input_prettydate = new html_checkbox(array('name' => '_pretty_date', 'id' => $field_id, 'value' => 1)); |
|---|
| 233 | |
|---|
| 234 | $blocks['main']['options']['prettydate'] = array( |
|---|
| 235 | 'title' => html::label($field_id, Q(rcube_label('prettydate'))), |
|---|
| 236 | 'content' => $input_prettydate->show($config['prettydate']?1:0), |
|---|
| 237 | ); |
|---|
| 238 | } |
|---|
| 239 | |
|---|
| 240 | // show page size selection |
|---|
| 241 | if (!isset($no_override['pagesize'])) { |
|---|
| 242 | $field_id = 'rcmfd_pgsize'; |
|---|
| 243 | $input_pagesize = new html_inputfield(array('name' => '_pagesize', 'id' => $field_id, 'size' => 5)); |
|---|
| 244 | |
|---|
| 245 | $blocks['list']['options']['pagesize'] = array( |
|---|
| 246 | 'title' => html::label($field_id, Q(rcube_label('pagesize'))), |
|---|
| 247 | 'content' => $input_pagesize->show($config['pagesize']), |
|---|
| 248 | ); |
|---|
| 249 | } |
|---|
| 250 | |
|---|
| 251 | // Show checkbox for toggling 'index_sort' |
|---|
| 252 | if (!isset($no_override['index_sort'])) { |
|---|
| 253 | $field_id = 'rcmfd_indexsort'; |
|---|
| 254 | $input_indexsort = new html_checkbox(array('name' => '_index_sort', 'id' => $field_id, 'value' => 1)); |
|---|
| 255 | |
|---|
| 256 | $blocks['list']['options']['index_sort'] = array( |
|---|
| 257 | 'title' => html::label($field_id, Q(rcube_label('indexsort'))), |
|---|
| 258 | 'content' => $input_indexsort->show($config['index_sort']?1:0), |
|---|
| 259 | ); |
|---|
| 260 | } |
|---|
| 261 | |
|---|
| 262 | // show drop-down for available skins |
|---|
| 263 | if (!isset($no_override['skin'])) { |
|---|
| 264 | $skins = rcmail_get_skins(); |
|---|
| 265 | |
|---|
| 266 | if (count($skins) > 1) { |
|---|
| 267 | $field_id = 'rcmfd_skin'; |
|---|
| 268 | $input_skin = new html_select(array('name'=>'_skin', 'id'=>$field_id)); |
|---|
| 269 | |
|---|
| 270 | foreach($skins as $skin) |
|---|
| 271 | $input_skin->add($skin, $skin); |
|---|
| 272 | |
|---|
| 273 | $blocks['main']['options']['skin'] = array( |
|---|
| 274 | 'title' => html::label($field_id, Q(rcube_label('skin'))), |
|---|
| 275 | 'content' => $input_skin->show($config['skin']), |
|---|
| 276 | ); |
|---|
| 277 | } |
|---|
| 278 | } |
|---|
| 279 | |
|---|
| 280 | break; |
|---|
| 281 | |
|---|
| 282 | // Mailbox view (mail screen) |
|---|
| 283 | case 'mailbox': |
|---|
| 284 | |
|---|
| 285 | $blocks = array( |
|---|
| 286 | 'main' => array('name' => Q(rcube_label('mainoptions'))), |
|---|
| 287 | 'new_message' => array('name' => Q(rcube_label('newmessage'))), |
|---|
| 288 | ); |
|---|
| 289 | |
|---|
| 290 | // show config parameter for preview pane |
|---|
| 291 | if (!isset($no_override['preview_pane'])) { |
|---|
| 292 | $field_id = 'rcmfd_preview'; |
|---|
| 293 | $input_preview = new html_checkbox(array('name' => '_preview_pane', 'id' => $field_id, 'value' => 1)); |
|---|
| 294 | |
|---|
| 295 | $blocks['main']['options']['preview_pane'] = array( |
|---|
| 296 | 'title' => html::label($field_id, Q(rcube_label('previewpane'))), |
|---|
| 297 | 'content' => $input_preview->show($config['preview_pane']?1:0), |
|---|
| 298 | ); |
|---|
| 299 | } |
|---|
| 300 | |
|---|
| 301 | if (!isset($no_override['mdn_requests'])) { |
|---|
| 302 | $field_id = 'rcmfd_mdn_requests'; |
|---|
| 303 | $select_mdn_requests = new html_select(array('name' => '_mdn_requests', 'id' => $field_id)); |
|---|
| 304 | $select_mdn_requests->add(rcube_label('askuser'), 0); |
|---|
| 305 | $select_mdn_requests->add(rcube_label('autosend'), 1); |
|---|
| 306 | $select_mdn_requests->add(rcube_label('ignore'), 2); |
|---|
| 307 | |
|---|
| 308 | $blocks['main']['options']['mdn_requests'] = array( |
|---|
| 309 | 'title' => html::label($field_id, Q(rcube_label('mdnrequests'))), |
|---|
| 310 | 'content' => $select_mdn_requests->show($config['mdn_requests']), |
|---|
| 311 | ); |
|---|
| 312 | } |
|---|
| 313 | |
|---|
| 314 | if (!isset($no_override['focus_on_new_message'])) { |
|---|
| 315 | $field_id = 'rcmfd_focus_on_new_message'; |
|---|
| 316 | $input_focus_on_new_message = new html_checkbox(array('name' => '_focus_on_new_message', 'id' => $field_id, 'value' => 1)); |
|---|
| 317 | |
|---|
| 318 | $blocks['new_message']['options']['focus_on_new_message'] = array( |
|---|
| 319 | 'title' => html::label($field_id, Q(rcube_label('focusonnewmessage'))), |
|---|
| 320 | 'content' => $input_focus_on_new_message->show($config['focus_on_new_message']?1:0), |
|---|
| 321 | ); |
|---|
| 322 | } |
|---|
| 323 | |
|---|
| 324 | if (!isset($no_override['keep_alive'])) { |
|---|
| 325 | $field_id = 'rcmfd_keep_alive'; |
|---|
| 326 | $select_keep_alive = new html_select(array('name' => '_keep_alive', 'id' => $field_id)); |
|---|
| 327 | |
|---|
| 328 | foreach(array(1, 3, 5, 10, 15, 30, 60) as $min) |
|---|
| 329 | if((!$config['min_keep_alive'] || $config['min_keep_alive'] <= $min * 60) |
|---|
| 330 | && (!$config['session_lifetime'] || $config['session_lifetime'] > $min)) { |
|---|
| 331 | $select_keep_alive->add(rcube_label(array('name' => 'everynminutes', 'vars' => array('n' => $min))), $min); |
|---|
| 332 | } |
|---|
| 333 | |
|---|
| 334 | $blocks['new_message']['options']['keep_alive'] = array( |
|---|
| 335 | 'title' => html::label($field_id, Q(rcube_label('keepalive'))), |
|---|
| 336 | 'content' => $select_keep_alive->show($config['keep_alive']/60), |
|---|
| 337 | ); |
|---|
| 338 | } |
|---|
| 339 | |
|---|
| 340 | if (!isset($no_override['check_all_folders'])) { |
|---|
| 341 | $field_id = 'rcmfd_check_all_folders'; |
|---|
| 342 | $input_check_all = new html_checkbox(array('name' => '_check_all_folders', 'id' => $field_id, 'value' => 1)); |
|---|
| 343 | |
|---|
| 344 | $blocks['new_message']['options']['check_all_folders'] = array( |
|---|
| 345 | 'title' => html::label($field_id, Q(rcube_label('checkallfolders'))), |
|---|
| 346 | 'content' => $input_check_all->show($config['check_all_folders']?1:0), |
|---|
| 347 | ); |
|---|
| 348 | } |
|---|
| 349 | |
|---|
| 350 | break; |
|---|
| 351 | |
|---|
| 352 | // Message viewing |
|---|
| 353 | case 'mailview': |
|---|
| 354 | |
|---|
| 355 | $blocks = array( |
|---|
| 356 | 'main' => array('name' => Q(rcube_label('mainoptions'))), |
|---|
| 357 | ); |
|---|
| 358 | |
|---|
| 359 | // show checkbox for HTML/plaintext messages |
|---|
| 360 | if (!isset($no_override['prefer_html'])) { |
|---|
| 361 | $field_id = 'rcmfd_htmlmsg'; |
|---|
| 362 | $input_preferhtml = new html_checkbox(array('name' => '_prefer_html', 'id' => $field_id, 'value' => 1, |
|---|
| 363 | 'onchange' => JS_OBJECT_NAME.'.toggle_prefer_html(this)')); |
|---|
| 364 | |
|---|
| 365 | $blocks['main']['options']['prefer_html'] = array( |
|---|
| 366 | 'title' => html::label($field_id, Q(rcube_label('preferhtml'))), |
|---|
| 367 | 'content' => $input_preferhtml->show($config['prefer_html']?1:0), |
|---|
| 368 | ); |
|---|
| 369 | } |
|---|
| 370 | |
|---|
| 371 | if (!isset($no_override['show_images'])) { |
|---|
| 372 | $field_id = 'rcmfd_show_images'; |
|---|
| 373 | $input_show_images = new html_select(array('name' => '_show_images', 'id' => $field_id)); |
|---|
| 374 | $input_show_images->add(rcube_label('never'), 0); |
|---|
| 375 | $input_show_images->add(rcube_label('fromknownsenders'), 1); |
|---|
| 376 | $input_show_images->add(rcube_label('always'), 2); |
|---|
| 377 | |
|---|
| 378 | $blocks['main']['options']['show_images'] = array( |
|---|
| 379 | 'title' => html::label($field_id, Q(rcube_label('showremoteimages'))), |
|---|
| 380 | 'content' => $input_show_images->show($config['show_images']), |
|---|
| 381 | ); |
|---|
| 382 | } |
|---|
| 383 | |
|---|
| 384 | if (!isset($no_override['inline_images'])) { |
|---|
| 385 | $field_id = 'rcmfd_inline_images'; |
|---|
| 386 | $input_inline_images = new html_checkbox(array('name' => '_inline_images', 'id' => $field_id, 'value' => 1)); |
|---|
| 387 | |
|---|
| 388 | $blocks['main']['options']['inline_images'] = array( |
|---|
| 389 | 'title' => html::label($field_id, Q(rcube_label('showinlineimages'))), |
|---|
| 390 | 'content' => $input_inline_images->show($config['inline_images']?1:0), |
|---|
| 391 | ); |
|---|
| 392 | } |
|---|
| 393 | |
|---|
| 394 | // "display after delete" checkbox |
|---|
| 395 | if (!isset($no_override['display_next'])) { |
|---|
| 396 | $field_id = 'rcmfd_displaynext'; |
|---|
| 397 | $input_displaynext = new html_checkbox(array('name' => '_display_next', 'id' => $field_id, 'value' => 1)); |
|---|
| 398 | |
|---|
| 399 | $blocks['main']['options']['display_next'] = array( |
|---|
| 400 | 'title' => html::label($field_id, Q(rcube_label('displaynext'))), |
|---|
| 401 | 'content' => $input_displaynext->show($config['display_next']?1:0), |
|---|
| 402 | ); |
|---|
| 403 | } |
|---|
| 404 | |
|---|
| 405 | break; |
|---|
| 406 | |
|---|
| 407 | // Mail composition |
|---|
| 408 | case 'compose': |
|---|
| 409 | |
|---|
| 410 | $blocks = array( |
|---|
| 411 | 'main' => array('name' => Q(rcube_label('mainoptions'))), |
|---|
| 412 | 'sig' => array('name' => Q(rcube_label('signatureoptions'))), |
|---|
| 413 | ); |
|---|
| 414 | |
|---|
| 415 | // Show checkbox for HTML Editor |
|---|
| 416 | if (!isset($no_override['htmleditor'])) { |
|---|
| 417 | $field_id = 'rcmfd_htmleditor'; |
|---|
| 418 | $input_htmleditor = new html_checkbox(array('name' => '_htmleditor', 'id' => $field_id, 'value' => 1)); |
|---|
| 419 | |
|---|
| 420 | $blocks['main']['options']['htmleditor'] = array( |
|---|
| 421 | 'title' => html::label($field_id, Q(rcube_label('htmleditor'))), |
|---|
| 422 | 'content' => $input_htmleditor->show($config['htmleditor']?1:0), |
|---|
| 423 | ); |
|---|
| 424 | } |
|---|
| 425 | |
|---|
| 426 | if (!isset($no_override['draft_autosave'])) { |
|---|
| 427 | $field_id = 'rcmfd_autosave'; |
|---|
| 428 | $select_autosave = new html_select(array('name' => '_draft_autosave', 'id' => $field_id, 'disabled' => empty($config['drafts_mbox']))); |
|---|
| 429 | $select_autosave->add(rcube_label('never'), 0); |
|---|
| 430 | foreach (array(1, 3, 5, 10) as $i => $min) |
|---|
| 431 | $select_autosave->add(rcube_label(array('name' => 'everynminutes', 'vars' => array('n' => $min))), $min*60); |
|---|
| 432 | |
|---|
| 433 | $blocks['main']['options']['draft_autosave'] = array( |
|---|
| 434 | 'title' => html::label($field_id, Q(rcube_label('autosavedraft'))), |
|---|
| 435 | 'content' => $select_autosave->show($config['draft_autosave']), |
|---|
| 436 | ); |
|---|
| 437 | } |
|---|
| 438 | |
|---|
| 439 | if (!isset($no_override['mime_param_folding'])) { |
|---|
| 440 | $field_id = 'rcmfd_param_folding'; |
|---|
| 441 | $select_param_folding = new html_select(array('name' => '_mime_param_folding', 'id' => $field_id)); |
|---|
| 442 | $select_param_folding->add(rcube_label('2231folding'), 0); |
|---|
| 443 | $select_param_folding->add(rcube_label('miscfolding'), 1); |
|---|
| 444 | $select_param_folding->add(rcube_label('2047folding'), 2); |
|---|
| 445 | |
|---|
| 446 | $blocks['main']['options']['mime_param_folding'] = array( |
|---|
| 447 | 'advanced' => true, |
|---|
| 448 | 'title' => html::label($field_id, Q(rcube_label('mimeparamfolding'))), |
|---|
| 449 | 'content' => $select_param_folding->show($config['mime_param_folding']), |
|---|
| 450 | ); |
|---|
| 451 | } |
|---|
| 452 | |
|---|
| 453 | if (!isset($no_override['top_posting'])) { |
|---|
| 454 | $field_id = 'rcmfd_top_posting'; |
|---|
| 455 | $select_replymode = new html_select(array('name' => '_top_posting', 'id' => $field_id)); |
|---|
| 456 | $select_replymode->add(rcube_label('replybottomposting'), 0); |
|---|
| 457 | $select_replymode->add(rcube_label('replytopposting'), 1); |
|---|
| 458 | |
|---|
| 459 | $blocks['main']['options']['top_posting'] = array( |
|---|
| 460 | 'title' => html::label($field_id, Q(rcube_label('whenreplying'))), |
|---|
| 461 | 'content' => $select_replymode->show($config['top_posting']?1:0), |
|---|
| 462 | ); |
|---|
| 463 | } |
|---|
| 464 | |
|---|
| 465 | if (!isset($no_override['show_sig'])) { |
|---|
| 466 | $field_id = 'rcmfd_show_sig'; |
|---|
| 467 | $select_show_sig = new html_select(array('name' => '_show_sig', 'id' => $field_id)); |
|---|
| 468 | $select_show_sig->add(rcube_label('never'), 0); |
|---|
| 469 | $select_show_sig->add(rcube_label('always'), 1); |
|---|
| 470 | $select_show_sig->add(rcube_label('newmessageonly'), 2); |
|---|
| 471 | $select_show_sig->add(rcube_label('replyandforwardonly'), 3); |
|---|
| 472 | |
|---|
| 473 | $blocks['sig']['options']['show_sig'] = array( |
|---|
| 474 | 'title' => html::label($field_id, Q(rcube_label('autoaddsignature'))), |
|---|
| 475 | 'content' => $select_show_sig->show($config['show_sig']), |
|---|
| 476 | ); |
|---|
| 477 | } |
|---|
| 478 | |
|---|
| 479 | if (!isset($no_override['sig_above'])) { |
|---|
| 480 | $field_id = 'rcmfd_sig_above'; |
|---|
| 481 | $input_sigabove = new html_checkbox(array('name' => '_sig_above', 'id' => $field_id, 'value' => 1)); |
|---|
| 482 | |
|---|
| 483 | $blocks['sig']['options']['sig_above'] = array( |
|---|
| 484 | 'title' => html::label($field_id, Q(rcube_label('replysignatureabove'))), |
|---|
| 485 | 'content' => $input_sigabove->show($config['sig_above']?1:0), |
|---|
| 486 | ); |
|---|
| 487 | } |
|---|
| 488 | |
|---|
| 489 | if (!isset($no_override['strip_existing_sig'])) { |
|---|
| 490 | $field_id = 'rcmfd_strip_existing_sig'; |
|---|
| 491 | $input_stripexistingsig = new html_checkbox(array('name' => '_strip_existing_sig', 'id' => $field_id, 'value' => 1)); |
|---|
| 492 | |
|---|
| 493 | $blocks['sig']['options']['strip_existing_sig'] = array( |
|---|
| 494 | 'title' => html::label($field_id, Q(rcube_label('replyremovesignature'))), |
|---|
| 495 | 'content' => $input_stripexistingsig->show($config['strip_existing_sig']?1:0), |
|---|
| 496 | ); |
|---|
| 497 | } |
|---|
| 498 | |
|---|
| 499 | break; |
|---|
| 500 | |
|---|
| 501 | // Special IMAP folders |
|---|
| 502 | case 'folders': |
|---|
| 503 | |
|---|
| 504 | $blocks = array( |
|---|
| 505 | 'main' => array('name' => Q(rcube_label('mainoptions'))), |
|---|
| 506 | ); |
|---|
| 507 | |
|---|
| 508 | // Configure special folders |
|---|
| 509 | if (!isset($no_override['default_imap_folders'])) { |
|---|
| 510 | $RCMAIL->imap_init(true); |
|---|
| 511 | $select = rcmail_mailbox_select(array('noselection' => '---', 'realnames' => true, |
|---|
| 512 | 'maxlength' => 30, 'exceptions' => array('INBOX'))); |
|---|
| 513 | |
|---|
| 514 | if (!isset($no_override['drafts_mbox'])) |
|---|
| 515 | $blocks['main']['options']['drafts_mbox'] = array( |
|---|
| 516 | 'title' => Q(rcube_label('drafts')), |
|---|
| 517 | 'content' => $select->show($config['drafts_mbox'], array('name' => "_drafts_mbox")), |
|---|
| 518 | ); |
|---|
| 519 | |
|---|
| 520 | if (!isset($no_override['sent_mbox'])) |
|---|
| 521 | $blocks['main']['options']['sent_mbox'] = array( |
|---|
| 522 | 'title' => Q(rcube_label('sent')), |
|---|
| 523 | 'content' => $select->show($config['sent_mbox'], array('name' => "_sent_mbox")), |
|---|
| 524 | ); |
|---|
| 525 | |
|---|
| 526 | if (!isset($no_override['junk_mbox'])) |
|---|
| 527 | $blocks['main']['options']['junk_mbox'] = array( |
|---|
| 528 | 'title' => Q(rcube_label('junk')), |
|---|
| 529 | 'content' => $select->show($config['junk_mbox'], array('name' => "_junk_mbox")), |
|---|
| 530 | ); |
|---|
| 531 | |
|---|
| 532 | if (!isset($no_override['trash_mbox'])) |
|---|
| 533 | $blocks['main']['options']['trash_mbox'] = array( |
|---|
| 534 | 'title' => Q(rcube_label('trash')), |
|---|
| 535 | 'content' => $select->show($config['trash_mbox'], array('name' => "_trash_mbox")), |
|---|
| 536 | ); |
|---|
| 537 | } |
|---|
| 538 | |
|---|
| 539 | break; |
|---|
| 540 | |
|---|
| 541 | // Server settings |
|---|
| 542 | case 'server': |
|---|
| 543 | |
|---|
| 544 | $blocks = array( |
|---|
| 545 | 'main' => array('name' => Q(rcube_label('mainoptions'))), |
|---|
| 546 | 'maintenance' => array('name' => Q(rcube_label('maintenance'))), |
|---|
| 547 | ); |
|---|
| 548 | |
|---|
| 549 | if (!isset($no_override['read_when_deleted'])) { |
|---|
| 550 | $field_id = 'rcmfd_read_deleted'; |
|---|
| 551 | $input_readdeleted = new html_checkbox(array('name' => '_read_when_deleted', 'id' => $field_id, 'value' => 1)); |
|---|
| 552 | |
|---|
| 553 | $blocks['main']['options']['read_when_deleted'] = array( |
|---|
| 554 | 'title' => html::label($field_id, Q(rcube_label('readwhendeleted'))), |
|---|
| 555 | 'content' => $input_readdeleted->show($config['read_when_deleted']?1:0), |
|---|
| 556 | ); |
|---|
| 557 | } |
|---|
| 558 | |
|---|
| 559 | if (!isset($no_override['flag_for_deletion'])) { |
|---|
| 560 | $field_id = 'rcmfd_flag_for_deletion'; |
|---|
| 561 | $input_flagfordeletion = new html_checkbox(array('name' => '_flag_for_deletion', 'id' => $field_id, 'value' => 1)); |
|---|
| 562 | |
|---|
| 563 | $blocks['main']['options']['flag_for_deletion'] = array( |
|---|
| 564 | 'title' => html::label($field_id, Q(rcube_label('flagfordeletion'))), |
|---|
| 565 | 'content' => $input_flagfordeletion->show($config['flag_for_deletion']?1:0), |
|---|
| 566 | ); |
|---|
| 567 | } |
|---|
| 568 | |
|---|
| 569 | // don't show deleted messages |
|---|
| 570 | if (!isset($no_override['skip_deleted'])) { |
|---|
| 571 | $field_id = 'rcmfd_skip_deleted'; |
|---|
| 572 | $input_purge = new html_checkbox(array('name' => '_skip_deleted', 'id' => $field_id, 'value' => 1)); |
|---|
| 573 | |
|---|
| 574 | $blocks['main']['options']['skip_deleted'] = array( |
|---|
| 575 | 'title' => html::label($field_id, Q(rcube_label('skipdeleted'))), |
|---|
| 576 | 'content' => $input_purge->show($config['skip_deleted']?1:0), |
|---|
| 577 | ); |
|---|
| 578 | } |
|---|
| 579 | |
|---|
| 580 | // Trash purging on logout |
|---|
| 581 | if (!isset($no_override['logout_purge'])) { |
|---|
| 582 | $field_id = 'rcmfd_logout_purge'; |
|---|
| 583 | $input_purge = new html_checkbox(array('name' => '_logout_purge', 'id' => $field_id, 'value' => 1)); |
|---|
| 584 | |
|---|
| 585 | $blocks['maintenance']['options']['logout_purge'] = array( |
|---|
| 586 | 'title' => html::label($field_id, Q(rcube_label('logoutclear'))), |
|---|
| 587 | 'content' => $input_purge->show($config['logout_purge']?1:0), |
|---|
| 588 | ); |
|---|
| 589 | } |
|---|
| 590 | |
|---|
| 591 | // INBOX compacting on logout |
|---|
| 592 | if (!isset($no_override['logout_expunge'])) { |
|---|
| 593 | $field_id = 'rcmfd_logout_expunge'; |
|---|
| 594 | $input_expunge = new html_checkbox(array('name' => '_logout_expunge', 'id' => $field_id, 'value' => 1)); |
|---|
| 595 | |
|---|
| 596 | $blocks['maintenance']['options']['logout_expunge'] = array( |
|---|
| 597 | 'title' => html::label($field_id, Q(rcube_label('logoutcompact'))), |
|---|
| 598 | 'content' => $input_expunge->show($config['logout_expunge']?1:0), |
|---|
| 599 | ); |
|---|
| 600 | } |
|---|
| 601 | |
|---|
| 602 | break; |
|---|
| 603 | } |
|---|
| 604 | |
|---|
| 605 | $data = $RCMAIL->plugins->exec_hook('user_preferences', array('section' => $sect['id'], 'blocks' => $blocks)); |
|---|
| 606 | $found = false; |
|---|
| 607 | |
|---|
| 608 | // create output |
|---|
| 609 | foreach ($data['blocks'] as $block) { |
|---|
| 610 | if ($block['options']) { |
|---|
| 611 | foreach ($block['options'] as $option) { |
|---|
| 612 | $found = true; |
|---|
| 613 | break 2; |
|---|
| 614 | } |
|---|
| 615 | } |
|---|
| 616 | } |
|---|
| 617 | |
|---|
| 618 | if (!$found) |
|---|
| 619 | unset($sections[$idx]); |
|---|
| 620 | else |
|---|
| 621 | $sections[$idx]['blocks'] = $data['blocks']; |
|---|
| 622 | } |
|---|
| 623 | |
|---|
| 624 | return array($sections, $plugin['cols']); |
|---|
| 625 | } |
|---|
| 626 | |
|---|
| 627 | |
|---|
| 628 | function rcmail_get_skins() |
|---|
| 629 | { |
|---|
| 630 | $path = 'skins'; |
|---|
| 631 | $skins = array(); |
|---|
| 632 | |
|---|
| 633 | $dir = opendir($path); |
|---|
| 634 | |
|---|
| 635 | if (!$dir) |
|---|
| 636 | return false; |
|---|
| 637 | |
|---|
| 638 | while (($file = readdir($dir)) !== false) |
|---|
| 639 | { |
|---|
| 640 | $filename = $path.'/'.$file; |
|---|
| 641 | if (is_dir($filename) && is_readable($filename) |
|---|
| 642 | && !in_array($file, array('.', '..', '.svn'))) |
|---|
| 643 | $skins[] = $file; |
|---|
| 644 | } |
|---|
| 645 | |
|---|
| 646 | closedir($dir); |
|---|
| 647 | |
|---|
| 648 | return $skins; |
|---|
| 649 | } |
|---|
| 650 | |
|---|
| 651 | |
|---|
| 652 | // register UI objects |
|---|
| 653 | $OUTPUT->add_handlers(array( |
|---|
| 654 | 'prefsframe' => 'rcmail_preferences_frame', |
|---|
| 655 | 'sectionslist' => 'rcmail_sections_list', |
|---|
| 656 | 'identitieslist' => 'rcmail_identities_list', |
|---|
| 657 | )); |
|---|
| 658 | |
|---|
| 659 | ?> |
|---|