added language option to preferences

This commit is contained in:
SJ 2013-03-17 21:43:40 +01:00
parent 7ab1478655
commit 266003afb6
9 changed files with 27 additions and 4 deletions

View File

@ -184,7 +184,7 @@ create table if not exists `user_settings` (
`username` char(64) not null unique,
`pagelen` int default 20,
`theme` char(8) default 'default',
`lang` char(2) default 'en'
`lang` char(2) default NULL
);
create index `user_settings_idx` on `user_settings`(`username`);

View File

@ -29,4 +29,6 @@ drop view if exists `v_messages`;
create view `v_messages` AS select `metadata`.`id` AS `id`,`metadata`.`piler_id` AS `piler_id`,`metadata`.`from` AS `from`,`metadata`.`fromdomain` AS `fromdomain`,`rcpt`.`to` AS `to`,`rcpt`.`todomain` AS `todomain`,`metadata`.`subject` AS `subject`, `metadata`.`size` AS `size`, `metadata`.`direction` AS `direction`, `metadata`.`sent` AS `sent`, `metadata`.`arrived` AS `arrived`, `metadata`.`digest` AS `digest`, `metadata`.`bodydigest` AS `bodydigest` from (`metadata` join `rcpt`) where (`metadata`.`id` = `rcpt`.`id`);
alter table `user_settings` change column `lang` `lang` char(2) default NULL;

View File

@ -389,5 +389,6 @@ $_['text_clear'] = 'Clear';
$_['text_select_letter'] = 'Select Addresses by Letter';
$_['text_working'] = 'Working...';
$_['text_use_browser_settings'] = 'Use browser settings';
?>

View File

@ -390,4 +390,6 @@ $_['text_clear'] = 'T
$_['text_select_letter'] = 'Cím kiválasztása betű szerint';
$_['text_working'] = 'Keresés...';
$_['text_use_browser_settings'] = 'Böngésző beállításainak használata';
?>

View File

@ -390,4 +390,6 @@ $_['text_clear'] = 'Törlés';
$_['text_select_letter'] = 'Cím kiválasztása betű szerint';
$_['text_working'] = 'Keresés...';
$_['text_use_browser_settings'] = 'Böngésző beállításainak használata';
?>

View File

@ -389,4 +389,6 @@ $_['text_clear'] = 'Clear';
$_['text_select_letter'] = 'Select Addresses by Letter';
$_['text_working'] = 'Working...';
$_['text_use_browser_settings'] = 'Use browser settings';
?>

View File

@ -9,6 +9,7 @@ class ModelUserPrefs extends Model {
if(isset($query->row['pagelen'])) { $_SESSION['pagelen'] = $query->row['pagelen']; } else { $_SESSION['pagelen'] = PAGE_LEN; }
if(isset($query->row['theme'])) { $_SESSION['theme'] = $query->row['theme']; } else { $_SESSION['theme'] = THEME; }
if(isset($query->row['lang'])) { $_SESSION['lang'] = $query->row['lang']; } else { $_SESSION['lang'] = DEFAULT_LANG; }
return 1;
}
@ -22,15 +23,16 @@ class ModelUserPrefs extends Model {
$query = $this->db->query("SELECT COUNT(*) AS num FROM " . TABLE_USER_SETTINGS . " WHERE username=?", array($username));
if((int)@$query->row['num'] == 1) {
$query = $this->db->query("UPDATE " . TABLE_USER_SETTINGS . " SET pagelen=?, theme=? WHERE username=?", array((int)@$prefs['pagelen'], $prefs['theme'], $username));
$query = $this->db->query("UPDATE " . TABLE_USER_SETTINGS . " SET pagelen=?, theme=?, lang=? WHERE username=?", array((int)@$prefs['pagelen'], $prefs['theme'], $prefs['lang'], $username));
}
else {
$query = $this->db->query("INSERT INTO " . TABLE_USER_SETTINGS . " (username, pagelen, theme) VALUES(?,?,?)", array($username, (int)@$prefs['pagelen'], $prefs['theme']));
$query = $this->db->query("INSERT INTO " . TABLE_USER_SETTINGS . " (username, pagelen, theme, lang) VALUES(?,?,?,?)", array($username, (int)@$prefs['pagelen'], $prefs['theme'], $prefs['lang']));
}
$_SESSION['pagelen'] = $prefs['pagelen'];
$_SESSION['theme'] = $prefs['theme'];
$_SESSION['lang'] = $prefs['lang'];
LOGGER("set user preference", $username);

View File

@ -9,7 +9,7 @@ class Language {
$lang = '';
if(isset($_SESSION['lang'])) {
if(isset($_SESSION['lang']) && $_SESSION['lang'] != '') {
$file = DIR_LANGUAGE . $_SESSION['lang'] . '/messages.php';
define('LANG', $_SESSION['lang']);
}

View File

@ -79,6 +79,18 @@
</div>
</div>
<div class="row">
<div class="cell1"><?php print $text_language; ?>:</div>
<div class="cell2">
<select name="lang">
<option value=""><?php print $text_use_browser_settings; ?></option>
<?php foreach(Registry::get('langs') as $t) { ?>
<option value="<?php print $t; ?>"<?php if(isset($_SESSION['lang']) && $_SESSION['lang'] == $t) { ?> selected="selected"<?php } ?>><?php print $t; ?></option>
<?php } ?>
</select>
</div>
</div>
<div class="row">
<div class="cell1">&nbsp;</div>