]> git.wh0rd.org Git - tt-rss.git/commitdiff
support for adding filters
authorAndrew Dolgov <fox@bah.spb.su>
Sat, 3 Sep 2005 07:34:31 +0000 (08:34 +0100)
committerAndrew Dolgov <fox@bah.spb.su>
Sat, 3 Sep 2005 07:34:31 +0000 (08:34 +0100)
backend.php
prefs.js

index 9c0b5c8b0ded9d61507ee9a13ad80984447e61f0..3b07bd38de79eed01131b9796856a1c73002ccb4 100644 (file)
 
                if ($subop == "add") {
                
-/*                     if (!WEB_DEMO_MODE) {
+                       if (!WEB_DEMO_MODE) {
 
-                               $feed_link = pg_escape_string($_GET["link"]);
+                               $regexp = pg_escape_string($_GET["regexp"]);
+                               $match = pg_escape_string($_GET["match"]);
                                        
                                $result = pg_query(
-                                       "INSERT INTO ttrss_feeds (feed_url,title) VALUES ('$feed_link', '')");
-
-                               $result = pg_query(
-                                       "SELECT id FROM ttrss_feeds WHERE feed_url = '$feed_link'");
-
-                               $feed_id = pg_fetch_result($result, 0, "id");
-
-                               if ($feed_id) {
-                                       update_rss_feed($link, $feed_link, $feed_id);
-                               }
-                       } */
+                                       "INSERT INTO ttrss_filters (regexp,filter_type) VALUES 
+                                               ('$regexp', (SELECT id FROM ttrss_filter_types WHERE
+                                                       description = '$match'))");
+                       } 
                }
 
                $result = pg_query("SELECT description 
index a498bb2e32148c18f66ec829504a5515f4ee66ae..e55f7d4f45d12f2995682fc5a4673d7cb9d1fe23 100644 (file)
--- a/prefs.js
+++ b/prefs.js
@@ -106,6 +106,31 @@ function toggleSelectRow(sender) {
        }
 }
 
+function addFilter() {
+
+       if (!xmlhttp_ready(xmlhttp)) {
+               printLockingError();
+               return
+       }
+
+       var regexp = document.getElementById("fadd_regexp");
+       var match = document.getElementById("fadd_match");
+
+       if (regexp.value.length == 0) {
+               notify("Missing filter expression.");
+       } else {
+               notify("Adding filter...");
+
+               xmlhttp.open("GET", "backend.php?op=pref-filters&subop=add&regexp=" +
+                       param_escape(regexp.value) + "&match=" + match.value, true);                    
+                       
+               xmlhttp.onreadystatechange=filterlist_callback;
+               xmlhttp.send(null);
+
+               regexp.value = "";
+       }
+
+}
 function addFeed() {
 
        if (!xmlhttp_ready(xmlhttp)) {