api: getArticle: allow comma-separated list of ids

This commit is contained in:
Andrew Dolgov 2010-10-15 19:04:09 +04:00
parent cd9c29de80
commit f95ac2755a
1 changed files with 27 additions and 26 deletions

View File

@ -194,43 +194,44 @@
case "getArticle": case "getArticle":
$article_id = (int)db_escape_string($_REQUEST["article_id"]); $article_id = db_escape_string($_REQUEST["article_id"]);
$query = "SELECT title,link,content,feed_id,comments,int_id, $query = "SELECT id,title,link,content,feed_id,comments,int_id,
marked,unread,published, marked,unread,published,
".SUBSTRING_FOR_DATE."(updated,1,16) as updated, ".SUBSTRING_FOR_DATE."(updated,1,16) as updated,
author author
FROM ttrss_entries,ttrss_user_entries FROM ttrss_entries,ttrss_user_entries
WHERE id = '$article_id' AND ref_id = id AND owner_uid = " . WHERE id IN ($article_id) AND ref_id = id AND owner_uid = " .
$_SESSION["uid"] ; $_SESSION["uid"] ;
$attachments = get_article_enclosures($link, $article_id);
$result = db_query($link, $query); $result = db_query($link, $query);
$article = array();
if (db_num_rows($result) != 0) { if (db_num_rows($result) != 0) {
$line = db_fetch_assoc($result);
$article = array( while ($line = db_fetch_assoc($result)) {
"title" => $line["title"],
"link" => $line["link"], $attachments = get_article_enclosures($link, $line['id']);
"labels" => get_article_labels($link, $article_id),
"unread" => sql_bool_to_bool($line["unread"]), $article = array(
"marked" => sql_bool_to_bool($line["marked"]), "id" => $line["id"],
"published" => sql_bool_to_bool($line["published"]), "title" => $line["title"],
"comments" => $line["comments"], "link" => $line["link"],
"author" => $line["author"], "labels" => get_article_labels($link, $line['id']),
"updated" => strtotime($line["updated"]), "unread" => sql_bool_to_bool($line["unread"]),
"content" => $line["content"], "marked" => sql_bool_to_bool($line["marked"]),
"feed_id" => $line["feed_id"], "published" => sql_bool_to_bool($line["published"]),
"attachments" => $attachments "comments" => $line["comments"],
); "author" => $line["author"],
"updated" => strtotime($line["updated"]),
"content" => $line["content"],
"feed_id" => $line["feed_id"],
"attachments" => $attachments
);
print json_encode($article);
}
} }
print json_encode($article);
break; break;
case "getConfig": case "getConfig":
$config = array( $config = array(