summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorAndrew Dolgov <[email protected]>2012-10-09 19:09:50 +0400
committerAndrew Dolgov <[email protected]>2012-10-09 19:09:50 +0400
commit67bd0b1f26707945cd086e5a86e0f7a7c2d6e0bf (patch)
tree0e3f9288ebe392fbda99feebf91b5bfed5157af4 /include
parentbed44d5164637b4c443db5e2910ee37e48652c0f (diff)
allow filters to work on child categories
Diffstat (limited to 'include')
-rw-r--r--include/functions.php20
-rw-r--r--include/rssfuncs.php7
2 files changed, 23 insertions, 4 deletions
diff --git a/include/functions.php b/include/functions.php
index 343de9ad7..0231c52de 100644
--- a/include/functions.php
+++ b/include/functions.php
@@ -2262,6 +2262,20 @@
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();
@@ -3635,6 +3649,10 @@
$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"];
@@ -3643,7 +3661,7 @@
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'");
diff --git a/include/rssfuncs.php b/include/rssfuncs.php
index 011fbd472..09fd457b6 100644
--- a/include/rssfuncs.php
+++ b/include/rssfuncs.php
@@ -410,9 +410,10 @@
$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();