From 4049672041287a491919c01d80017c7b767c3461 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Mon, 26 Mar 2007 06:23:15 +0100 Subject: [PATCH] add persistent storage for toolbar view options, bump schema --- backend.php | 5 ++- feedlist.js | 6 ---- functions.js | 62 ++--------------------------------- functions.php | 6 ++++ modules/pref-prefs.php | 1 + prefs.js | 4 --- schema/ttrss_schema_mysql.sql | 6 +++- schema/ttrss_schema_pgsql.sql | 6 +++- schema/versions/mysql/15.sql | 5 +++ schema/versions/pgsql/15.sql | 5 +++ tt-rss.js | 6 ++-- update.php | 2 +- 12 files changed, 37 insertions(+), 77 deletions(-) create mode 100644 schema/versions/mysql/15.sql create mode 100644 schema/versions/pgsql/15.sql diff --git a/backend.php b/backend.php index b15101fd..45c97802 100644 --- a/backend.php +++ b/backend.php @@ -12,7 +12,7 @@ error_reporting(DEFAULT_ERROR_LEVEL); */ - define('SCHEMA_VERSION', 14); + define('SCHEMA_VERSION', 15); require_once "sanity_check.php"; require_once "config.php"; @@ -305,6 +305,9 @@ if (!$offset) $offset = 0; + set_pref($link, "_DEFAULT_VIEW_MODE", $view_mode); + set_pref($link, "_DEFAULT_VIEW_LIMIT", $limit); + if ($subop == "undefined") $subop = ""; if ($subop == "CatchupSelected") { diff --git a/feedlist.js b/feedlist.js index ddf12f29..9d6be547 100644 --- a/feedlist.js +++ b/feedlist.js @@ -57,12 +57,6 @@ function viewfeed(feed, subop, is_cat, subop_param, skip_history, offset) { toolbar_form.query.value = ""; } - storeInitParam("toolbar_limit", - toolbar_form.limit[toolbar_form.limit.selectedIndex].value); - - storeInitParam("toolbar_view_mode", - toolbar_form.view_mode[toolbar_form.view_mode.selectedIndex].value); - var query = "backend.php?op=viewfeed&feed=" + feed + "&" + toolbar_query + "&subop=" + param_escape(subop); diff --git a/functions.js b/functions.js index 1172a49f..608284dc 100644 --- a/functions.js +++ b/functions.js @@ -1502,71 +1502,13 @@ function debug(msg) { } function getInitParam(key) { - var c = getCookie("TTIP:" + key); - if (c) { - return c; - } else { - return getMainContext().init_params[key]; - } + return init_params[key]; } function storeInitParam(key, value) { - try { - init_params[key] = value; - debug("storeInitParam: " + key + " => " + value + - " (" + getInitParam("cookie_lifetime") + ")"); - if (getInitParam("cookie_lifetime") > 0) { - setCookie("TTIP:" + key, value, getInitParam("cookie_lifetime")); - } else { - setCookie("TTIP:" + key, value); - } - } catch (e) { - exception_error("storeInitParam", e); - } + debug("storeInitParam is OBSOLETE: " + key + " => " + value + ""); } - -/* -function storeInitParam(key, value, is_client) { - try { - if (!is_client) { - if (getMainContext().init_params[key] != value) { - debug("storeInitParam: " + key + " => " + value); - //new Ajax.Request("backend.php?op=rpc&subop=storeParam&key=" + - // param_escape(key) + "&value=" + param_escape(value)); - var f = getMainContext().document.getElementById("backReqBox"); - f.src = "backend.php?op=rpc&subop=storeParam&key=" + - param_escape(key) + "&value=" + param_escape(value); - } - } - getMainContext().init_params[key] = value; - } catch (e) { - exception_error("storeInitParam", e); - } -} */ - -/* -function storeInitParams(params, is_client) { - try { - var s = ""; - - for (k in params) { - if (getMainContext().init_params[k] != params[k]) { - s += k + "=" + params[k] + ";"; - getMainContext().init_params[k] = params[k]; - } - } - - debug("storeInitParams: " + s); - - if (!is_client) { - new Ajax.Request("backend.php?op=rpc&subop=storeParams&str=" + s); - } - } catch (e) { - exception_error("storeInitParams", e); - } -}*/ - function fatalError(code, message) { try { diff --git a/functions.php b/functions.php index 05ac12dd..e98f36f6 100644 --- a/functions.php +++ b/functions.php @@ -2205,6 +2205,12 @@ print ""; + print ""; + + print ""; + print ""; } diff --git a/modules/pref-prefs.php b/modules/pref-prefs.php index e9ebc183..37c6c9b5 100644 --- a/modules/pref-prefs.php +++ b/modules/pref-prefs.php @@ -308,6 +308,7 @@ WHERE type_id = ttrss_prefs_types.id AND section_id = ttrss_prefs_sections.id AND ttrss_user_prefs.pref_name = ttrss_prefs.pref_name AND + short_desc != '' AND owner_uid = ".$_SESSION["uid"]." ORDER BY section_id,short_desc"); diff --git a/prefs.js b/prefs.js index a6e5d084..c8cb3558 100644 --- a/prefs.js +++ b/prefs.js @@ -1219,10 +1219,6 @@ function selectTab(id, noupdate, subop) { } } - if (active_tab != id) { - storeInitParam("prefs_active_tab", id); - } - active_tab = id; } catch (e) { diff --git a/schema/ttrss_schema_mysql.sql b/schema/ttrss_schema_mysql.sql index 1097a4e1..0afcac5d 100644 --- a/schema/ttrss_schema_mysql.sql +++ b/schema/ttrss_schema_mysql.sql @@ -188,7 +188,7 @@ create table ttrss_tags (id integer primary key auto_increment, create table ttrss_version (schema_version int not null) TYPE=InnoDB; -insert into ttrss_version values (14); +insert into ttrss_version values (15); create table ttrss_prefs_types (id integer not null primary key, type_name varchar(100) not null) TYPE=InnoDB; @@ -267,6 +267,10 @@ insert into ttrss_prefs (pref_name,type_id,def_value,short_desc,section_id) valu insert into ttrss_prefs (pref_name,type_id,def_value,short_desc,section_id,help_text) values('CDM_AUTO_CATCHUP', 1, 'false', 'Mark articles as read automatically',2, 'This option enables marking articles as read automatically in combined mode while you scroll article list.'); +insert into ttrss_prefs (pref_name,type_id,def_value,short_desc,section_id) values('_DEFAULT_VIEW_MODE', 2, 'adaptive', '', 1); + +insert into ttrss_prefs (pref_name,type_id,def_value,short_desc,section_id) values('_DEFAULT_VIEW_LIMIT', 3, '30', '', 1); + create table ttrss_user_prefs ( owner_uid integer not null, pref_name varchar(250), diff --git a/schema/ttrss_schema_pgsql.sql b/schema/ttrss_schema_pgsql.sql index 24436b3a..4501ef1c 100644 --- a/schema/ttrss_schema_pgsql.sql +++ b/schema/ttrss_schema_pgsql.sql @@ -172,7 +172,7 @@ create index ttrss_tags_owner_uid_index on ttrss_tags(owner_uid); create table ttrss_version (schema_version int not null); -insert into ttrss_version values (14); +insert into ttrss_version values (15); create table ttrss_prefs_types (id integer not null primary key, type_name varchar(100) not null); @@ -247,6 +247,10 @@ insert into ttrss_prefs (pref_name,type_id,def_value,short_desc,section_id) valu insert into ttrss_prefs (pref_name,type_id,def_value,short_desc,section_id,help_text) values('CDM_AUTO_CATCHUP', 1, 'false', 'Mark articles as read automatically',2, 'This option enables marking articles as read automatically in combined mode while you scroll article list.'); +insert into ttrss_prefs (pref_name,type_id,def_value,short_desc,section_id) values('_DEFAULT_VIEW_MODE', 2, 'adaptive', '', 1); + +insert into ttrss_prefs (pref_name,type_id,def_value,short_desc,section_id) values('_DEFAULT_VIEW_LIMIT', 3, '30', '', 1); + create table ttrss_user_prefs ( owner_uid integer not null references ttrss_users(id) ON DELETE CASCADE, pref_name varchar(250) not null references ttrss_prefs(pref_name) ON DELETE CASCADE, diff --git a/schema/versions/mysql/15.sql b/schema/versions/mysql/15.sql new file mode 100644 index 00000000..9fa183a0 --- /dev/null +++ b/schema/versions/mysql/15.sql @@ -0,0 +1,5 @@ +insert into ttrss_prefs (pref_name,type_id,def_value,short_desc,section_id) values('_DEFAULT_VIEW_MODE', 2, 'adaptive', '', 1); + +insert into ttrss_prefs (pref_name,type_id,def_value,short_desc,section_id) values('_DEFAULT_VIEW_LIMIT', 3, '30', '', 1); + +update ttrss_version set schema_version = 15; diff --git a/schema/versions/pgsql/15.sql b/schema/versions/pgsql/15.sql new file mode 100644 index 00000000..9fa183a0 --- /dev/null +++ b/schema/versions/pgsql/15.sql @@ -0,0 +1,5 @@ +insert into ttrss_prefs (pref_name,type_id,def_value,short_desc,section_id) values('_DEFAULT_VIEW_MODE', 2, 'adaptive', '', 1); + +insert into ttrss_prefs (pref_name,type_id,def_value,short_desc,section_id) values('_DEFAULT_VIEW_LIMIT', 3, '30', '', 1); + +update ttrss_version set schema_version = 15; diff --git a/tt-rss.js b/tt-rss.js index bc5bc820..5f913f86 100644 --- a/tt-rss.js +++ b/tt-rss.js @@ -386,10 +386,10 @@ function init_second_stage() { document.onkeydown = hotkey_handler; - var tb = parent.document.forms["main_toolbar_form"]; + var toolbar = document.forms["main_toolbar_form"]; - dropboxSelect(tb.view_mode, getInitParam("toolbar_view_mode")); - dropboxSelect(tb.limit, getInitParam("toolbar_limit")); + dropboxSelect(toolbar.view_mode, getInitParam("default_view_mode")); + dropboxSelect(toolbar.limit, getInitParam("default_view_limit")); daemon_enabled = getInitParam("daemon_enabled") == 1; daemon_refresh_only = getInitParam("daemon_refresh_only") == 1; diff --git a/update.php b/update.php index 3851679a..bab0543d 100644 --- a/update.php +++ b/update.php @@ -25,7 +25,7 @@ exit; } - define('SCHEMA_VERSION', 14); + define('SCHEMA_VERSION', 15); ?> -- 2.39.2