]> git.wh0rd.org Git - tt-rss.git/commitdiff
allow filters to work on child categories
authorAndrew Dolgov <fox@madoka.volgo-balt.ru>
Tue, 9 Oct 2012 15:09:50 +0000 (19:09 +0400)
committerAndrew Dolgov <fox@madoka.volgo-balt.ru>
Tue, 9 Oct 2012 15:09:50 +0000 (19:09 +0400)
include/functions.php
include/rssfuncs.php

index 343de9ad78754c8e590ce08cb701fb932ad2a492..0231c52de87920b7c99113e5ff96266a3a38df2b 100644 (file)
                return $search_query_part;
        }
 
+       function getParentCategories($link, $cat, $owner_uid) {
+               $rv = array();
+
+               $result = db_query($link, "SELECT parent_cat FROM ttrss_feed_categories
+                       WHERE id = '$cat' AND parent_cat IS NOT NULL AND owner_uid = $owner_uid");
+
+               while ($line = db_fetch_assoc($result)) {
+                       array_push($rv, $line["parent_cat"]);
+                       $rv = array_merge($rv, getParentCategories($link, $line["parent_cat"], $owner_uid));
+               }
+
+               return $rv;
+       }
+
        function getChildCategories($link, $cat, $owner_uid) {
                $rv = array();
 
                $result = db_query($link, "SELECT * FROM ttrss_filters2 WHERE
                        owner_uid = $owner_uid AND enabled = true");
 
+               $check_cats = join(",", array_merge(
+                       getParentCategories($link, $cat_id, $owner_uid),
+                       array($cat_id)));
+
                while ($line = db_fetch_assoc($result)) {
                        $filter_id = $line["id"];
 
                                FROM ttrss_filters2_rules AS r,
                                ttrss_filter_types AS t
                                WHERE
-                                       (cat_id IS NULL OR cat_id = '$cat_id') AND
+                                       (cat_id IS NULL OR cat_id IN ($check_cats)) AND
                                        (feed_id IS NULL OR feed_id = '$feed_id') AND
                                        filter_type = t.id AND filter_id = '$filter_id'");
 
index 011fbd472127f0d48d2daa104e355ef7e251881c..09fd457b6079daa4ce8efa01cb12baf73a2dcd97 100644 (file)
 
                        $filters = load_filters($link, $feed, $owner_uid);
 
-//                     if ($debug_enabled) {
-//                             print_r($filters);
-//                     }
+                       if ($debug_enabled) {
+                               //print_r($filters);
+                               _debug("update_rss_feed: " . count($filters) . " filters loaded.");
+                       }
 
                        if ($use_simplepie) {
                                $iterator = $rss->get_items();