summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Dolgov <[email protected]>2007-08-26 05:13:50 +0100
committerAndrew Dolgov <[email protected]>2007-08-26 05:13:50 +0100
commitd1f0c58498dbe91ebdaa59565abc1f2c1e076ad6 (patch)
treeeff3b65db994106741a87fab6cf76492f29317ec
parentbc0f07856012aa94eaea7c409e720d73f2fba0c3 (diff)
new feed action: clear articles
-rw-r--r--functions.php8
-rw-r--r--localized_js.php4
-rw-r--r--modules/pref-feeds.php5
-rw-r--r--tt-rss.js39
-rw-r--r--tt-rss.php1
5 files changed, 55 insertions, 2 deletions
diff --git a/functions.php b/functions.php
index c321f9b4f..cf5d421c9 100644
--- a/functions.php
+++ b/functions.php
@@ -4696,4 +4696,12 @@
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");
+ }
+
?>
diff --git a/localized_js.php b/localized_js.php
index 1f2c7c171..f4840bf6f 100644
--- a/localized_js.php
+++ b/localized_js.php
@@ -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(
diff --git a/modules/pref-feeds.php b/modules/pref-feeds.php
index f0081a097..25cbf707a 100644
--- a/modules/pref-feeds.php
+++ b/modules/pref-feeds.php
@@ -451,6 +451,11 @@
}
}
+ if ($subop == "clear") {
+ $id = db_escape_string($_GET["id"]);
+ clear_feed_articles($link, $id);
+ }
+
if ($subop == "add") {
if (!WEB_DEMO_MODE) {
diff --git a/tt-rss.js b/tt-rss.js
index 92fa161b1..54e069e78 100644
--- 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;
diff --git a/tt-rss.php b/tt-rss.php
index 69e9c7e8d..01765c517 100644
--- a/tt-rss.php
+++ b/tt-rss.php
@@ -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>