source: github/program/steps/settings/func.inc @ 4e17e6c

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

Initial revision

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