]> git.wh0rd.org - tt-rss.git/commitdiff
block type 5 filters (date)
authorAndrew Dolgov <fox@madoka.volgo-balt.ru>
Fri, 31 Aug 2012 08:54:37 +0000 (12:54 +0400)
committerAndrew Dolgov <fox@madoka.volgo-balt.ru>
Fri, 31 Aug 2012 08:54:37 +0000 (12:54 +0400)
classes/pref/filters.php
update.php

index 664c26f6d523ec8ee236482cce0ca25319633067..04077e52f6ca9d12c43a7cfcfb8350f3c0141241 100644 (file)
@@ -109,13 +109,32 @@ class Pref_Filters extends Handler_Protected {
                $result = db_query($this->link, "SELECT *,
                        (SELECT action_id FROM ttrss_filters2_actions
                                WHERE filter_id = ttrss_filters2.id ORDER BY id LIMIT 1) AS action_id,
+                       (SELECT description FROM ttrss_filter_actions
+                               WHERE id = (SELECT action_id FROM ttrss_filters2_actions
+                                       WHERE filter_id = ttrss_filters2.id ORDER BY id LIMIT 1)) AS action_name,
                        (SELECT reg_exp FROM ttrss_filters2_rules
                                WHERE filter_id = ttrss_filters2.id ORDER BY id LIMIT 1) AS reg_exp
                        FROM ttrss_filters2 WHERE
                        owner_uid = ".$_SESSION["uid"]." ORDER BY action_id,reg_exp");
 
+               $action_id = -1;
+               $folder = array();
+               $folder['items'] = array();
+
                while ($line = db_fetch_assoc($result)) {
 
+                       if ($action_id != $line["action_id"]) {
+                               if (count($folder['items']) > 0) {
+                                       $folder['id'] = $line["action_id"];
+                                       $folder['name'] = $line["action_name"];
+
+                                       array_push($root['items'], $folder);
+                               }
+                               $folder = array();
+                               $folder['items'] = array();
+                               $action_id = $line["action_id"];
+                       }
+
                        $name = $this->getFilterName($line["id"]);
 
                        $filter = array();
@@ -126,7 +145,7 @@ class Pref_Filters extends Handler_Protected {
                        $filter['checkbox'] = false;
                        $filter['enabled'] = sql_bool_to_bool($line["enabled"]);
 
-                       array_push($root['items'], $filter);
+                       array_push($folder['items'], $filter);
                }
 
                $fl = array();
@@ -466,17 +485,6 @@ class Pref_Filters extends Handler_Protected {
                        $sort = "reg_exp";
                }
 
-               $result = db_query($this->link, "SELECT id,description
-                       FROM ttrss_filter_types ORDER BY description");
-
-               $filter_types = array();
-
-               while ($line = db_fetch_assoc($result)) {
-                       //array_push($filter_types, $line["description"]);
-                       $filter_types[$line["id"]] = $line["description"];
-               }
-
-
                $filter_search = db_escape_string($_REQUEST["search"]);
 
                if (array_key_exists("search", $_REQUEST)) {
@@ -684,7 +692,7 @@ class Pref_Filters extends Handler_Protected {
                print "<form name='filter_new_rule_form' id='filter_new_rule_form'>";
 
                $result = db_query($this->link, "SELECT id,description
-                       FROM ttrss_filter_types ORDER BY description");
+                       FROM ttrss_filter_types WHERE id != 5 ORDER BY description");
 
                $filter_types = array();
 
index e8ef8bc99898a9bf61287b5052373f60e1d2928c..0bc1090e886a8e54a8d21216aa5810cf3db68f6c 100755 (executable)
                while ($line = db_fetch_assoc($result)) {
                        $owner_uid = $line["owner_uid"];
 
-                       $filter = array();
-
-                       if (sql_bool_to_bool($line["cat_filter"])) {
-                               $feed_id = "CAT:" . (int)$line["cat_id"];
-                       } else {
-                               $feed_id = (int)$line["feed_id"];
-                       }
-
-                       $filter["enabled"] = $line["enabled"] ? "on" : "off";
-                       $filter["rule"] = array(
-                               json_encode(array(
-                                       "reg_exp" => $line["reg_exp"],
-                                       "feed_id" => $feed_id,
-                                       "filter_type" => $line["filter_type"])));
+                       // date filters are removed
+                       if ($line["filter_type"] != 5) {
+                               $filter = array();
+
+                               if (sql_bool_to_bool($line["cat_filter"])) {
+                                       $feed_id = "CAT:" . (int)$line["cat_id"];
+                               } else {
+                                       $feed_id = (int)$line["feed_id"];
+                               }
 
-                       $filter["action"] = array(
-                               json_encode(array(
-                                       "action_id" => $line["action_id"],
-                                       "action_param_label" => $line["action_param"],
-                                       "action_param" => $line["action_param"])));
+                               $filter["enabled"] = $line["enabled"] ? "on" : "off";
+                               $filter["rule"] = array(
+                                       json_encode(array(
+                                               "reg_exp" => $line["reg_exp"],
+                                               "feed_id" => $feed_id,
+                                               "filter_type" => $line["filter_type"])));
 
-                       // Oh god it's full of hacks
+                               $filter["action"] = array(
+                                       json_encode(array(
+                                               "action_id" => $line["action_id"],
+                                               "action_param_label" => $line["action_param"],
+                                               "action_param" => $line["action_param"])));
 
-##                     print_r($filter);
+                               // Oh god it's full of hacks
 
-                       $_REQUEST = $filter;
-                       $_SESSION["uid"] = $owner_uid;
+                               $_REQUEST = $filter;
+                               $_SESSION["uid"] = $owner_uid;
 
-                       $filters = new Pref_Filters($link, $_REQUEST);
-                       $filters->add();
+                               $filters = new Pref_Filters($link, $_REQUEST);
+                               $filters->add();
+                       }
                }
 
        }