]> git.wh0rd.org Git - tt-rss.git/commitdiff
disable depending filters when removing label
authorAndrew Dolgov <fox@bah.spb.su>
Sun, 18 Jan 2009 10:11:55 +0000 (11:11 +0100)
committerAndrew Dolgov <fox@bah.spb.su>
Sun, 18 Jan 2009 10:11:55 +0000 (11:11 +0100)
modules/pref-labels.php

index 3690464e79a39b61fca7bbf4f563d45e588e9bd5..6f284e942805a1169456930de7986a3ec32cc3de 100644 (file)
 
                        $ids = split(",", db_escape_string($_GET["ids"]));
 
-                               foreach ($ids as $id) {
-                                       db_query($link, "DELETE FROM ttrss_labels2 WHERE id = '$id'
-                                               AND owner_uid = " . $_SESSION["uid"]);
+                       db_query($link, "BEGIN");
+
+                       foreach ($ids as $id) {
+                               $result = db_query($link, "SELECT caption FROM ttrss_labels2
+                                       WHERE id = '$id'");
+
+                               $caption = db_fetch_result($result, 0, "caption");
+
+                               $result = db_query($link, "DELETE FROM ttrss_labels2 WHERE id = '$id'
+                                       AND owner_uid = " . $_SESSION["uid"]);
+
+                               if (db_affected_rows($link, $result) != 0 && $caption) {
+
+                                               /* Disable filters that reference label being removed */
+
+                                               db_query($link, "UPDATE ttrss_filters SET
+                                                       enabled = false WHERE action_param = '$caption'
+                                                       AND action_id = 7
+                                                       AND owner_uid = " . $_SESSION["uid"]);
+                               }
                        }
+
+                       db_query($link, "COMMIT");
+
                }
 
                if ($subop == "add") {