source: github/program/steps/settings/save_prefs.inc @ cc97ea0

HEADcourier-fixdev-browser-capabilitiespdorelease-0.6release-0.7release-0.8
Last change on this file since cc97ea0 was cc97ea0, checked in by thomascube <thomas@…>, 4 years ago

Merged branch devel-api (from r2208 to r2387) back into trunk (omitting some sample plugins)

  • Property mode set to 100644
File size: 4.7 KB
Line 
1<?php
2
3/*
4 +-----------------------------------------------------------------------+
5 | program/steps/settings/save_prefs.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 |   Save user preferences to DB and to the current session              |
13 |                                                                       |
14 +-----------------------------------------------------------------------+
15 | Author: Thomas Bruederli <roundcube@gmail.com>                        |
16 +-----------------------------------------------------------------------+
17
18 $Id$
19
20*/
21
22$a_user_prefs = array(
23  'language'     => isset($_POST['_language']) ? get_input_value('_language', RCUBE_INPUT_POST) : $CONFIG['language'],
24  'timezone'     => isset($_POST['_timezone']) ? (is_numeric($_POST['_timezone']) ? floatval($_POST['_timezone']) : get_input_value('_timezone', RCUBE_INPUT_POST)) : $CONFIG['timezone'],
25  'dst_active'   => isset($_POST['_dst_active']) ? TRUE : FALSE,
26  'pagesize'     => is_numeric($_POST['_pagesize']) ? max(2, intval($_POST['_pagesize'])) : $CONFIG['pagesize'],
27  'prettydate'   => isset($_POST['_pretty_date']) ? TRUE : FALSE,
28  'prefer_html'  => isset($_POST['_prefer_html']) ? TRUE : FALSE,
29  'htmleditor'   => isset($_POST['_htmleditor']) ? TRUE : FALSE,
30  'inline_images'   => isset($_POST['_inline_images']) ? TRUE : FALSE,
31  'preview_pane' => isset($_POST['_preview_pane']) ? TRUE : FALSE,
32  'focus_on_new_message' => isset($_POST['_focus_on_new_message']) ? TRUE : FALSE,
33  'read_when_deleted' => isset($_POST['_read_when_deleted']) ? TRUE : FALSE,
34  'skip_deleted' => isset($_POST['_skip_deleted']) ? TRUE : FALSE,
35  'flag_for_deletion' => isset($_POST['_flag_for_deletion']) ? TRUE : FALSE,
36  'logout_purge' => isset($_POST['_logout_purge']) ? TRUE : FALSE,
37  'logout_expunge' => isset($_POST['_logout_expunge']) ? TRUE : FALSE,
38  'draft_autosave' => isset($_POST['_draft_autosave']) ? intval($_POST['_draft_autosave']) : 0,
39  'show_images' => isset($_POST['_show_images']) ? intval($_POST['_show_images']) : 0,
40  'keep_alive' => isset($_POST['_keep_alive']) ? intval($_POST['_keep_alive'])*60 : $CONFIG['keep_alive'],
41  'check_all_folders' => isset($_POST['_check_all_folders']) ? TRUE : FALSE,
42  'mime_param_folding' => isset($_POST['_mime_param_folding']) ? intval($_POST['_mime_param_folding']) : 0,
43  'mdn_requests' => isset($_POST['_mdn_requests']) ? intval($_POST['_mdn_requests']) : 0,
44  'skin' => isset($_POST['_skin']) ? get_input_value('_skin', RCUBE_INPUT_POST) : $CONFIG['skin'],
45  'drafts_mbox' => get_input_value('_drafts_mbox', RCUBE_INPUT_POST),
46  'sent_mbox' => get_input_value('_sent_mbox', RCUBE_INPUT_POST),
47  'junk_mbox' => get_input_value('_junk_mbox', RCUBE_INPUT_POST),
48  'trash_mbox' => get_input_value('_trash_mbox', RCUBE_INPUT_POST),
49  );
50
51$data  =  rcmail::get_instance()->plugins->exec_hook('save_preferences', array('prefs' => $a_user_prefs));
52$a_user_prefs = $data['prefs'];
53
54// don't override these parameters
55foreach ((array)$CONFIG['dont_override'] as $p)
56  $a_user_prefs[$p] = $CONFIG[$p];
57
58// special handling for 'default_imap_folders'
59if (in_array('default_imap_folders', (array)$CONFIG['dont_override'])) {
60  foreach (array('drafts_mbox','sent_mbox','junk_mbox','trash_mbox') as $p)
61    $a_user_prefs[$p] = $CONFIG[$p];
62}
63else {
64  $a_user_prefs['default_imap_folders'] = array('INBOX');
65  foreach (array('drafts_mbox','sent_mbox','junk_mbox','trash_mbox') as $p) {
66    if ($a_user_prefs[$p])
67      $a_user_prefs['default_imap_folders'][] = $a_user_prefs[$p];
68  }
69}
70
71// switch UI language
72if (isset($_POST['_language'])) {
73  $RCMAIL->load_language($a_user_prefs['language']);
74}
75
76// switch skin
77$OUTPUT->set_skin($a_user_prefs['skin']);
78
79// force min size
80if ($a_user_prefs['pagesize'] < 1)
81  $a_user_prefs['pagesize'] = 10;
82
83if (isset($CONFIG['max_pagesize']) && ($a_user_prefs['pagesize'] > $CONFIG['max_pagesize']))
84  $a_user_prefs['pagesize'] = (int) $CONFIG['max_pagesize'];
85
86// force keep_alive
87if (isset($a_user_prefs['keep_alive'])) {
88    $a_user_prefs['keep_alive'] = max(60, $CONFIG['min_keep_alive'], $a_user_prefs['keep_alive']);
89    if (!empty($CONFIG['session_lifetime']))
90      $a_user_prefs['keep_alive'] = min($CONFIG['session_lifetime']*60, $a_user_prefs['keep_alive']);
91}
92
93
94if ($USER->save_prefs($a_user_prefs))
95  $OUTPUT->show_message('successfullysaved', 'confirmation');
96
97// go to next step
98rcmail_overwrite_action('preferences');
99
100?>
Note: See TracBrowser for help on using the repository browser.