]> git.wh0rd.org Git - tt-rss.git/commitdiff
add remove_feed() and remove_feed_category()
authorAndrew Dolgov <fox@bah.org.ru>
Mon, 28 Dec 2009 09:04:21 +0000 (12:04 +0300)
committerAndrew Dolgov <fox@bah.org.ru>
Mon, 28 Dec 2009 09:04:21 +0000 (12:04 +0300)
functions.php
modules/pref-feeds.php

index 0c23e7ec788f7c4c58dbba4ae0ac3f2532b0b9c7..02521b313508035eb07118e4154ecba1595424a0 100644 (file)
                        }
                }
        }
+
+       function remove_feed($link, $id, $owner_uid) {
+
+               if ($id > 0) {
+                       db_query($link, "DELETE FROM ttrss_feeds 
+                                       WHERE id = '$id' AND owner_uid = $owner_uid");
+
+                       if (file_exists(ICONS_DIR . "/$id.ico")) {
+                               unlink(ICONS_DIR . "/$id.ico");
+                       }
+
+                       ccache_remove($link, $id, $owner_uid);
+
+               } else {
+                       label_remove($link, -11-$id, $owner_uid);
+                       ccache_remove($link, -11-$id, $owner_uid);
+               }
+       }
+
+       function remove_feed_category($link, $id, $owner_uid) {
+
+               db_query($link, "DELETE FROM ttrss_feed_categories
+                       WHERE id = '$id' AND owner_uid = $owner_uid");
+
+               ccache_remove($link, $id, $owner_uid, true);
+       }
+
 ?>
index e8c6d878395425632ee353dad2203fef3af5eda8..73fbe807934be270e1c45ef99191f3c84047d503 100644 (file)
                        $ids = split(",", db_escape_string($_GET["ids"]));
 
                        foreach ($ids as $id) {
-
-                               if ($id > 0) {
-
-                                       db_query($link, "DELETE FROM ttrss_feeds 
-                                               WHERE id = '$id' AND owner_uid = " . $_SESSION["uid"]);
-
-                                       $icons_dir = ICONS_DIR;
-                                       
-                                       if (file_exists($icons_dir . "/$id.ico")) {
-                                               unlink($icons_dir . "/$id.ico");
-                                       }
-
-                                       ccache_remove($link, $id, $_SESSION["uid"]);
-
-                               } else {
-                                       label_remove($link, -11-$id, $_SESSION["uid"]);
-                                       ccache_remove($link, -11-$id, $_SESSION["uid"]);
-                               }
+                               remove_feed($link, $id, $_SESSION["uid"]);
                        }
                }
 
 
                        if ($action == "remove") {
        
-                               if (!WEB_DEMO_MODE) {
-       
-                                       $ids = split(",", db_escape_string($_GET["ids"]));
-       
-                                       foreach ($ids as $id) {
-       
-                                               db_query($link, "BEGIN");
-       
-                                               $result = db_query($link, 
-                                                       "SELECT count(id) as num_feeds FROM ttrss_feeds 
-                                                               WHERE cat_id = '$id'");
-       
-                                               $num_feeds = db_fetch_result($result, 0, "num_feeds");
-       
-                                               if ($num_feeds == 0) {
-                                                       db_query($link, "DELETE FROM ttrss_feed_categories
-                                                               WHERE id = '$id' AND owner_uid = " . $_SESSION["uid"]);
-
-                                                       ccache_remove($link, $id, $_SESSION["uid"], true);
-
-                                               } else {
-       
-                                                       print format_warning(__("Unable to delete non empty feed categories."));
-                                                               
-                                               }
+                               $ids = split(",", db_escape_string($_GET["ids"]));
        
-                                               db_query($link, "COMMIT");
-                                       }
+                               foreach ($ids as $id) {
+                                       remove_feed_category($link, $id, $_SESSION["uid"]);
                                }
                        }