]> git.wh0rd.org Git - tt-rss.git/commitdiff
new feed action: clear articles
authorAndrew Dolgov <fox@bah.spb.su>
Sun, 26 Aug 2007 04:13:50 +0000 (05:13 +0100)
committerAndrew Dolgov <fox@bah.spb.su>
Sun, 26 Aug 2007 04:13:50 +0000 (05:13 +0100)
functions.php
localized_js.php
modules/pref-feeds.php
tt-rss.js
tt-rss.php

index c321f9b4fd10e2ae397d66acdf69f21d135c8c3d..cf5d421c9ccd074f1a9e00e247256a03388675ca 100644 (file)
                return $url_path;
        }
 
+       function clear_feed_articles($link, $id) {
+               $result = db_query($link, "DELETE FROM ttrss_user_entries
+                       WHERE feed_id = '$id' AND marked = false");
+
+               $result = db_query($link, "DELETE FROM ttrss_entries WHERE 
+                       (SELECT COUNT(int_id) FROM ttrss_user_entries WHERE ref_id = id) = 0");
+       }
+
 ?>
index 1f2c7c1710c8aa42904ef5f98846d9c559ca91a4..f4840bf6f99ee09aab130bdd2913b46f5d6616ca 100644 (file)
@@ -124,8 +124,8 @@ print T_js_decl("Unstar article");
 print T_js_decl("Please wait...");
 print T_js_decl("Publish article");
 print T_js_decl("Unpublish article");
-#print T_js_decl(
-#print T_js_decl(
+print T_js_decl("You can't clear this type of feed.");
+print T_js_decl("Remove all (except starred) stored articles for %s?");
 #print T_js_decl(
 #print T_js_decl(
 #print T_js_decl(
index f0081a097d7aac83da2e067e096b5416a30f84aa..25cbf707a8ec5945b8ad1b295b3890e89ff290c4 100644 (file)
                        }
                }
 
+               if ($subop == "clear") {
+                       $id = db_escape_string($_GET["id"]);
+                       clear_feed_articles($link, $id);
+               }
+
                if ($subop == "add") {
                
                        if (!WEB_DEMO_MODE) {
index 92fa161b1058088aae029dddf4511b30beecc4ab..54e069e786054a9e8fbcc7528eceadfccf5cdd54 100644 (file)
--- a/tt-rss.js
+++ b/tt-rss.js
@@ -460,7 +460,32 @@ function quickMenuGo(opid) {
                
                        return;
                }
+
+               if (opid == "qmcClearFeed") {
+                       var actid = getActiveFeedId();
+
+                       if (!actid) {
+                               alert(__("Please select some feed first."));
+                               return;
+                       }
+
+                       if (activeFeedIsCat() || actid < 0) {
+                               alert(__("You can't clear this type of feed."));
+                               return;
+                       }       
+
+                       var fn = getFeedName(actid);
+
+                       var pr = __("Remove all (except starred) stored articles for %s?").replace("%s", fn);
+
+                       if (confirm(pr)) {
+                               clearFeedArticles(actid);
+                       }
+               
+                       return;
+               }
        
+
                if (opid == "qmcUpdateFeeds") {
                        scheduleFeedUpdate(true);
                        return;
@@ -500,6 +525,20 @@ function qfdDelete(feed_id) {
        return false;
 }
 
+function clearFeedArticles(feed_id) {
+
+       notify_progress("Clearing feed...");
+
+       var query = "backend.php?op=pref-feeds&quiet=1&subop=clear&id=" + feed_id;
+
+       new Ajax.Request(query, {
+               onComplete: function(transport) {
+                               dlg_frefresh_callback(transport, feed_id);
+                       } });
+
+       return false;
+}
+
 
 function updateFeedTitle(t) {
        active_title_text = t;
index 69e9c7e8d02b58febc219c2714aab85767fafc01..01765c5177139e8beeef6d70f6a8bc67894bd760 100644 (file)
@@ -134,6 +134,7 @@ window.onload = init;
                                        <option style="color : #5050aa" disabled><?php echo __('Feed actions:') ?></option>
                                        <option value="qmcAddFeed"><?php echo __('&nbsp;&nbsp;Subscribe to feed') ?></option>
                                        <option value="qmcEditFeed"><?php echo __('&nbsp;&nbsp;Edit this feed') ?></option>
+                                       <option value="qmcClearFeed"><?php echo __('&nbsp;&nbsp;Clear articles') ?></option>
                                        <option value="qmcRemoveFeed"><?php echo __('&nbsp;&nbsp;Unsubscribe') ?></option>
                                        <!-- <option>Edit this feed</option> -->
                                        <option disabled>--------</option>