From 7b149552cb99a44f1fbeef642ffc60e91b1f61a0 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Mon, 29 Apr 2013 15:54:23 +0400 Subject: [PATCH] remove language selector from the login form, store language in the database per-user --- classes/handler/public.php | 10 +--------- classes/pref/prefs.php | 32 ++++++++------------------------ include/functions.php | 19 +++++++------------ include/login_form.php | 8 -------- schema/ttrss_schema_mysql.sql | 3 ++- schema/ttrss_schema_pgsql.sql | 3 ++- schema/versions/mysql/120.sql | 7 +++++++ schema/versions/pgsql/120.sql | 7 +++++++ 8 files changed, 34 insertions(+), 55 deletions(-) create mode 100644 schema/versions/mysql/120.sql create mode 100644 schema/versions/pgsql/120.sql diff --git a/classes/handler/public.php b/classes/handler/public.php index 0d9b04686..2b5169ca7 100644 --- a/classes/handler/public.php +++ b/classes/handler/public.php @@ -478,14 +478,6 @@ class Handler_Public extends Handler { "> - - - - @@ -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"]; diff --git a/classes/pref/prefs.php b/classes/pref/prefs.php index 35065ea7b..157abb8bc 100644 --- a/classes/pref/prefs.php +++ b/classes/pref/prefs.php @@ -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 "

".$section_name."

"; $lnum = 0; - - if ($active_section == 2) { - print ""; - - print ""; - print ""; - - print ""; - print_select_hash("language", $_COOKIE["ttrss_lang"], get_translations(), - "style='width : 220px; margin : 0px' dojoType='dijit.form.Select'"); - print ""; - print ""; - } - } print ""; @@ -574,7 +554,11 @@ class Pref_Prefs extends Handler_Protected { print ""; - 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")); diff --git a/include/functions.php b/include/functions.php index 38c3eac32..b3130104b 100644 --- a/include/functions.php +++ b/include/functions.php @@ -1,6 +1,6 @@ -
- - -
-
diff --git a/schema/ttrss_schema_mysql.sql b/schema/ttrss_schema_mysql.sql index efa7be7cf..aa1197091 100644 --- a/schema/ttrss_schema_mysql.sql +++ b/schema/ttrss_schema_mysql.sql @@ -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', diff --git a/schema/ttrss_schema_pgsql.sql b/schema/ttrss_schema_pgsql.sql index c04e5224b..79634678d 100644 --- a/schema/ttrss_schema_pgsql.sql +++ b/schema/ttrss_schema_pgsql.sql @@ -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', diff --git a/schema/versions/mysql/120.sql b/schema/versions/mysql/120.sql new file mode 100644 index 000000000..34971146e --- /dev/null +++ b/schema/versions/mysql/120.sql @@ -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; diff --git a/schema/versions/pgsql/120.sql b/schema/versions/pgsql/120.sql new file mode 100644 index 000000000..34971146e --- /dev/null +++ b/schema/versions/pgsql/120.sql @@ -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;