remove language selector from the login form, store language in the database per-user

This commit is contained in:
Andrew Dolgov 2013-04-29 15:54:23 +04:00
parent e57a1507ae
commit 7b149552cb
8 changed files with 34 additions and 55 deletions

View File

@ -478,14 +478,6 @@ class Handler_Public extends Handler {
<tr><td align="right"><?php echo __("Password:") ?></td>
<td align="right"><input type="password" name="password"
value="<?php echo $_SESSION["fake_password"] ?>"></td></tr>
<tr><td align="right"><?php echo __("Language:") ?></td>
<td align="right">
<?php
print_select_hash("language", $_COOKIE["ttrss_lang"], get_translations(),
"style='width : 100%''");
?>
</td></tr>
<tr><td colspan='2'>
<button type="submit">
<?php echo __('Log in') ?></button>
@ -518,7 +510,7 @@ class Handler_Public extends Handler {
if (authenticate_user($login, $password)) {
$_POST["password"] = "";
$_SESSION["language"] = $_POST["language"];
$_SESSION["language"] = get_pref("USER_LANGUAGE", $_SESSION["uid"], false);
$_SESSION["ref_schema_version"] = get_schema_version(true);
$_SESSION["bw_limit"] = !!$_POST["bw_limit"];

View File

@ -54,6 +54,7 @@ class Pref_Prefs extends Handler_Protected {
"USER_STYLESHEET" => array(__("Customize stylesheet"), __("Customize CSS stylesheet to your liking")),
"USER_TIMEZONE" => array(__("User timezone"), ""),
"VFEED_GROUP_BY_FEED" => array(__("Group headlines in virtual feeds"), __("Special feeds, labels, and categories are grouped by originating feeds")),
"USER_LANGUAGE" => array(__("Language")),
"USER_CSS_THEME" => array(__("Select theme"), __("Select one of the available CSS themes"))
);
}
@ -111,18 +112,13 @@ class Pref_Prefs extends Handler_Protected {
}
}
if ($pref_name == "language") {
if ($pref_name == "USER_LANGUAGE") {
if ($_SESSION["language"] != $value) {
setcookie("ttrss_lang", $value,
time() + COOKIE_LIFETIME_LONG);
$_SESSION["language"] = $value;
$need_reload = true;
}
} else {
set_pref($pref_name, $value);
}
set_pref($pref_name, $value);
}
if ($need_reload) {
@ -543,22 +539,6 @@ class Pref_Prefs extends Handler_Protected {
print "<tr><td colspan=\"3\"><h3>".$section_name."</h3></td></tr>";
$lnum = 0;
if ($active_section == 2) {
print "<tr>";
print "<td width=\"40%\" class=\"prefName\">";
print "<label>";
print __("Language:");
print "</label>";
print "<td>";
print_select_hash("language", $_COOKIE["ttrss_lang"], get_translations(),
"style='width : 220px; margin : 0px' dojoType='dijit.form.Select'");
print "</td>";
print "</tr>";
}
}
print "<tr>";
@ -574,7 +554,11 @@ class Pref_Prefs extends Handler_Protected {
print "<td class=\"prefValue\">";
if ($pref_name == "USER_TIMEZONE") {
if ($pref_name == "USER_LANGUAGE") {
print_select_hash($pref_name, $value, get_translations(),
"style='width : 220px; margin : 0px' dojoType='dijit.form.Select'");
} else if ($pref_name == "USER_TIMEZONE") {
$timezones = explode("\n", file_get_contents("lib/timezones.txt"));

View File

@ -1,6 +1,6 @@
<?php
define('EXPECTED_CONFIG_VERSION', 26);
define('SCHEMA_VERSION', 119);
define('SCHEMA_VERSION', 120);
define('LABEL_BASE_INDEX', -1024);
define('PLUGIN_FEED_BASE_INDEX', -128);
@ -97,11 +97,12 @@
$lang = _TRANSLATION_OVERRIDE_DEFAULT;
}
// startup_gettext() is called before session_start() so we can't rely
// on $_SESSION['language'] here.
if ($_SESSION["uid"]) {
$pref_lang = get_pref("USER_LANGUAGE", $_SESSION["uid"], false);
if ($_COOKIE["ttrss_lang"] && $_COOKIE["ttrss_lang"] != "auto") {
$lang = $_COOKIE["ttrss_lang"];
if ($pref_lang) {
$lang = $pref_lang;
}
}
if ($lang) {
@ -118,8 +119,6 @@
}
}
startup_gettext();
require_once 'db-prefs.php';
require_once 'version.php';
require_once 'ccache.php';
@ -798,12 +797,8 @@
$_SESSION["last_login_update"] = time();
}
if ($_SESSION["uid"] && $_SESSION["language"]) {
setcookie("ttrss_lang", $_SESSION["language"],
time() + COOKIE_LIFETIME_LONG);
}
if ($_SESSION["uid"]) {
startup_gettext();
load_user_plugins($_SESSION["uid"]);
/* cleanup ccache */

View File

@ -201,14 +201,6 @@ function bwLimitChange(elem) {
<?php } ?>
<div class="row">
<label><?php echo __("Language:") ?></label>
<?php
print_select_hash("language", $_COOKIE["ttrss_lang"], get_translations(),
"style='width : 220px; margin : 0px' dojoType='dijit.form.Select'");
?>
</div>
<div class="row">
<label><?php echo __("Profile:") ?></label>

View File

@ -300,7 +300,7 @@ create table ttrss_tags (id integer primary key auto_increment,
create table ttrss_version (schema_version int not null) ENGINE=InnoDB DEFAULT CHARSET=UTF8;
insert into ttrss_version values (119);
insert into ttrss_version values (120);
create table ttrss_enclosures (id integer primary key auto_increment,
content_url text not null,
@ -397,6 +397,7 @@ insert into ttrss_prefs (pref_name,type_id,def_value,section_id) values('AUTO_AS
insert into ttrss_prefs (pref_name,type_id,def_value,section_id) values('_ENABLED_PLUGINS', 2, '', 1);
insert into ttrss_prefs (pref_name,type_id,def_value,section_id) values('_MOBILE_REVERSE_HEADLINES', 1, 'false', 1);
insert into ttrss_prefs (pref_name,type_id,def_value,section_id) values('USER_CSS_THEME', 2, '', 2);
insert into ttrss_prefs (pref_name,type_id,def_value,section_id) values('USER_LANGUAGE', 2, '', 2);
update ttrss_prefs set access_level = 1 where pref_name in ('ON_CATCHUP_SHOW_NEXT_FEED',
'SORT_HEADLINES_BY_FEED_DATE',

View File

@ -258,7 +258,7 @@ create index ttrss_tags_post_int_id_idx on ttrss_tags(post_int_id);
create table ttrss_version (schema_version int not null);
insert into ttrss_version values (119);
insert into ttrss_version values (120);
create table ttrss_enclosures (id serial not null primary key,
content_url text not null,
@ -348,6 +348,7 @@ insert into ttrss_prefs (pref_name,type_id,def_value,section_id) values('AUTO_AS
insert into ttrss_prefs (pref_name,type_id,def_value,section_id) values('_ENABLED_PLUGINS', 2, '', 1);
insert into ttrss_prefs (pref_name,type_id,def_value,section_id) values('_MOBILE_REVERSE_HEADLINES', 1, 'false', 1);
insert into ttrss_prefs (pref_name,type_id,def_value,section_id) values('USER_CSS_THEME', 2, '', 2);
insert into ttrss_prefs (pref_name,type_id,def_value,section_id) values('USER_LANGUAGE', 2, '', 2);
update ttrss_prefs set access_level = 1 where pref_name in ('ON_CATCHUP_SHOW_NEXT_FEED',
'SORT_HEADLINES_BY_FEED_DATE',

View File

@ -0,0 +1,7 @@
begin;
insert into ttrss_prefs (pref_name,type_id,def_value,section_id) values('USER_LANGUAGE', 2, '', 2);
update ttrss_version set schema_version = 120;
commit;

View File

@ -0,0 +1,7 @@
begin;
insert into ttrss_prefs (pref_name,type_id,def_value,section_id) values('USER_LANGUAGE', 2, '', 2);
update ttrss_version set schema_version = 120;
commit;