]> git.wh0rd.org Git - tt-rss.git/commitdiff
obsolete cookie storage for collapsed status of feedlist and special categories ...
authorAndrew Dolgov <fox@bah.org.ru>
Thu, 24 Dec 2009 12:25:06 +0000 (15:25 +0300)
committerAndrew Dolgov <fox@bah.org.ru>
Thu, 24 Dec 2009 12:25:06 +0000 (15:25 +0300)
12 files changed:
backend.php
feedlist.js
functions.php
mobile/classic/functions.php
mobile/classic/index.php
modules/backend-rpc.php
sanity_check.php
schema/ttrss_schema_mysql.sql
schema/ttrss_schema_pgsql.sql
schema/versions/mysql/59.sql [new file with mode: 0644]
schema/versions/pgsql/59.sql [new file with mode: 0644]
tt-rss.js

index aa8edb7ba81f2b8ba7aa037415a6e2682ec6cb7a..a25a0b5be177c9322aaeda052f4d0a9c49b1ca0c 100644 (file)
                                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;
 
index b4e7b60ef95d3cd29e5cd8ddc39249f12fcbfdf3..f0cb73f77d3215871c0f78302cb05969a0e1247f 100644 (file)
@@ -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();
                }
 
index 26e57ab4a716dd51d07e5b6be1e55a52f3307218..d7ef40cf6745c6d770e1bdb23e4f56b46b0e4dfa 100644 (file)
                print "<param key=\"num_feeds\" value=\"".
                        (int)$num_feeds. "\"/>";
 
+               print "<param key=\"collapsed_feedlist\" value=\"" . 
+                       (int) get_pref($link, "_COLLAPSED_FEEDLIST") . "\"/>";
+
                print "</init-params>";
        }
 
 
                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);
                }
                                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);
 
 
                                        // 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);
index 88b25ab253f396ed3161ce8f0f17d56b2e66f187..823af122f5b4446863db401972b66c421b80c6d6 100644 (file)
                        /* 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";
                                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";
 
                                        // 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") {
index 6a3aa52261019a91c73d119319d0b514754e62bd..4b158395bf6da340c448f2316c73f1c3393066f4 100644 (file)
                
                $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;
        }
index 1a65efc025f06277db552e6e10ec3c3d03fd1ce3..686602d6f80d2c016b9e90d540b5624137d55a89 100644 (file)
                                        ttrss_feed_categories WHERE owner_uid = ".$_SESSION["uid"]);
 
                                        print "<category id=\"0\" collapsed=\"".
-                                               (int)$_COOKIE["ttrss_vf_uclps"]."\"><![CDATA[";
+                                               (int)get_pref($link, "_COLLAPSED_UNCAT")."\"><![CDATA[";
                                        print __("Uncategorized");
                                        print "]]></category>";
 
                                        print "<category id=\"-1\" collapsed=\"".
-                                               (int)$_COOKIE["ttrss_vf_vclps"]."\"><![CDATA[";
+                                               (int)get_pref($link, "_COLLAPSED_SPECIAL")."\"><![CDATA[";
                                        print __("Special");
                                        print "]]></category>";
 
                                        print "<category id=\"-2\" collapsed=\"".
-                                               (int)$_COOKIE["ttrss_vf_lclps"]."\"><![CDATA[";
+                                               (int)get_pref($link, "_COLLAPSED_LABELS")."\"><![CDATA[";
                                        print __("Labels");
                                        print "]]></category>";
 
index 55df981415d06b21e29b37c792322f60d0b30e6a..2818809847798d0b16f05f5c28bccb73b4e35164 100644 (file)
@@ -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 "<b>Fatal Error</b>: You forgot to copy 
index 04c601faea3b2720e181d495a6620cc9e4ab5f59..95edaffdd1d97fb814f88f34b86f0313decac044 100644 (file)
@@ -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),
index b2458d4bada76ac69c62f7028c4777021022c929..0b6f719e14217a3de0948b9b19ba2e5db62a1114 100644 (file)
@@ -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 (file)
index 0000000..d51fe8f
--- /dev/null
@@ -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 (file)
index 0000000..d51fe8f
--- /dev/null
@@ -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;
index af5c6fae0cc7c4bb7e303d0dd47f8aacac4e7b91..86b4e564478cbbc5748722e5bbcd2f0a42e90fa6 100644 (file)
--- 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);