add simple op=getUnread call to return global unread counter
This commit is contained in:
parent
ed891a51b0
commit
f3acc32e56
2 changed files with 30 additions and 8 deletions
29
backend.php
29
backend.php
|
@ -37,7 +37,12 @@
|
|||
header("Content-Type: application/xml");
|
||||
}
|
||||
|
||||
if (!$_SESSION["uid"] && $op != "globalUpdateFeeds" && $op != "rss") {
|
||||
if (!$op) {
|
||||
header("Content-Type: application/xml");
|
||||
print_error_xml(7); exit;
|
||||
}
|
||||
|
||||
if (!$_SESSION["uid"] && $op != "globalUpdateFeeds" && $op != "rss" && $op != "getUnread") {
|
||||
|
||||
if ($op == "rpc") {
|
||||
print_error_xml(6); die;
|
||||
|
@ -58,10 +63,6 @@
|
|||
exit;
|
||||
}
|
||||
|
||||
if (!$op) {
|
||||
print_error_xml(7); exit;
|
||||
}
|
||||
|
||||
$purge_intervals = array(
|
||||
0 => "Use default",
|
||||
-1 => "Never purge",
|
||||
|
@ -3872,8 +3873,24 @@
|
|||
}
|
||||
}
|
||||
|
||||
if ($op == "getUnread") {
|
||||
$login = db_escape_string($_GET["login"]);
|
||||
|
||||
header("Content-Type: text/plain");
|
||||
|
||||
$result = db_query($link, "SELECT id FROM ttrss_users WHERE login = '$login'");
|
||||
|
||||
if (db_num_rows($result) == 1) {
|
||||
$uid = db_fetch_result($result, 0, "id");
|
||||
print getGlobalUnread($link, $uid);
|
||||
} else {
|
||||
print "Error: user not found";
|
||||
}
|
||||
}
|
||||
|
||||
db_close($link);
|
||||
?>
|
||||
|
||||
<?php if ($op != "getUnread") { ?>
|
||||
<!-- <?php echo sprintf("Backend execution time: %.4f seconds", getmicrotime() - $script_started) ?> -->
|
||||
|
||||
<?php } ?>
|
||||
|
|
|
@ -1555,13 +1555,18 @@
|
|||
|
||||
/* FIXME this needs reworking */
|
||||
|
||||
function getGlobalUnread($link) {
|
||||
function getGlobalUnread($link, $user_id = false) {
|
||||
|
||||
if (!$user_id) {
|
||||
$user_id = $_SESSION["uid"];
|
||||
}
|
||||
|
||||
$result = db_query($link, "SELECT count(ttrss_entries.id) as c_id FROM ttrss_entries,ttrss_user_entries,ttrss_feeds
|
||||
WHERE unread = true AND
|
||||
ttrss_user_entries.feed_id = ttrss_feeds.id AND
|
||||
ttrss_user_entries.ref_id = ttrss_entries.id AND
|
||||
hidden = false AND
|
||||
ttrss_user_entries.owner_uid = " . $_SESSION["uid"]);
|
||||
ttrss_user_entries.owner_uid = '$user_id'");
|
||||
$c_id = db_fetch_result($result, 0, "c_id");
|
||||
return $c_id;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue