summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Dolgov <[email protected]>2013-04-29 15:54:23 +0400
committerAndrew Dolgov <[email protected]>2013-04-29 15:54:23 +0400
commit7b149552cb99a44f1fbeef642ffc60e91b1f61a0 (patch)
tree54c4d22d0078dbd2b3e79773251b74afb8ba2bbe
parente57a1507aeb349c9ba7d673048c5ccb43e2d639b (diff)
remove language selector from the login form, store language in the database per-user
-rw-r--r--classes/handler/public.php10
-rw-r--r--classes/pref/prefs.php32
-rw-r--r--include/functions.php19
-rw-r--r--include/login_form.php8
-rw-r--r--schema/ttrss_schema_mysql.sql3
-rw-r--r--schema/ttrss_schema_pgsql.sql3
-rw-r--r--schema/versions/mysql/120.sql7
-rw-r--r--schema/versions/pgsql/120.sql7
8 files changed, 34 insertions, 55 deletions
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 {
<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"];
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 "<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"));
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 @@
<?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 */
diff --git a/include/login_form.php b/include/login_form.php
index 9a20e9be9..b7dae1016 100644
--- a/include/login_form.php
+++ b/include/login_form.php
@@ -202,14 +202,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>
<span id='profile_box'><select disabled='disabled' dojoType='dijit.form.Select'
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;