filter by search results while marking feed as read
This commit is contained in:
parent
86e534290e
commit
337535416f
5 changed files with 127 additions and 120 deletions
|
@ -300,6 +300,7 @@ class Feeds extends Handler_Protected {
|
||||||
make_local_datetime($qfh_ret[4], false) : __("Never");
|
make_local_datetime($qfh_ret[4], false) : __("Never");
|
||||||
$highlight_words = $qfh_ret[5];
|
$highlight_words = $qfh_ret[5];
|
||||||
$reply['first_id'] = $qfh_ret[6];
|
$reply['first_id'] = $qfh_ret[6];
|
||||||
|
$reply['search_query'] = [$search, $search_language];
|
||||||
|
|
||||||
$vgroup_last_feed = $vgr_last_feed;
|
$vgroup_last_feed = $vgr_last_feed;
|
||||||
|
|
||||||
|
|
|
@ -450,8 +450,10 @@ class RPC extends Handler_Protected {
|
||||||
$feed_id = $this->dbh->escape_string($_REQUEST['feed_id']);
|
$feed_id = $this->dbh->escape_string($_REQUEST['feed_id']);
|
||||||
$is_cat = $this->dbh->escape_string($_REQUEST['is_cat']) == "true";
|
$is_cat = $this->dbh->escape_string($_REQUEST['is_cat']) == "true";
|
||||||
$mode = $this->dbh->escape_string($_REQUEST['mode']);
|
$mode = $this->dbh->escape_string($_REQUEST['mode']);
|
||||||
|
$search_query = $this->dbh->escape_string($_REQUEST['search_query']);
|
||||||
|
$search_lang = $this->dbh->escape_string($_REQUEST['search_lang']);
|
||||||
|
|
||||||
catchup_feed($feed_id, $is_cat, false, false, $mode);
|
catchup_feed($feed_id, $is_cat, false, false, $mode, [$search_query, $search_lang]);
|
||||||
|
|
||||||
print json_encode(array("message" => "UPDATE_COUNTERS"));
|
print json_encode(array("message" => "UPDATE_COUNTERS"));
|
||||||
}
|
}
|
||||||
|
|
|
@ -1163,149 +1163,148 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function catchup_feed($feed, $cat_view, $owner_uid = false, $max_id = false, $mode = 'all') {
|
function catchup_feed($feed, $cat_view, $owner_uid = false, $max_id = false, $mode = 'all', $search = false) {
|
||||||
|
|
||||||
if (!$owner_uid) $owner_uid = $_SESSION['uid'];
|
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
|
||||||
|
|
||||||
// Todo: all this interval stuff needs some generic generator function
|
$date_qpart = "false";
|
||||||
|
$search_qpart = is_array($search) && $search[0] ? search_to_sql($search[0], $search[1])[0] : 'true';
|
||||||
|
|
||||||
$date_qpart = "false";
|
switch ($mode) {
|
||||||
|
case "1day":
|
||||||
switch ($mode) {
|
if (DB_TYPE == "pgsql") {
|
||||||
case "1day":
|
$date_qpart = "date_entered < NOW() - INTERVAL '1 day' ";
|
||||||
if (DB_TYPE == "pgsql") {
|
} else {
|
||||||
$date_qpart = "date_entered < NOW() - INTERVAL '1 day' ";
|
$date_qpart = "date_entered < DATE_SUB(NOW(), INTERVAL 1 DAY) ";
|
||||||
} else {
|
|
||||||
$date_qpart = "date_entered < DATE_SUB(NOW(), INTERVAL 1 DAY) ";
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case "1week":
|
|
||||||
if (DB_TYPE == "pgsql") {
|
|
||||||
$date_qpart = "date_entered < NOW() - INTERVAL '1 week' ";
|
|
||||||
} else {
|
|
||||||
$date_qpart = "date_entered < DATE_SUB(NOW(), INTERVAL 1 WEEK) ";
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case "2week":
|
|
||||||
if (DB_TYPE == "pgsql") {
|
|
||||||
$date_qpart = "date_entered < NOW() - INTERVAL '2 week' ";
|
|
||||||
} else {
|
|
||||||
$date_qpart = "date_entered < DATE_SUB(NOW(), INTERVAL 2 WEEK) ";
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
$date_qpart = "true";
|
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
|
case "1week":
|
||||||
|
if (DB_TYPE == "pgsql") {
|
||||||
|
$date_qpart = "date_entered < NOW() - INTERVAL '1 week' ";
|
||||||
|
} else {
|
||||||
|
$date_qpart = "date_entered < DATE_SUB(NOW(), INTERVAL 1 WEEK) ";
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case "2week":
|
||||||
|
if (DB_TYPE == "pgsql") {
|
||||||
|
$date_qpart = "date_entered < NOW() - INTERVAL '2 week' ";
|
||||||
|
} else {
|
||||||
|
$date_qpart = "date_entered < DATE_SUB(NOW(), INTERVAL 2 WEEK) ";
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
$date_qpart = "true";
|
||||||
|
}
|
||||||
|
|
||||||
if (is_numeric($feed)) {
|
if (is_numeric($feed)) {
|
||||||
if ($cat_view) {
|
if ($cat_view) {
|
||||||
|
|
||||||
if ($feed >= 0) {
|
if ($feed >= 0) {
|
||||||
|
|
||||||
if ($feed > 0) {
|
if ($feed > 0) {
|
||||||
$children = getChildCategories($feed, $owner_uid);
|
$children = getChildCategories($feed, $owner_uid);
|
||||||
array_push($children, $feed);
|
array_push($children, $feed);
|
||||||
|
|
||||||
$children = join(",", $children);
|
$children = join(",", $children);
|
||||||
|
|
||||||
$cat_qpart = "cat_id IN ($children)";
|
$cat_qpart = "cat_id IN ($children)";
|
||||||
} else {
|
} else {
|
||||||
$cat_qpart = "cat_id IS NULL";
|
$cat_qpart = "cat_id IS NULL";
|
||||||
}
|
|
||||||
|
|
||||||
db_query("UPDATE ttrss_user_entries
|
|
||||||
SET unread = false, last_read = NOW() WHERE ref_id IN
|
|
||||||
(SELECT id FROM
|
|
||||||
(SELECT DISTINCT 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("UPDATE ttrss_user_entries
|
|
||||||
SET unread = false,last_read = NOW() WHERE (SELECT COUNT(*)
|
|
||||||
FROM ttrss_user_labels2, ttrss_entries WHERE article_id = ref_id AND id = ref_id AND $date_qpart) > 0
|
|
||||||
AND unread = true AND owner_uid = $owner_uid");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if ($feed > 0) {
|
|
||||||
|
|
||||||
db_query("UPDATE ttrss_user_entries
|
db_query("UPDATE ttrss_user_entries
|
||||||
SET unread = false, last_read = NOW() WHERE ref_id IN
|
SET unread = false, last_read = NOW() WHERE ref_id IN
|
||||||
(SELECT id FROM
|
(SELECT id FROM
|
||||||
(SELECT DISTINCT id FROM ttrss_entries, ttrss_user_entries WHERE ref_id = id
|
(SELECT DISTINCT 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)");
|
AND owner_uid = $owner_uid AND unread = true AND feed_id IN
|
||||||
|
(SELECT id FROM ttrss_feeds WHERE $cat_qpart) AND $date_qpart AND $search_qpart) as tmp)");
|
||||||
|
|
||||||
} else if ($feed < 0 && $feed > LABEL_BASE_INDEX) { // special, like starred
|
} else if ($feed == -2) {
|
||||||
|
|
||||||
if ($feed == -1) {
|
db_query("UPDATE ttrss_user_entries
|
||||||
db_query("UPDATE ttrss_user_entries
|
SET unread = false,last_read = NOW() WHERE (SELECT COUNT(*)
|
||||||
SET unread = false, last_read = NOW() WHERE ref_id IN
|
FROM ttrss_user_labels2, ttrss_entries WHERE article_id = ref_id AND id = ref_id AND $date_qpart AND $search_qpart) > 0
|
||||||
(SELECT id FROM
|
AND unread = true AND owner_uid = $owner_uid");
|
||||||
(SELECT DISTINCT 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)");
|
|
||||||
|
} else if ($feed > 0) {
|
||||||
|
|
||||||
|
db_query("UPDATE ttrss_user_entries
|
||||||
|
SET unread = false, last_read = NOW() WHERE ref_id IN
|
||||||
|
(SELECT id FROM
|
||||||
|
(SELECT DISTINCT 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 $search_qpart) as tmp)");
|
||||||
|
|
||||||
|
} else if ($feed < 0 && $feed > LABEL_BASE_INDEX) { // special, like starred
|
||||||
|
|
||||||
|
if ($feed == -1) {
|
||||||
|
db_query("UPDATE ttrss_user_entries
|
||||||
|
SET unread = false, last_read = NOW() WHERE ref_id IN
|
||||||
|
(SELECT id FROM
|
||||||
|
(SELECT DISTINCT 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 AND $search_qpart) as tmp)");
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($feed == -2) {
|
||||||
|
db_query("UPDATE ttrss_user_entries
|
||||||
|
SET unread = false, last_read = NOW() WHERE ref_id IN
|
||||||
|
(SELECT id FROM
|
||||||
|
(SELECT DISTINCT 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 AND $search_qpart) as tmp)");
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($feed == -3) {
|
||||||
|
|
||||||
|
$intl = get_pref("FRESH_ARTICLE_MAX_AGE");
|
||||||
|
|
||||||
|
if (DB_TYPE == "pgsql") {
|
||||||
|
$match_part = "date_entered > NOW() - INTERVAL '$intl hour' ";
|
||||||
|
} else {
|
||||||
|
$match_part = "date_entered > DATE_SUB(NOW(),
|
||||||
|
INTERVAL $intl HOUR) ";
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($feed == -2) {
|
|
||||||
db_query("UPDATE ttrss_user_entries
|
|
||||||
SET unread = false, last_read = NOW() WHERE ref_id IN
|
|
||||||
(SELECT id FROM
|
|
||||||
(SELECT DISTINCT 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) {
|
|
||||||
|
|
||||||
$intl = get_pref("FRESH_ARTICLE_MAX_AGE");
|
|
||||||
|
|
||||||
if (DB_TYPE == "pgsql") {
|
|
||||||
$match_part = "date_entered > NOW() - INTERVAL '$intl hour' ";
|
|
||||||
} else {
|
|
||||||
$match_part = "date_entered > DATE_SUB(NOW(),
|
|
||||||
INTERVAL $intl HOUR) ";
|
|
||||||
}
|
|
||||||
|
|
||||||
db_query("UPDATE ttrss_user_entries
|
|
||||||
SET unread = false, last_read = NOW() WHERE ref_id IN
|
|
||||||
(SELECT id FROM
|
|
||||||
(SELECT DISTINCT id FROM ttrss_entries, ttrss_user_entries WHERE ref_id = id
|
|
||||||
AND owner_uid = $owner_uid AND score >= 0 AND unread = true AND $date_qpart AND $match_part) as tmp)");
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($feed == -4) {
|
|
||||||
db_query("UPDATE ttrss_user_entries
|
|
||||||
SET unread = false, last_read = NOW() WHERE ref_id IN
|
|
||||||
(SELECT id FROM
|
|
||||||
(SELECT DISTINCT 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("UPDATE ttrss_user_entries
|
db_query("UPDATE ttrss_user_entries
|
||||||
SET unread = false, last_read = NOW() WHERE ref_id IN
|
SET unread = false, last_read = NOW() WHERE ref_id IN
|
||||||
(SELECT id FROM
|
(SELECT id FROM
|
||||||
(SELECT DISTINCT ttrss_entries.id FROM ttrss_entries, ttrss_user_entries, ttrss_user_labels2 WHERE ref_id = id
|
(SELECT DISTINCT id FROM ttrss_entries, ttrss_user_entries WHERE ref_id = id
|
||||||
AND label_id = '$label_id' AND ref_id = article_id
|
AND owner_uid = $owner_uid AND score >= 0 AND unread = true AND $date_qpart AND $match_part AND $search_qpart) as tmp)");
|
||||||
AND owner_uid = $owner_uid AND unread = true AND $date_qpart) as tmp)");
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ccache_update($feed, $owner_uid, $cat_view);
|
if ($feed == -4) {
|
||||||
|
db_query("UPDATE ttrss_user_entries
|
||||||
|
SET unread = false, last_read = NOW() WHERE ref_id IN
|
||||||
|
(SELECT id FROM
|
||||||
|
(SELECT DISTINCT id FROM ttrss_entries, ttrss_user_entries WHERE ref_id = id
|
||||||
|
AND owner_uid = $owner_uid AND unread = true AND $date_qpart AND $search_qpart) as tmp)");
|
||||||
|
}
|
||||||
|
|
||||||
|
} else if ($feed < LABEL_BASE_INDEX) { // label
|
||||||
|
|
||||||
|
$label_id = feed_to_label_id($feed);
|
||||||
|
|
||||||
} else { // tag
|
|
||||||
db_query("UPDATE ttrss_user_entries
|
db_query("UPDATE ttrss_user_entries
|
||||||
SET unread = false, last_read = NOW() WHERE ref_id IN
|
SET unread = false, last_read = NOW() WHERE ref_id IN
|
||||||
(SELECT id FROM
|
(SELECT id FROM
|
||||||
(SELECT DISTINCT ttrss_entries.id FROM ttrss_entries, ttrss_user_entries, ttrss_tags WHERE ref_id = ttrss_entries.id
|
(SELECT DISTINCT ttrss_entries.id FROM ttrss_entries, ttrss_user_entries, ttrss_user_labels2 WHERE ref_id = id
|
||||||
AND post_int_id = int_id AND tag_name = '$feed'
|
AND label_id = '$label_id' AND ref_id = article_id
|
||||||
AND ttrss_user_entries.owner_uid = $owner_uid AND unread = true AND $date_qpart) as tmp)");
|
AND owner_uid = $owner_uid AND unread = true AND $date_qpart AND $search_qpart) as tmp)");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ccache_update($feed, $owner_uid, $cat_view);
|
||||||
|
|
||||||
|
} else { // tag
|
||||||
|
db_query("UPDATE ttrss_user_entries
|
||||||
|
SET unread = false, last_read = NOW() WHERE ref_id IN
|
||||||
|
(SELECT id FROM
|
||||||
|
(SELECT DISTINCT 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 AND $search_qpart) as tmp)");
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function getAllCounters() {
|
function getAllCounters() {
|
||||||
|
|
|
@ -484,28 +484,31 @@ function catchupFeed(feed, is_cat, mode) {
|
||||||
|
|
||||||
switch (mode) {
|
switch (mode) {
|
||||||
case "1day":
|
case "1day":
|
||||||
str = __("Mark all articles in %s older than 1 day as read?");
|
str = __("Mark %w in %s older than 1 day as read?");
|
||||||
break;
|
break;
|
||||||
case "1week":
|
case "1week":
|
||||||
str = __("Mark all articles in %s older than 1 week as read?");
|
str = __("Mark %w in %s older than 1 week as read?");
|
||||||
break;
|
break;
|
||||||
case "2week":
|
case "2week":
|
||||||
str = __("Mark all articles in %s older than 2 weeks as read?");
|
str = __("Mark %w in %s older than 2 weeks as read?");
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
str = __("Mark all articles in %s as read?");
|
str = __("Mark %w in %s as read?");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var mark_what = last_search_query && last_search_query[0] ? __("search results") : __("all articles");
|
||||||
var fn = getFeedName(feed, is_cat);
|
var fn = getFeedName(feed, is_cat);
|
||||||
|
|
||||||
str = str.replace("%s", fn);
|
str = str.replace("%s", fn)
|
||||||
|
.replace("%w", mark_what);
|
||||||
|
|
||||||
if (getInitParam("confirm_feed_catchup") == 1 && !confirm(str)) {
|
if (getInitParam("confirm_feed_catchup") == 1 && !confirm(str)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var catchup_query = "?op=rpc&method=catchupFeed&feed_id=" +
|
var catchup_query = {op: 'rpc', method: 'catchupFeed', feed_id: feed,
|
||||||
feed + "&is_cat=" + is_cat + "&mode=" + mode;
|
is_cat: is_cat, mode: mode, search_query: last_search_query[0],
|
||||||
|
search_lang: last_search_query[1]};
|
||||||
|
|
||||||
console.log(catchup_query);
|
console.log(catchup_query);
|
||||||
|
|
||||||
|
|
|
@ -13,6 +13,7 @@ var loaded_article_ids = [];
|
||||||
var _last_headlines_update = 0;
|
var _last_headlines_update = 0;
|
||||||
var _headlines_scroll_offset = 0;
|
var _headlines_scroll_offset = 0;
|
||||||
var current_first_id = 0;
|
var current_first_id = 0;
|
||||||
|
var last_search_query;
|
||||||
|
|
||||||
var _catchup_request_sent = false;
|
var _catchup_request_sent = false;
|
||||||
|
|
||||||
|
@ -38,6 +39,7 @@ function headlines_callback2(transport, offset, background, infscroll_req) {
|
||||||
|
|
||||||
is_cat = reply['headlines']['is_cat'];
|
is_cat = reply['headlines']['is_cat'];
|
||||||
feed_id = reply['headlines']['id'];
|
feed_id = reply['headlines']['id'];
|
||||||
|
last_search_query = reply['headlines']['search_query'];
|
||||||
|
|
||||||
if (background) {
|
if (background) {
|
||||||
var content = reply['headlines']['content'];
|
var content = reply['headlines']['content'];
|
||||||
|
|
Loading…
Reference in a new issue