From 492a4a6ac8c63239ecf67fda0acfc2afca9df457 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Tue, 17 Feb 2009 12:22:31 +0300 Subject: offline: sync marked/unread status --- modules/backend-rpc.php | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) (limited to 'modules/backend-rpc.php') diff --git a/modules/backend-rpc.php b/modules/backend-rpc.php index e3d9e6165..d7700d66a 100644 --- a/modules/backend-rpc.php +++ b/modules/backend-rpc.php @@ -547,8 +547,6 @@ $unread = bool_to_sql_bool((bool) $e[1]); $marked = bool_to_sql_bool((bool) $e[2]); - /* Marked status is not synchronized yet */ - $query = "UPDATE ttrss_user_entries SET unread = $unread, last_read = '$last_online' @@ -558,23 +556,36 @@ $result = db_query($link, $query); -// if (db_affected_rows($result) > 0) { - print ""; -// } + if ($marked) { + $query = "UPDATE ttrss_user_entries SET + marked = $marked, + last_read = '$last_online' + WHERE ref_id = '$id' AND + (last_read IS NULL OR last_read < '$last_online') AND + owner_uid = ".$_SESSION["uid"]; + + $result = db_query($link, $query); + } + + print ""; } } /* Maybe we need to further update local DB for this client */ - $query = "SELECT ref_id,unread FROM ttrss_user_entries + $query = "SELECT ref_id,unread,marked FROM ttrss_user_entries WHERE last_read >= '$last_online' AND owner_uid = ".$_SESSION["uid"] . " LIMIT 1000"; $result = db_query($link, $query); while ($line = db_fetch_assoc($result)) { - print ""; + $unread = (int) sql_bool_to_bool($line["unread"]); + $marked = (int) sql_bool_to_bool($line["marked"]); + + print ""; } } -- cgit v1.2.3