From f6f7817d9d275c4e7fc344758c0ca0ffbf925884 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Sun, 18 Jan 2009 11:11:55 +0100 Subject: [PATCH] disable depending filters when removing label --- modules/pref-labels.php | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/modules/pref-labels.php b/modules/pref-labels.php index 3690464e..6f284e94 100644 --- a/modules/pref-labels.php +++ b/modules/pref-labels.php @@ -48,10 +48,30 @@ $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") { -- 2.39.5