1
0
mirror of https://git.tt-rss.org/git/tt-rss.git synced 2025-12-22 01:01:29 +00:00

synchronize unread status from offline to online DB

This commit is contained in:
Andrew Dolgov
2009-02-07 13:40:43 +03:00
parent b7dbf528f3
commit badac687b0
3 changed files with 161 additions and 5 deletions

View File

@@ -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 "<rpc-reply>";
$sync = split(";", $sync);
print "<sync>";
if (count($sync) > 0) {
if (strtotime($sync[0])) {
$last_online = db_escape_string($sync[0]);
print "<sync-point><![CDATA[$last_online]]></sync-point>";
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 "<sync-ok id=\"$id\"/>";
// }
}
}
}
}
print "</sync>";
if ($stage == 0) {
print "<feeds>";
@@ -596,7 +638,6 @@
}
if ($stage > 0) {
print "<articles>";
$limit = 50;