]> git.wh0rd.org Git - tt-rss.git/commitdiff
new option: HIDE_READ_FEEDS (+ pref setting RPC calls) (closes #23)
authorAndrew Dolgov <fox@bah.spb.su>
Thu, 5 Jan 2006 15:12:40 +0000 (16:12 +0100)
committerAndrew Dolgov <fox@bah.spb.su>
Thu, 5 Jan 2006 15:12:40 +0000 (16:12 +0100)
backend.php
db-prefs.php
schema/ttrss_schema_mysql.sql
schema/ttrss_schema_pgsql.sql
schema/upgrade-1.1.1-1.1.2-mysql.sql
schema/upgrade-1.1.1-1.1.2-pgsql.sql
tt-rss.js

index 52b4f34600f856dfc22c42e0c46172251ec5717c..6fdd3c8e5878f2c2a1bfca7205989ff258a45f98 100644 (file)
                pg_query("set client_encoding = 'utf-8'");
        }
 
+       if (get_pref($link, "HIDE_READ_FEEDS") == "true") {
+               setcookie("ttrss_vf_hreadf", 1);
+       } else {
+               setcookie("ttrss_vf_hreadf", 0);
+       }  
+
        $fetch = $_GET["fetch"];
 
        setcookie("ttrss_icons_url", ICONS_URL);
 
                $subop = $_GET["subop"];
 
+               if ($subop == "setpref") {
+                       if (WEB_DEMO_MODE) {
+                               return;
+                       }
+
+                       print "<rpc-reply>";
+
+                       $key = db_escape_string($_GET["key"]);
+                       $value = db_escape_string($_GET["value"]);
+
+                       set_pref($link, $key, $value);
+
+                       print "<param-set key=\"$key\" value=\"$value\"/>";
+
+                       print "</rpc-reply>";
+
+               }
+
                if ($subop == "getLabelCounters") {
                        $aid = $_GET["aid"];            
                        print "<rpc-reply>";
index 293af7beaeb74ce0cf9c124aa3215ec7def51f65..1b6262d9a13ce311bcff7e32aeaa57f7e645fb3d 100644 (file)
                        return $value;
                }
        }
+
+       // doesn't peform any type checking, be vigilant
+       
+       function set_pref($link, $key, $value) {
+               $key = db_escape_string($key);
+               $value = db_escape_string($value);
+       
+               db_query($link, "UPDATE ttrss_user_prefs SET 
+                       value = '$value' WHERE pref_name = '$key' 
+                               AND owner_uid = " . $_SESSION["uid"]);
+
+               $_SESSION["prefs_cache"] = array();
+
+       }
 ?>
index c80d18445d9aabd725dfb33713935380a51a11a1..8b62cd837d1a1434f0dd9bad2948aad365bdc9da 100644 (file)
@@ -235,6 +235,8 @@ 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_SEARCH_TOOLBAR', 1, 'false', 'Enable search toolbar',2);
 
+insert into ttrss_prefs (pref_name,type_id,def_value,short_desc,section_id) values('HIDE_READ_FEEDS', 1, 'false', 'Hide feeds with no unread messages',2);
+
 create table ttrss_user_prefs (
    owner_uid integer not null,
    pref_name varchar(250),
index 2deae60608b85907099b90cd6da6f9757b2f9257..a0d570d36ebc6bf774f10e98693375ff285a9970 100644 (file)
@@ -213,6 +213,8 @@ 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_SEARCH_TOOLBAR', 1, 'false', 'Enable search toolbar',2);
 
+insert into ttrss_prefs (pref_name,type_id,def_value,short_desc,section_id) values('HIDE_READ_FEEDS', 1, 'false', 'Hide feeds with no unread messages',2);
+
 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,
index d6c8a522dbaca80bbd1f727b0eb4a9cb90aa0c3a..6dfc5f82f10096bdb672d02907b97071f99032c1 100644 (file)
@@ -10,6 +10,8 @@ update ttrss_feeds set private = false;
 alter table ttrss_feeds change private private bool not null;
 alter table ttrss_feeds alter column private set default 0;
 
+insert into ttrss_prefs (pref_name,type_id,def_value,short_desc,section_id) values('HIDE_READ_FEEDS', 1, 'false', 'Hide feeds with no unread messages',2);
+
 update ttrss_version set schema_version = 4;
 
 commit;
index 960ed8b64d6d5e7a3d0cb87dd2765dc407ef3a5d..1f926eaeb6f1734e1768d11d8735452bef160bc9 100644 (file)
@@ -10,6 +10,8 @@ update ttrss_feeds set private = false;
 alter table ttrss_feeds alter column private set not null;
 alter table ttrss_feeds alter column private set default false;
 
+insert into ttrss_prefs (pref_name,type_id,def_value,short_desc,section_id) values('HIDE_READ_FEEDS', 1, 'false', 'Hide feeds with no unread messages',2);
+
 update ttrss_version set schema_version = 4;
 
 commit;
index 85c4564dffe93f6393a26db5db9c5c9cc23f306f..36aec2bae76cd617a45070635365e2fe9c1454ce 100644 (file)
--- a/tt-rss.js
+++ b/tt-rss.js
@@ -72,6 +72,31 @@ function dlg_display_callback() {
        } 
 }
 
+function hide_unread_callback() {
+       if (xmlhttp.readyState == 4) {
+
+               try {
+
+                       var reply = xmlhttp.responseXML.firstChild.firstChild;
+                       var value = reply.getAttribute("value");
+                       var hide_read_feeds = (value != "false")
+                       var feeds_doc = window.frames["feeds-frame"].document;
+       
+                       hideOrShowFeeds(feeds_doc, hide_read_feeds);
+       
+                       if (hide_read_feeds) {
+                               setCookie("ttrss_vf_hreadf", 1);
+                       } else {
+                               setCookie("ttrss_vf_hreadf", 0);
+                       } 
+
+               } catch (e) {
+                       exception_error("hide_unread_callback", e);
+               }
+
+       } 
+}
+
 function refetch_callback() {
        if (xmlhttp.readyState == 4) {
                try {
@@ -504,6 +529,11 @@ function qaddFilter() {
 
 function displayDlg(id, param) {
 
+       if (!xmlhttp_ready(xmlhttp)) {
+               printLockingError();
+               return
+       }
+
        notify("");
 
        xmlhttp.open("GET", "backend.php?op=dlg&id=" +
@@ -524,6 +554,11 @@ function qfdDelete(feed_id) {
 
        notify("Removing feed...");
 
+       if (!xmlhttp_ready(xmlhttp)) {
+               printLockingError();
+               return
+       }
+
 //     var feeds_doc = window.frames["feeds-frame"].document;
 //     feeds_doc.location.href = "backend.php?op=error&msg=Loading,%20please wait...";
 
@@ -563,19 +598,26 @@ function updateFeedTitle(t) {
 }
 
 function toggleDispRead() {
-       var hide_read_feeds = (getCookie("ttrss_vf_hreadf") == 1);
+       try {
 
-       hide_read_feeds = !hide_read_feeds;
+               if (!xmlhttp_ready(xmlhttp)) {
+                       printLockingError();
+                       return
+               }
 
-       var feeds_doc = window.frames["feeds-frame"].document;
+               var hide_read_feeds = (getCookie("ttrss_vf_hreadf") == 1);
 
-       hideOrShowFeeds(feeds_doc, hide_read_feeds);
+               hide_read_feeds = !hide_read_feeds;
+       
+               var query = "backend.php?op=rpc&subop=setpref" +
+                       "&key=HIDE_READ_FEEDS&value=" + param_escape(hide_read_feeds);
 
-       if (hide_read_feeds) {
-               setCookie("ttrss_vf_hreadf", 1);
-       } else {
-               setCookie("ttrss_vf_hreadf", 0);
+               xmlhttp.open("GET", query);
+               xmlhttp.onreadystatechange=hide_unread_callback;
+               xmlhttp.send(null);
+               
+       } catch (e) {
+               exception_error("toggleDispRead", e);
        }
-
 }