}
}
- function catchup_feed($link, $feed, $cat_view, $owner_uid = false, $max_id = false) {
+ function catchup_feed($link, $feed, $cat_view, $owner_uid = false, $max_id = false, $mode = 'all') {
if (!$owner_uid) $owner_uid = $_SESSION['uid'];
//if (preg_match("/^-?[0-9][0-9]*$/", $feed) != false) {
+ // Todo: all this interval stuff needs some generic generator function
+
+ $date_qpart = "false";
+
+ switch ($mode) {
+ case "1day":
+ if (DB_TYPE == "pgsql") {
+ $date_qpart = "updated < NOW() - INTERVAL '1 day' ";
+ } else {
+ $date_qpart = "updated < DATE_SUB(NOW(), INTERVAL 1 WEEK) ";
+ }
+ break;
+ case "1week":
+ if (DB_TYPE == "pgsql") {
+ $date_qpart = "updated < NOW() - INTERVAL '1 week' ";
+ } else {
+ $date_qpart = "updated < DATE_SUB(NOW(), INTERVAL 1 WEEK) ";
+ }
+ break;
+ case "2weeks":
+ if (DB_TYPE == "pgsql") {
+ $date_qpart = "updated < NOW() - INTERVAL '2 week' ";
+ } else {
+ $date_qpart = "updated < DATE_SUB(NOW(), INTERVAL 2 WEEK) ";
+ }
+ break;
+ default:
+ $date_qpart = "true";
+ }
+
if (is_numeric($feed)) {
if ($cat_view) {
}
db_query($link, "UPDATE ttrss_user_entries
- SET unread = false,last_read = NOW()
- WHERE feed_id IN (SELECT id FROM ttrss_feeds WHERE $cat_qpart)
- AND unread = true
- AND owner_uid = $owner_uid");
+ SET unread = false, last_read = NOW() WHERE ref_id IN
+ (SELECT id FROM
+ (SELECT id FROM ttrss_entries, ttrss_user_entries WHERE ref_id = id
+ AND owner_uid = $owner_uid AND unread = true AND feed_id IN
+ (SELECT id FROM ttrss_feeds WHERE $cat_qpart) AND $date_qpart) as tmp)");
} else if ($feed == -2) {
db_query($link, "UPDATE ttrss_user_entries
SET unread = false,last_read = NOW() WHERE (SELECT COUNT(*)
FROM ttrss_user_labels2 WHERE article_id = ref_id) > 0
- AND unread = true AND owner_uid = $owner_uid");
+ AND unread = true AND $date_qpart AND owner_uid = $owner_uid");
}
} else if ($feed > 0) {
db_query($link, "UPDATE ttrss_user_entries
- SET unread = false,last_read = NOW()
- WHERE feed_id = '$feed'
- AND unread = true
- AND owner_uid = $owner_uid");
+ SET unread = false, last_read = NOW() WHERE ref_id IN
+ (SELECT id FROM
+ (SELECT id FROM ttrss_entries, ttrss_user_entries WHERE ref_id = id
+ AND owner_uid = $owner_uid AND unread = true AND feed_id = $feed AND $date_qpart) as tmp)");
} else if ($feed < 0 && $feed > LABEL_BASE_INDEX) { // special, like starred
if ($feed == -1) {
db_query($link, "UPDATE ttrss_user_entries
- SET unread = false,last_read = NOW()
- WHERE marked = true
- AND unread = true
- AND owner_uid = $owner_uid");
+ SET unread = false, last_read = NOW() WHERE ref_id IN
+ (SELECT id FROM
+ (SELECT id FROM ttrss_entries, ttrss_user_entries WHERE ref_id = id
+ AND owner_uid = $owner_uid AND unread = true AND marked = true AND $date_qpart) as tmp)");
}
if ($feed == -2) {
db_query($link, "UPDATE ttrss_user_entries
- SET unread = false,last_read = NOW()
- WHERE published = true
- AND unread = true
- AND owner_uid = $owner_uid");
+ SET unread = false, last_read = NOW() WHERE ref_id IN
+ (SELECT id FROM
+ (SELECT id FROM ttrss_entries, ttrss_user_entries WHERE ref_id = id
+ AND owner_uid = $owner_uid AND unread = true AND published = true AND $date_qpart) as tmp)");
}
if ($feed == -3) {
INTERVAL $intl HOUR) ";
}
- $result = db_query($link, "SELECT id FROM ttrss_entries,
- ttrss_user_entries WHERE $match_part AND
- unread = true AND
- ttrss_user_entries.ref_id = ttrss_entries.id AND
- owner_uid = $owner_uid");
-
- $affected_ids = array();
-
- while ($line = db_fetch_assoc($result)) {
- array_push($affected_ids, $line["id"]);
- }
-
- catchupArticlesById($link, $affected_ids, 0);
+ db_query($link, "UPDATE ttrss_user_entries
+ SET unread = false, last_read = NOW() WHERE ref_id IN
+ (SELECT id FROM
+ (SELECT id FROM ttrss_entries, ttrss_user_entries WHERE ref_id = id
+ AND owner_uid = $owner_uid AND unread = true AND feed_id = $feed AND $date_qpart AND $match_part) as tmp)");
}
if ($feed == -4) {
db_query($link, "UPDATE ttrss_user_entries
- SET unread = false,last_read = NOW()
- WHERE unread = true AND
- owner_uid = $owner_uid");
+ SET unread = false, last_read = NOW() WHERE ref_id IN
+ (SELECT id FROM
+ (SELECT id FROM ttrss_entries, ttrss_user_entries WHERE ref_id = id
+ AND owner_uid = $owner_uid AND unread = true AND $date_qpart) as tmp)");
}
} else if ($feed < LABEL_BASE_INDEX) { // label
$label_id = feed_to_label_id($feed);
- db_query($link, "UPDATE ttrss_user_entries, ttrss_user_labels2
- SET unread = false, last_read = NOW()
- WHERE label_id = '$label_id' AND unread = true
- AND owner_uid = '$owner_uid' AND ref_id = article_id");
+ db_query($link, "UPDATE ttrss_user_entries
+ SET unread = false, last_read = NOW() WHERE ref_id IN
+ (SELECT id FROM
+ (SELECT ttrss_entries.id FROM ttrss_entries, ttrss_user_entries, ttrss_user_labels2 WHERE ref_id = id
+ AND label_id = '$label_id' AND ref_id = article_id
+ AND owner_uid = $owner_uid AND unread = true AND $date_qpart) as tmp)");
}
ccache_update($link, $feed, $owner_uid, $cat_view);
} else { // tag
- db_query($link, "BEGIN");
+ db_query($link, "UPDATE ttrss_user_entries
+ SET unread = false, last_read = NOW() WHERE ref_id IN
+ (SELECT id FROM
+ (SELECT ttrss_entries.id FROM ttrss_entries, ttrss_user_entries, ttrss_tags WHERE ref_id = ttrss_entries.id
+ AND post_int_id = int_id AND tag_name = '$feed'
+ AND ttrss_user_entries.owner_uid = $owner_uid AND unread = true AND $date_qpart) as tmp)");
- $tag_name = db_escape_string($link, $feed);
-
- $result = db_query($link, "SELECT post_int_id FROM ttrss_tags
- WHERE tag_name = '$tag_name' AND owner_uid = $owner_uid");
-
- while ($line = db_fetch_assoc($result)) {
- db_query($link, "UPDATE ttrss_user_entries SET
- unread = false, last_read = NOW()
- WHERE unread = true
- AND int_id = " . $line["post_int_id"]);
- }
- db_query($link, "COMMIT");
}
}
}
}
-function catchupCurrentFeed() {
- return catchupFeed(getActiveFeedId(), activeFeedIsCat());
+function catchupCurrentFeed(elem) {
+
+ if (elem) {
+ var toolbar = document.forms["main_toolbar_form"];
+ var catchup_feed = dijit.getEnclosingWidget(toolbar.catchup_feed);
+ var mode = catchup_feed.attr('value');
+
+ if (mode != 'default') {
+ catchupFeed(getActiveFeedId(), activeFeedIsCat(), mode);
+ catchup_feed.attr('value', 'default');
+ }
+ } else {
+ catchupFeed(getActiveFeedId(), activeFeedIsCat());
+ }
}
function catchupFeedInGroup(id) {
}
}
-function catchupFeed(feed, is_cat) {
+function catchupFeed(feed, is_cat, mode) {
try {
if (is_cat == undefined) is_cat = false;
- var str = __("Mark all articles in %s as read?");
+ var str = false;
+
+ switch (mode) {
+ case "1day":
+ str = __("Mark all articles in %s older than 1 day as read?");
+ break;
+ case "1week":
+ str = __("Mark all articles in %s older than 1 week as read?");
+ break;
+ case "2weeks":
+ str = __("Mark all articles in %s older than 2 weeks as read?");
+ break;
+ default:
+ str = __("Mark all articles in %s as read?");
+ }
+
var fn = getFeedName(feed, is_cat);
str = str.replace("%s", fn);
}
var catchup_query = "?op=rpc&method=catchupFeed&feed_id=" +
- feed + "&is_cat=" + is_cat;
+ feed + "&is_cat=" + is_cat + "&mode=" + mode;
console.log(catchup_query);
onComplete: function(transport) {
handle_rpc_json(transport);
- if (feed == getActiveFeedId() && is_cat == activeFeedIsCat()) {
-
- $$("#headlines-frame > div[id*=RROW][class*=Unread]").each(
- function(child) {
- child.removeClassName("Unread");
- }
- );
- }
-
var show_next_feed = getInitParam("on_catchup_show_next_feed") == "1";
if (show_next_feed) {
if (nuf) {
viewfeed(nuf, '', is_cat);
}
+ } else {
+ if (feed == getActiveFeedId() && is_cat == activeFeedIsCat()) {
+ viewCurrentFeed();
+ }
}
notify("");