From 57937c42b99d94a4046986bbfb59fdf8d765408a Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Thu, 24 Dec 2009 15:25:06 +0300 Subject: [PATCH] obsolete cookie storage for collapsed status of feedlist and special categories (bump schema) --- backend.php | 30 ++++++++++++++++++--- feedlist.js | 41 +---------------------------- functions.php | 19 +++++--------- mobile/classic/functions.php | 17 +++--------- mobile/classic/index.php | 49 +++++++++++++++++------------------ modules/backend-rpc.php | 6 ++--- sanity_check.php | 2 +- schema/ttrss_schema_mysql.sql | 10 ++++++- schema/ttrss_schema_pgsql.sql | 10 ++++++- schema/versions/mysql/59.sql | 13 ++++++++++ schema/versions/pgsql/59.sql | 13 ++++++++++ tt-rss.js | 17 +++++++----- 12 files changed, 120 insertions(+), 107 deletions(-) create mode 100644 schema/versions/mysql/59.sql create mode 100644 schema/versions/pgsql/59.sql diff --git a/backend.php b/backend.php index aa8edb7b..a25a0b5b 100644 --- a/backend.php +++ b/backend.php @@ -174,9 +174,33 @@ case "collapse": $cat_id = db_escape_string($_GET["cid"]); - db_query($link, "UPDATE ttrss_feed_categories SET - collapsed = NOT collapsed WHERE id = '$cat_id' AND owner_uid = " . - $_SESSION["uid"]); + if ($cat_id > 0) { + db_query($link, "UPDATE ttrss_feed_categories SET + collapsed = NOT collapsed WHERE id = '$cat_id' AND owner_uid = " . + $_SESSION["uid"]); + } else { + $pref_name = ''; + + switch ($cat_id) { + case -1: + $pref_name = '_COLLAPSED_SPECIAL'; + break; + case -2: + $pref_name = '_COLLAPSED_LABELS'; + break; + case 0: + $pref_name = '_COLLAPSED_UNCAT'; + break; + } + + if ($pref_name) { + if (get_pref($link, $pref_name)) { + set_pref($link, $pref_name, 'false'); + } else { + set_pref($link, $pref_name, 'true'); + } + } + } return; break; diff --git a/feedlist.js b/feedlist.js index b4e7b60e..f0cb73f7 100644 --- a/feedlist.js +++ b/feedlist.js @@ -389,45 +389,6 @@ function toggleCollapseCat(cat) { var cat_list = $("FCATLIST-" + cat).parentNode; var caption = $("FCAP-" + cat); -/* if (cat_list.className.match("invisible")) { - cat_list.className = ""; - caption.innerHTML = caption.innerHTML.replace("...", ""); - if (cat == 0) { - setCookie("ttrss_vf_uclps", "0"); - } - } else { - cat_list.className = "invisible"; - caption.innerHTML = caption.innerHTML + "..."; - if (cat == 0) { - setCookie("ttrss_vf_uclps", "1"); - } - - } */ - - if (cat == 0) { - if (Element.visible("FCATLIST-" + cat)) { - setCookie("ttrss_vf_uclps", "1"); - } else { - setCookie("ttrss_vf_uclps", "0"); - } - } - - if (cat == -2) { - if (Element.visible("FCATLIST-" + cat)) { - setCookie("ttrss_vf_lclps", "1"); - } else { - setCookie("ttrss_vf_lclps", "0"); - } - } - - if (cat == -1) { - if (Element.visible("FCATLIST-" + cat)) { - setCookie("ttrss_vf_vclps", "1"); - } else { - setCookie("ttrss_vf_vclps", "0"); - } - } - Effect.toggle('FCATLIST-' + cat, 'blind', { duration: 0.5, afterFinish: toggleCollapseCat_af }); @@ -602,7 +563,7 @@ function init_collapsable_feedlist(theme) { if (fbtn) Element.show(fbtn); - if (getCookie("ttrss_vf_fclps") == 1) { + if (getInitParam("collapsed_feedlist") == 1) { collapse_feedlist(); } diff --git a/functions.php b/functions.php index 26e57ab4..d7ef40cf 100644 --- a/functions.php +++ b/functions.php @@ -3080,6 +3080,9 @@ print ""; + print ""; + print ""; } @@ -4162,11 +4165,7 @@ if (get_pref($link, 'ENABLE_FEED_CATS')) { - if ($_COOKIE["ttrss_vf_vclps"] == 1) { - $cat_hidden = true; - } else { - $cat_hidden = false; - } + $cat_hidden = get_pref($link, "_COLLAPSED_SPECIAL"); printCategoryHeader($link, -1, $cat_hidden, false); } @@ -4225,11 +4224,7 @@ if (db_num_rows($result) > 0) { if (get_pref($link, 'ENABLE_FEED_CATS')) { - if ($_COOKIE["ttrss_vf_lclps"] == 1) { - $cat_hidden = true; - } else { - $cat_hidden = false; - } + $cat_hidden = get_pref($link, "_COLLAPSED_LABELS"); printCategoryHeader($link, -2, $cat_hidden, true); @@ -4381,9 +4376,7 @@ // workaround for NULL category if ($category == __("Uncategorized")) { - if ($_COOKIE["ttrss_vf_uclps"] == 1) { - $collapsed = "t"; - } + $collapsed = get_pref($link, "_COLLAPSED_UNCAT"); } $cat_id = sprintf("%d", $cat_id); diff --git a/mobile/classic/functions.php b/mobile/classic/functions.php index 88b25ab2..823af122 100644 --- a/mobile/classic/functions.php +++ b/mobile/classic/functions.php @@ -30,11 +30,8 @@ /* virtual feeds */ if (get_pref($link, 'ENABLE_FEED_CATS')) { - if ($_COOKIE["ttrss_vf_vclps"] == 1) { - $collapsed = true; - } else { - $collapsed = false; - } + + $collapsed = get_pref($link, "_COLLAPSED_SPECIAL"); if ($collapsed == "t" || $collapsed == "1") { $holder_class = "invisible"; @@ -100,11 +97,7 @@ if (db_num_rows($result) > 0) { if (get_pref($link, 'ENABLE_FEED_CATS')) { - if ($_COOKIE["ttrss_vf_lclps"] == 1) { - $collapsed = true; - } else { - $collapsed = false; - } + $collapsed = get_pref($link, "_COLLAPSED_LABELS"); if ($collapsed == "t" || $collapsed == "1") { $holder_class = "invisible"; @@ -250,9 +243,7 @@ // workaround for NULL category if ($category == "Uncategorized") { - if ($_COOKIE["ttrss_vf_uclps"] == 1) { - $collapsed = "t"; - } + $collapsed = get_pref($link, "_COLLAPSED_UNCAT"); } if ($collapsed == "t" || $collapsed == "1") { diff --git a/mobile/classic/index.php b/mobile/classic/index.php index 6a3aa522..4b158395 100644 --- a/mobile/classic/index.php +++ b/mobile/classic/index.php @@ -27,35 +27,34 @@ $cat_id = db_escape_string($_GET["id"]); - switch ($cat_id) { - case 0: - if ($_COOKIE["ttrss_vf_uclps"] != 1) { - setcookie("ttrss_vf_uclps", 1); - } else { - setcookie("ttrss_vf_uclps", 0); - } - break; - case -1: - if ($_COOKIE["ttrss_vf_vclps"] != 1) { - setcookie("ttrss_vf_vclps", 1); - } else { - setcookie("ttrss_vf_vclps", 0); - } - break; - case -2: - if ($_COOKIE["ttrss_vf_lclps"] != 1) { - setcookie("ttrss_vf_lclps", 1); - } else { - setcookie("ttrss_vf_lclps", 0); - } - break; - default: + if ($cat_id > 0) { db_query($link, "UPDATE ttrss_feed_categories SET collapsed = NOT collapsed WHERE id = '$cat_id' AND owner_uid = " . $_SESSION["uid"]); - break; + } else { + $pref_name = ''; + + switch ($cat_id) { + case -1: + $pref_name = '_COLLAPSED_SPECIAL'; + break; + case -2: + $pref_name = '_COLLAPSED_LABELS'; + break; + case 0: + $pref_name = '_COLLAPSED_UNCAT'; + break; + } + + if ($pref_name) { + if (get_pref($link, $pref_name)) { + set_pref($link, $pref_name, 'false'); + } else { + set_pref($link, $pref_name, 'true'); + } + } } - + header("Location: index.php"); return; } diff --git a/modules/backend-rpc.php b/modules/backend-rpc.php index 1a65efc0..686602d6 100644 --- a/modules/backend-rpc.php +++ b/modules/backend-rpc.php @@ -633,17 +633,17 @@ ttrss_feed_categories WHERE owner_uid = ".$_SESSION["uid"]); print ""; print ""; print ""; diff --git a/sanity_check.php b/sanity_check.php index 55df9814..28188098 100644 --- a/sanity_check.php +++ b/sanity_check.php @@ -2,7 +2,7 @@ require_once "functions.php"; define('EXPECTED_CONFIG_VERSION', 18); - define('SCHEMA_VERSION', 58); + define('SCHEMA_VERSION', 59); if (!file_exists("config.php")) { print "Fatal Error: You forgot to copy diff --git a/schema/ttrss_schema_mysql.sql b/schema/ttrss_schema_mysql.sql index 04c601fa..95edaffd 100644 --- a/schema/ttrss_schema_mysql.sql +++ b/schema/ttrss_schema_mysql.sql @@ -226,7 +226,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 (58); +insert into ttrss_version values (59); create table ttrss_enclosures (id serial not null primary key, content_url text not null, @@ -361,6 +361,14 @@ insert into ttrss_prefs (pref_name,type_id,def_value,short_desc,section_id,help_ insert into ttrss_prefs (pref_name,type_id,def_value,short_desc,section_id) values('ENABLE_API_ACCESS', 1, 'false', 'Enable external API', 3); +insert into ttrss_prefs (pref_name,type_id,def_value,short_desc,section_id) values('_COLLAPSED_SPECIAL', 1, 'false', '', 1); + +insert into ttrss_prefs (pref_name,type_id,def_value,short_desc,section_id) values('_COLLAPSED_LABELS', 1, 'false', '', 1); + +insert into ttrss_prefs (pref_name,type_id,def_value,short_desc,section_id) values('_COLLAPSED_UNCAT', 1, 'false', '', 1); + +insert into ttrss_prefs (pref_name,type_id,def_value,short_desc,section_id) values('_COLLAPSED_FEEDLIST', 1, 'false', '', 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 b2458d4b..0b6f719e 100644 --- a/schema/ttrss_schema_pgsql.sql +++ b/schema/ttrss_schema_pgsql.sql @@ -202,7 +202,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 (58); +insert into ttrss_version values (59); create table ttrss_enclosures (id serial not null primary key, content_url text not null, @@ -331,6 +331,14 @@ insert into ttrss_prefs (pref_name,type_id,def_value,short_desc,section_id,help_ insert into ttrss_prefs (pref_name,type_id,def_value,short_desc,section_id) values('ENABLE_API_ACCESS', 1, 'false', 'Enable external API', 3); +insert into ttrss_prefs (pref_name,type_id,def_value,short_desc,section_id) values('_COLLAPSED_SPECIAL', 1, 'false', '', 1); + +insert into ttrss_prefs (pref_name,type_id,def_value,short_desc,section_id) values('_COLLAPSED_LABELS', 1, 'false', '', 1); + +insert into ttrss_prefs (pref_name,type_id,def_value,short_desc,section_id) values('_COLLAPSED_UNCAT', 1, 'false', '', 1); + +insert into ttrss_prefs (pref_name,type_id,def_value,short_desc,section_id) values('_COLLAPSED_FEEDLIST', 1, 'false', '', 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/59.sql b/schema/versions/mysql/59.sql new file mode 100644 index 00000000..d51fe8f6 --- /dev/null +++ b/schema/versions/mysql/59.sql @@ -0,0 +1,13 @@ +begin; + +insert into ttrss_prefs (pref_name,type_id,def_value,short_desc,section_id) values('_COLLAPSED_SPECIAL', 1, 'false', '', 1); + +insert into ttrss_prefs (pref_name,type_id,def_value,short_desc,section_id) values('_COLLAPSED_LABELS', 1, 'false', '', 1); + +insert into ttrss_prefs (pref_name,type_id,def_value,short_desc,section_id) values('_COLLAPSED_FEEDLIST', 1, 'false', '', 1); + +insert into ttrss_prefs (pref_name,type_id,def_value,short_desc,section_id) values('_COLLAPSED_UNCAT', 1, 'false', '', 1); + +update ttrss_version set schema_version = 59; + +commit; diff --git a/schema/versions/pgsql/59.sql b/schema/versions/pgsql/59.sql new file mode 100644 index 00000000..d51fe8f6 --- /dev/null +++ b/schema/versions/pgsql/59.sql @@ -0,0 +1,13 @@ +begin; + +insert into ttrss_prefs (pref_name,type_id,def_value,short_desc,section_id) values('_COLLAPSED_SPECIAL', 1, 'false', '', 1); + +insert into ttrss_prefs (pref_name,type_id,def_value,short_desc,section_id) values('_COLLAPSED_LABELS', 1, 'false', '', 1); + +insert into ttrss_prefs (pref_name,type_id,def_value,short_desc,section_id) values('_COLLAPSED_FEEDLIST', 1, 'false', '', 1); + +insert into ttrss_prefs (pref_name,type_id,def_value,short_desc,section_id) values('_COLLAPSED_UNCAT', 1, 'false', '', 1); + +update ttrss_version set schema_version = 59; + +commit; diff --git a/tt-rss.js b/tt-rss.js index af5c6fae..86b4e564 100644 --- a/tt-rss.js +++ b/tt-rss.js @@ -27,7 +27,6 @@ function activeFeedIsCat() { } function getActiveFeedId() { -// return getCookie("ttrss_vf_actfeed"); try { debug("gAFID: " + _active_feed_id); return _active_feed_id; @@ -37,7 +36,6 @@ function getActiveFeedId() { } function setActiveFeedId(id, is_cat) { -// return setCookie("ttrss_vf_actfeed", id); try { debug("sAFID(" + id + ", " + is_cat + ")"); _active_feed_id = id; @@ -372,9 +370,9 @@ function genericSanityCheck() { // if (!Ajax.getTransport()) fatalError(1); - setCookie("ttrss_vf_test", "TEST"); + setCookie("ttrss_test", "TEST"); - if (getCookie("ttrss_vf_test") != "TEST") { + if (getCookie("ttrss_test") != "TEST") { fatalError(2); } @@ -504,7 +502,7 @@ function init_second_stage() { try { - delCookie("ttrss_vf_test"); + delCookie("ttrss_test"); // document.onresize = resize_headlines; window.onresize=resize_headlines; @@ -943,7 +941,9 @@ function collapse_feedlist() { if (fc) fc.style.left = fl.offsetWidth + 40 + "px"; } - setCookie("ttrss_vf_fclps", "0"); + query = "backend.php?op=rpc&subop=setpref&key=_COLLAPSED_FEEDLIST&value=false"; + + new Ajax.Request(query); } else { Element.hide(fl); @@ -965,7 +965,10 @@ function collapse_feedlist() { } - setCookie("ttrss_vf_fclps", "1"); + query = "backend.php?op=rpc&subop=setpref&key=_COLLAPSED_FEEDLIST&value=true"; + + new Ajax.Request(query); + } } catch (e) { exception_error("toggle_feedlist", e); -- 2.39.5