]> git.wh0rd.org Git - tt-rss.git/commitdiff
remove language selector from the login form, store language in the database per...
authorAndrew Dolgov <fox@madoka.volgo-balt.ru>
Mon, 29 Apr 2013 11:54:23 +0000 (15:54 +0400)
committerAndrew Dolgov <fox@madoka.volgo-balt.ru>
Mon, 29 Apr 2013 11:54:23 +0000 (15:54 +0400)
classes/handler/public.php
classes/pref/prefs.php
include/functions.php
include/login_form.php
schema/ttrss_schema_mysql.sql
schema/ttrss_schema_pgsql.sql
schema/versions/mysql/120.sql [new file with mode: 0644]
schema/versions/pgsql/120.sql [new file with mode: 0644]

index 0d9b046869eb02eece62bb788f3afa55ddec1757..2b5169ca7f6d8d6094648d3c9493f77704e04c71 100644 (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"];
 
index 35065ea7b262d2314f591d5cc4912830c10a4742..157abb8bc55b3e082ac232e95c6fab84d42908bd 100644 (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"));
 
index 38c3eac32e9f49992af671057db56170a1b95152..b3130104b138b8aa525375beabb3c2377ab6be04 100644 (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);
                        $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) {
                }
        }
 
-       startup_gettext();
-
        require_once 'db-prefs.php';
        require_once 'version.php';
        require_once 'ccache.php';
                                $_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 */
index 9a20e9be9817120237c98b4ac64f56add17917f5..b7dae10166c77bfaa00d6ad7254baa5a4ac85e14 100644 (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>
 
index efa7be7cf7d6871377d94a6b617226301669d976..aa11970914d3755a19530244af9b309900388442 100644 (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',
index c04e5224b65eb96827a3215c97d899c2b12e4e74..79634678d12c05306edcc8a67c70b34d40716e8b 100644 (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',
diff --git a/schema/versions/mysql/120.sql b/schema/versions/mysql/120.sql
new file mode 100644 (file)
index 0000000..3497114
--- /dev/null
@@ -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 (file)
index 0000000..3497114
--- /dev/null
@@ -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;