source: subversion/trunk/roundcubemail/program/steps/settings/func.inc @ 337

Last change on this file since 337 was 337, checked in by thomasb, 7 years ago

Made automatic draft saving configurable

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 9.7 KB
Line 
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, 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
23// get user record
24$sql_result = $DB->query("SELECT username, mail_host FROM ".get_table_name('users')."
25                          WHERE  user_id=?",
26                          $_SESSION['user_id']);
27                                 
28if ($USER_DATA = $DB->fetch_assoc($sql_result))
29  $PAGE_TITLE = sprintf('%s %s@%s', rcube_label('settingsfor'), $USER_DATA['username'], $USER_DATA['mail_host']);
30
31
32
33function rcmail_user_prefs_form($attrib)
34  {
35  global $DB, $CONFIG, $sess_user_lang;
36
37  // add some labels to client
38  rcube_add_label('nopagesizewarning');
39 
40  list($form_start, $form_end) = get_form_tags($attrib, 'save-prefs');
41  unset($attrib['form']);
42
43  // allow the following attributes to be added to the <table> tag
44  $attrib_str = create_attrib_string($attrib, array('style', 'class', 'id', 'cellpadding', 'cellspacing', 'border', 'summary'));
45
46  // return the complete edit form as table
47  $out = "$form_start<table" . $attrib_str . ">\n\n";
48
49  $a_show_cols = array(
50          'language'   => array('type' => 'text'),
51    'pagesize'   => array('type' => 'text'),
52    'timezone'   => array('type' => 'text'),
53    'prettydate' => array('type' => 'text'),
54    'draft_autosave' => array('type' => 'text')
55  );
56                       
57  // show language selection
58  $a_lang = rcube_list_languages();
59  asort($a_lang);
60 
61  $field_id = 'rcmfd_lang';
62  $select_lang = new select(array('name' => '_language', 'id' => $field_id));
63  $select_lang->add(array_values($a_lang), array_keys($a_lang));
64 
65
66  $out .= sprintf("<tr><td class=\"title\"><label for=\"%s\">%s</label></td><td>%s</td></tr>\n",
67                  $field_id,
68                  rep_specialchars_output(rcube_label('language')),
69                  $select_lang->show($sess_user_lang));
70
71
72  // show page size selection
73  $field_id = 'rcmfd_timezone';
74  $select_timezone = new select(array('name' => '_timezone', 'id' => $field_id));
75  $select_timezone->add('(GMT -11:00) Midway Island, Samoa', '-11');
76  $select_timezone->add('(GMT -10:00) Hawaii', '-10');
77  $select_timezone->add('(GMT -9:00) Alaska', '-9');
78  $select_timezone->add('(GMT -8:00) Pacific Time (US/Canada)', '-8');
79  $select_timezone->add('(GMT -7:00) Mountain Time (US/Canada)', '-7');
80  $select_timezone->add('(GMT -6:00) Central Time (US/Canada), Mexico City', '-6');
81  $select_timezone->add('(GMT -5:00) Eastern Time (US/Canada), Bogota, Lima', '-5');
82  $select_timezone->add('(GMT -4:00) Atlantic Time (Canada), Caracas, La Paz', '-4');
83  $select_timezone->add('(GMT -3:00) Brazil, Buenos Aires, Georgetown', '-3');
84  $select_timezone->add('(GMT -3:30) Nfld Time (Canada), Nfld, S. Labador', '-3.5');
85  $select_timezone->add('(GMT -2:00) Mid-Atlantic', '-2');
86  $select_timezone->add('(GMT -1:00) Azores, Cape Verde Islands', '-1');
87  $select_timezone->add('(GMT) Western Europe, London, Lisbon, Casablanca', '0');
88  $select_timezone->add('(GMT +1:00) Central European Time', '1');
89  $select_timezone->add('(GMT +2:00) EET: Kaliningrad, South Africa', '2');
90  $select_timezone->add('(GMT +3:00) Baghdad, Kuwait, Riyadh, Moscow, Nairobi', '3');
91  $select_timezone->add('(GMT +3:30) Tehran', '3.5');
92  $select_timezone->add('(GMT +4:00) Abu Dhabi, Muscat, Baku, Tbilisi', '4');
93  $select_timezone->add('(GMT +4:30) Kabul', '4.5');
94  $select_timezone->add('(GMT +5:00) Ekaterinburg, Islamabad, Karachi', '5');
95  $select_timezone->add('(GMT +5:30) Chennai, Kolkata, Mumbai, New Delhi', '5.5');
96  $select_timezone->add('(GMT +5:45) Kathmandu', '5.75');
97  $select_timezone->add('(GMT +6:00) Almaty, Dhaka, Colombo', '6');
98  $select_timezone->add('(GMT +7:00) Bangkok, Hanoi, Jakarta', '7');
99  $select_timezone->add('(GMT +8:00) Beijing, Perth, Singapore, Taipei', '8');
100  $select_timezone->add('(GMT +9:00) Tokyo, Seoul, Yakutsk', '9');
101  $select_timezone->add('(GMT +9:30) Adelaide, Darwin', '9.5');
102  $select_timezone->add('(GMT +10:00) EAST/AEST: Guam, Vladivostok', '10');
103  $select_timezone->add('(GMT +11:00) Magadan, Solomon Islands', '11');
104  $select_timezone->add('(GMT +12:00) Auckland, Wellington, Kamchatka', '12');
105  $select_timezone->add('(GMT +13:00) Tonga, Pheonix Islands', '13');
106  $select_timezone->add('(GMT +14:00) Kiribati', '14');
107 
108 
109  $out .= sprintf("<tr><td class=\"title\"><label for=\"%s\">%s</label></td><td>%s</td></tr>\n",
110                  $field_id,
111                  rep_specialchars_output(rcube_label('timezone')),
112                  $select_timezone->show($CONFIG['timezone']));
113
114
115  $field_id = 'rcmfd_dst';
116  $input_dst = new checkbox(array('name' => '_dst_active', 'id' => $field_id, 'value' => 1));
117  $out .= sprintf("<tr><td class=\"title\"><label for=\"%s\">%s</label></td><td>%s</td></tr>\n",
118                  $field_id,
119                  rep_specialchars_output(rcube_label('dstactive')),
120                  $input_dst->show($CONFIG['dst_active']));
121
122
123  // show page size selection
124  $field_id = 'rcmfd_pgsize';
125  $input_pagesize = new textfield(array('name' => '_pagesize', 'id' => $field_id, 'size' => 5));
126
127  $out .= sprintf("<tr><td class=\"title\"><label for=\"%s\">%s</label></td><td>%s</td></tr>\n",
128                  $field_id,
129                  rep_specialchars_output(rcube_label('pagesize')),
130                  $input_pagesize->show($CONFIG['pagesize']));
131
132  // show checkbox for HTML/plaintext messages
133  $field_id = 'rcmfd_htmlmsg';
134  $input_pagesize = new checkbox(array('name' => '_prefer_html', 'id' => $field_id, 'value' => 1));
135
136  $out .= sprintf("<tr><td class=\"title\"><label for=\"%s\">%s</label></td><td>%s</td></tr>\n",
137                  $field_id,
138                  rep_specialchars_output(rcube_label('preferhtml')),
139                  $input_pagesize->show($CONFIG['prefer_html']?1:0));
140
141  // MM: Show checkbox for toggling 'pretty dates'
142  $field_id = 'rcmfd_prettydate';
143  $input_prettydate = new checkbox(array('name' => '_pretty_date', 'id' => $field_id, 'value' => 1));
144
145  $out .= sprintf("<tr><td class=\"title\"><label for=\"%s\">%s</label></td><td>%s</td></tr>\n",
146                  $field_id,
147                  rep_specialchars_output(rcube_label('prettydate')),
148                  $input_prettydate->show($CONFIG['prettydate']?1:0));
149
150  if (!empty($CONFIG['drafts_mbox']))
151    {
152    $field_id = 'rcmfd_autosave';
153    $select_autosave = new select(array('name' => '_draft_autosave', 'id' => $field_id));
154    $select_autosave->add(rcube_label('never'), 0);
155    foreach (array(3, 5, 10) as $i => $min)
156      $select_autosave->add(rcube_label(array('name' => 'everynminutes', 'vars' => array('n' => $min))), $min*60);
157
158    $out .= sprintf("<tr><td class=\"title\"><label for=\"%s\">%s</label></td><td>%s</td></tr>\n",
159                    $field_id,
160                    rep_specialchars_output(rcube_label('autosavedraft')),
161                    $select_autosave->show($CONFIG['draft_autosave']));
162    }
163
164  $out .= "\n</table>$form_end";
165
166  return $out; 
167  }
168
169
170
171
172function rcmail_identities_list($attrib)
173  {
174  global $DB, $CONFIG, $OUTPUT, $JS_OBJECT_NAME;
175
176
177  // get contacts from DB
178  $sql_result = $DB->query("SELECT * FROM ".get_table_name('identities')."
179                            WHERE  del<>1
180                            AND    user_id=?
181                            ORDER BY standard DESC, name ASC",
182                            $_SESSION['user_id']);
183
184
185  // add id to message list table if not specified
186  if (!strlen($attrib['id']))
187    $attrib['id'] = 'rcmIdentitiesList';
188
189  // define list of cols to be displayed
190  $a_show_cols = array('name', 'email', 'organization', 'reply-to');
191
192  // create XHTML table 
193  $out = rcube_table_output($attrib, $sql_result, $a_show_cols, 'identity_id');
194 
195  // set client env
196  $javascript = sprintf("%s.gui_object('identitieslist', '%s');\n", $JS_OBJECT_NAME, $attrib['id']);
197  $OUTPUT->add_script($javascript);   
198
199  return $out;
200  }
201
202
203
204// similar function as in /steps/addressbook/edit.inc
205function get_form_tags($attrib, $action, $add_hidden=array())
206  {
207  global $OUTPUT, $JS_OBJECT_NAME, $EDIT_FORM, $SESS_HIDDEN_FIELD; 
208
209  $form_start = '';
210  if (!strlen($EDIT_FORM))
211    {
212    $hiddenfields = new hiddenfield(array('name' => '_task', 'value' => $GLOBALS['_task']));
213    $hiddenfields->add(array('name' => '_action', 'value' => $action));
214   
215    if ($add_hidden)
216      $hiddenfields->add($add_hidden);
217   
218    if ($_GET['_framed'] || $_POST['_framed'])
219      $hiddenfields->add(array('name' => '_framed', 'value' => 1));
220   
221    $form_start = !strlen($attrib['form']) ? '<form name="form" action="./" method="post">' : '';
222    $form_start .= "\n$SESS_HIDDEN_FIELD\n";
223    $form_start .= $hiddenfields->show();
224    }
225   
226  $form_end = (!strlen($EDIT_FORM) && !strlen($attrib['form'])) ? '</form>' : '';
227  $form_name = strlen($attrib['form']) ? $attrib['form'] : 'form';
228
229  if (!strlen($EDIT_FORM))
230    $OUTPUT->add_script("$JS_OBJECT_NAME.gui_object('editform', '$form_name');");
231 
232  $EDIT_FORM = $form_name;
233
234  return array($form_start, $form_end); 
235  }
236
237
238?>
Note: See TracBrowser for help on using the repository browser.