]> git.wh0rd.org Git - tt-rss.git/commitdiff
add archive_article()
authorAndrew Dolgov <fox@bah.org.ru>
Mon, 28 Dec 2009 16:30:34 +0000 (19:30 +0300)
committerAndrew Dolgov <fox@bah.org.ru>
Mon, 28 Dec 2009 16:30:34 +0000 (19:30 +0300)
functions.php
modules/backend-rpc.php

index 8650ceb9ca1693e9c0dd44cc166088bd8df454d7..e8682ca3746e6f06c18db83bd0019bc1ac6544cd 100644 (file)
                ccache_remove($link, $id, $owner_uid, true);
        }
 
+       function archive_article($link, $id, $owner_uid) {
+               db_query($link, "BEGIN");
+
+               $result = db_query($link, "SELECT feed_id FROM ttrss_user_entries
+                       WHERE ref_id = '$id' AND owner_uid = $owner_uid");
+
+               if (db_num_rows($result) != 0) {
+
+                       /* prepare the archived table */
+
+                       $feed_id = (int) db_fetch_result($result, 0, "feed_id");
+
+                       if ($feed_id) {
+                               $result = db_query($link, "SELECT id FROM ttrss_archived_feeds
+                                       WHERE id = '$feed_id'");
+
+                               if (db_num_rows($result) == 0) {
+                                       db_query($link, "INSERT INTO ttrss_archived_feeds 
+                                               (id, owner_uid, title, feed_url, site_url)
+                                       SELECT id, owner_uid, title, feed_url, site_url from ttrss_feeds
+                                       WHERE id = '$feed_id'");
+                               }
+
+                               db_query($link, "UPDATE ttrss_user_entries 
+                                       SET orig_feed_id = feed_id, feed_id = NULL
+                                       WHERE ref_id = '$id' AND owner_uid = " . $_SESSION["uid"]);
+                       }
+               }
+
+               db_query($link, "COMMIT");
+       }
 ?>
index 326c669fbb08129eed13dab087c630c44efaa3bc..7374241ca7c4cea339239017fb081b0562a55015 100644 (file)
                }
 
                if ($subop == "archive") {
-                       $ids = db_escape_string($_GET["ids"]);
+                       $ids = split(",", db_escape_string($_GET["ids"]));
 
-                       $result = db_query($link, "UPDATE ttrss_user_entries 
-                               SET orig_feed_id = feed_id, feed_id = NULL, marked = true
-                               WHERE ref_id IN ($ids) AND owner_uid = " . $_SESSION["uid"]);
+                       foreach ($ids as $id) {
+                               archive_article($link, $id, $_SESSION["uid"]);
+                       }
 
                        print "<rpc-reply><counters>";
                        getGlobalCounters($link);