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

Last change on this file since 7 was 7, checked in by roundcube, 8 years ago

* empty log message *

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 7.9 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 | All rights reserved.                                                  |
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(sprintf("SELECT username, mail_host FROM %s
25                                  WHERE  user_id=%d",
26                                 get_table_name('users'),
27                                 $_SESSION['user_id']));
28                                 
29if ($USER_DATA = $DB->fetch_assoc($sql_result))
30  $PAGE_TITLE = sprintf('%s %s@%s', rcube_label('settingsfor'), $USER_DATA['username'], $USER_DATA['mail_host']);
31
32
33
34function rcmail_user_prefs_form($attrib)
35  {
36  global $DB, $CONFIG, $sess_user_lang;
37
38  list($form_start, $form_end) = get_form_tags($attrib, 'save-prefs');
39  unset($attrib['form']);
40
41  // allow the following attributes to be added to the <table> tag
42  $attrib_str = create_attrib_string($attrib, array('style', 'class', 'id', 'cellpadding', 'cellspacing', 'border', 'summary'));
43
44  // return the complete edit form as table
45  $out = "$form_start<table" . $attrib_str . ">\n\n";
46
47  $a_show_cols = array('language'  => array('type' => 'text'),
48                       'pagesize'  => array('type' => 'text'),
49                       'timezone'  => array('type' => 'text'));
50                       
51  // show language selection
52  $field_id = 'rcmfd_lang';
53  $select_lang = new select(array('name' => '_language', 'id' => $field_id));
54  // $select_lang->add('Czech', 'cs');
55  $select_lang->add('Dansk', 'da');
56  $select_lang->add('Deutsch', 'de');
57  $select_lang->add('English', 'en');
58  $select_lang->add('Espanol', 'es');
59  $select_lang->add('Franais', 'fr');
60  $select_lang->add('Italiano', 'it');
61
62  $out .= sprintf("<tr><td class=\"title\"><label for=\"%s\">%s</label></td><td>%s</td></tr>\n",
63                  $field_id,
64                  rcube_label('language'),
65                  $select_lang->show($sess_user_lang));
66
67
68  // show page size selection
69  $field_id = 'rcmfd_timezone';
70  $select_timezone = new select(array('name' => '_timezone', 'id' => $field_id));
71  $select_timezone->add('(GMT -11:00) Midway Island, Samoa', '-11');
72  $select_timezone->add('(GMT -10:00) Hawaii', '-10');
73  $select_timezone->add('(GMT -9:00) Alaska', '-9');
74  $select_timezone->add('(GMT -8:00) Pacific Time (US/Canada)', '-8');
75  $select_timezone->add('(GMT -7:00) Mountain Time (US/Canada)', '-7');
76  $select_timezone->add('(GMT -6:00) Central Time (US/Canada), Mexico City', '-6');
77  $select_timezone->add('(GMT -5:00) Eastern Time (US/Canada), Bogota, Lima', '-5');
78  $select_timezone->add('(GMT -4:00) Atlantic Time (Canada), Caracas, La Paz', '-4');
79  $select_timezone->add('(GMT -3:00) Brazil, Buenos Aires, Georgetown', '-3');
80  $select_timezone->add('(GMT -2:00) Mid-Atlantic', '-2');
81  $select_timezone->add('(GMT -1:00) Azores, Cape Verde Islands', '-1');
82  $select_timezone->add('(GMT) Western Europe, London, Lisbon, Casablanca', '0');
83  $select_timezone->add('(GMT +1:00) Central European Time', '1');
84  $select_timezone->add('(GMT +2:00) EET: Kaliningrad, South Africa', '2');
85  $select_timezone->add('(GMT +3:00) Baghdad, Kuwait, Riyadh, Moscow, Nairobi', '3');
86  $select_timezone->add('(GMT +4:00) Abu Dhabi, Muscat, Baku, Tbilisi', '4');
87  $select_timezone->add('(GMT +5:00) Ekaterinburg, Islamabad, Karachi', '5');
88  $select_timezone->add('(GMT +6:00) Almaty, Dhaka, Colombo', '6');
89  $select_timezone->add('(GMT +7:00) Bangkok, Hanoi, Jakarta', '7');
90  $select_timezone->add('(GMT +8:00) Beijing, Perth, Singapore, Taipei', '8');
91  $select_timezone->add('(GMT +9:00) Tokyo, Seoul, Yakutsk', '9');
92  $select_timezone->add('(GMT +10:00) EAST/AEST: Guam, Vladivostok', '10');
93  $select_timezone->add('(GMT +11:00) Magadan, Solomon Islands', '11');
94  $select_timezone->add('(GMT +12:00) Auckland, Wellington, Kamchatka', '12');
95  $select_timezone->add('(GMT +13:00) Tonga, Pheonix Islands', '13');
96  $select_timezone->add('(GMT +14:00) Kiribati', '14');
97 
98 
99  $out .= sprintf("<tr><td class=\"title\"><label for=\"%s\">%s</label></td><td>%s</td></tr>\n",
100                  $field_id,
101                  rcube_label('timezone'),
102                  $select_timezone->show($CONFIG['timezone']));
103
104
105  // show page size selection
106  $field_id = 'rcmfd_pgsize';
107  $input_pagesize = new textfield(array('name' => '_pagesize', 'id' => $field_id, 'size' => 5));
108
109  $out .= sprintf("<tr><td class=\"title\"><label for=\"%s\">%s</label></td><td>%s</td></tr>\n",
110                  $field_id,
111                  rcube_label('pagesize'),
112                  $input_pagesize->show($CONFIG['pagesize']));
113
114  // show checkbox for HTML/plaintext messages
115  $field_id = 'rcmfd_htmlmsg';
116  $input_pagesize = new checkbox(array('name' => '_prefer_html', 'id' => $field_id, 'value' => 1));
117
118  $out .= sprintf("<tr><td class=\"title\"><label for=\"%s\">%s</label></td><td>%s</td></tr>\n",
119                  $field_id,
120                  rcube_label('preferhtml'),
121                  $input_pagesize->show($CONFIG['prefer_html']?1:0));
122
123
124  $out .= "\n</table>$form_end";
125
126  return $out; 
127  }
128
129
130
131
132function rcmail_identities_list($attrib)
133  {
134  global $DB, $CONFIG, $OUTPUT, $JS_OBJECT_NAME;
135
136
137  // get contacts from DB
138  $sql_result = $DB->query(sprintf("SELECT * FROM %s
139                                    WHERE  del!='1'
140                                    AND    user_id=%d
141                                    ORDER BY `default` DESC, name ASC",
142                                   get_table_name('identities'),
143                                   $_SESSION['user_id']));
144
145
146  // add id to message list table if not specified
147  if (!strlen($attrib['id']))
148    $attrib['id'] = 'rcmIdentitiesList';
149
150  // define list of cols to be displayed
151  $a_show_cols = array('name', 'email', 'organization', 'reply-to');
152
153  // create XHTML table 
154  $out = rcube_table_output($attrib, $sql_result, $a_show_cols, 'identity_id');
155 
156  // set client env
157  $javascript = sprintf("%s.gui_object('identitieslist', '%s');\n", $JS_OBJECT_NAME, $attrib['id']);
158  $OUTPUT->add_script($javascript);   
159
160  return $out;
161  }
162
163
164
165// similar function as in /steps/addressbook/edit.inc
166function get_form_tags($attrib, $action, $add_hidden=array())
167  {
168  global $OUTPUT, $JS_OBJECT_NAME, $EDIT_FORM, $SESS_HIDDEN_FIELD; 
169
170  $form_start = '';
171  if (!strlen($EDIT_FORM))
172    {
173    $hiddenfields = new hiddenfield(array('name' => '_task', 'value' => $GLOBALS['_task']));
174    $hiddenfields->add(array('name' => '_action', 'value' => $action));
175   
176    if ($add_hidden)
177      $hiddenfields->add($add_hidden);
178   
179    if ($_GET['_framed'] || $_POST['_framed'])
180      $hiddenfields->add(array('name' => '_framed', 'value' => 1));
181   
182    $form_start = !strlen($attrib['form']) ? '<form name="form" action="./" method="post">' : '';
183    $form_start .= "\n$SESS_HIDDEN_FIELD\n";
184    $form_start .= $hiddenfields->show();
185    }
186   
187  $form_end = (!strlen($EDIT_FORM) && !strlen($attrib['form'])) ? '</form>' : '';
188  $form_name = strlen($attrib['form']) ? $attrib['form'] : 'form';
189
190  if (!strlen($EDIT_FORM))
191    $OUTPUT->add_script("$JS_OBJECT_NAME.gui_object('editform', '$form_name');");
192 
193  $EDIT_FORM = $form_name;
194
195  return array($form_start, $form_end); 
196  }
197
198
199?>
Note: See TracBrowser for help on using the repository browser.