1
0
mirror of https://tt-rss.org/git/tt-rss.git synced 2024-06-24 11:56:36 +02:00

api, getArticle: check for article_id being present

This commit is contained in:
Andrew Dolgov 2013-05-15 22:29:31 +04:00
parent b79da01999
commit 6f81395d73

View File

@ -307,54 +307,58 @@ class API extends Handler {
$article_id = join(",", array_filter(explode(",", $this->dbh->escape_string($_REQUEST["article_id"])), is_numeric)); $article_id = join(",", array_filter(explode(",", $this->dbh->escape_string($_REQUEST["article_id"])), is_numeric));
$query = "SELECT id,title,link,content,cached_content,feed_id,comments,int_id, if ($article_id) {
marked,unread,published,score,
".SUBSTRING_FOR_DATE."(updated,1,16) as updated,
author,(SELECT title FROM ttrss_feeds WHERE id = feed_id) AS feed_title
FROM ttrss_entries,ttrss_user_entries
WHERE id IN ($article_id) AND ref_id = id AND owner_uid = " .
$_SESSION["uid"] ;
$result = $this->dbh->query($query); $query = "SELECT id,title,link,content,cached_content,feed_id,comments,int_id,
marked,unread,published,score,
".SUBSTRING_FOR_DATE."(updated,1,16) as updated,
author,(SELECT title FROM ttrss_feeds WHERE id = feed_id) AS feed_title
FROM ttrss_entries,ttrss_user_entries
WHERE id IN ($article_id) AND ref_id = id AND owner_uid = " .
$_SESSION["uid"] ;
$articles = array(); $result = $this->dbh->query($query);
if ($this->dbh->num_rows($result) != 0) { $articles = array();
while ($line = $this->dbh->fetch_assoc($result)) { if ($this->dbh->num_rows($result) != 0) {
$attachments = get_article_enclosures($line['id']); while ($line = $this->dbh->fetch_assoc($result)) {
$article = array( $attachments = get_article_enclosures($line['id']);
"id" => $line["id"],
"title" => $line["title"], $article = array(
"link" => $line["link"], "id" => $line["id"],
"labels" => get_article_labels($line['id']), "title" => $line["title"],
"unread" => sql_bool_to_bool($line["unread"]), "link" => $line["link"],
"marked" => sql_bool_to_bool($line["marked"]), "labels" => get_article_labels($line['id']),
"published" => sql_bool_to_bool($line["published"]), "unread" => sql_bool_to_bool($line["unread"]),
"comments" => $line["comments"], "marked" => sql_bool_to_bool($line["marked"]),
"author" => $line["author"], "published" => sql_bool_to_bool($line["published"]),
"updated" => (int) strtotime($line["updated"]), "comments" => $line["comments"],
"content" => $line["cached_content"] != "" ? $line["cached_content"] : $line["content"], "author" => $line["author"],
"feed_id" => $line["feed_id"], "updated" => (int) strtotime($line["updated"]),
"attachments" => $attachments, "content" => $line["cached_content"] != "" ? $line["cached_content"] : $line["content"],
"score" => (int)$line["score"], "feed_id" => $line["feed_id"],
"feed_title" => $line["feed_title"] "attachments" => $attachments,
); "score" => (int)$line["score"],
"feed_title" => $line["feed_title"]
);
foreach (PluginHost::getInstance()->get_hooks(PluginHost::HOOK_RENDER_ARTICLE_API) as $p) {
$article = $p->hook_render_article_api(array("article" => $article));
}
array_push($articles, $article);
foreach (PluginHost::getInstance()->get_hooks(PluginHost::HOOK_RENDER_ARTICLE_API) as $p) {
$article = $p->hook_render_article_api(array("article" => $article));
} }
array_push($articles, $article);
} }
$this->wrap(self::STATUS_OK, $articles);
} else {
$this->wrap(self::STATUS_ERR, array("error" => 'INCORRECT_USAGE'));
} }
$this->wrap(self::STATUS_OK, $articles);
} }
function getConfig() { function getConfig() {