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