From badac687b01db1491d3917e45c478b3c9d7a9a06 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Sat, 7 Feb 2009 13:40:43 +0300 Subject: synchronize unread status from offline to online DB --- modules/backend-rpc.php | 43 ++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 42 insertions(+), 1 deletion(-) (limited to 'modules/backend-rpc.php') diff --git a/modules/backend-rpc.php b/modules/backend-rpc.php index 2e9915f53..9996f7f41 100644 --- a/modules/backend-rpc.php +++ b/modules/backend-rpc.php @@ -518,6 +518,7 @@ $stage = (int) $_REQUEST["stage"]; $cidt = db_escape_string($_REQUEST["cidt"]); $cidb = db_escape_string($_REQUEST["cidb"]); + $sync = db_escape_string($_REQUEST["sync"]); //$amount = (int) $_REQUEST["amount"]; //$unread_only = db_escape_string($_REQUEST["unread_only"]); //if (!$amount) $amount = 50; @@ -527,6 +528,47 @@ print ""; + $sync = split(";", $sync); + + print ""; + + if (count($sync) > 0) { + if (strtotime($sync[0])) { + $last_online = db_escape_string($sync[0]); + + print ""; + + for ($i = 1; $i < count($sync); $i++) { + $e = split(",", $sync[$i]); + + if (count($e) == 3) { + + $id = (int) $e[0]; + $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' + WHERE ref_id = '$id' AND + (last_read IS NULL OR last_read < '$last_online') AND + owner_uid = ".$_SESSION["uid"]; + + $result = db_query($link, $query); + +// if (db_affected_rows($result) > 0) { + print ""; +// } + + } + } + } + } + + print ""; + if ($stage == 0) { print ""; @@ -596,7 +638,6 @@ } if ($stage > 0) { - print ""; $limit = 50; -- cgit v1.2.3