]> git.wh0rd.org Git - tt-rss.git/commitdiff
api: improve getHeadlines/updateArticle
authorAndrew Dolgov <fox@bah.org.ru>
Tue, 5 Jan 2010 17:33:08 +0000 (20:33 +0300)
committerAndrew Dolgov <fox@bah.org.ru>
Tue, 5 Jan 2010 17:33:08 +0000 (20:33 +0300)
api/index.php

index 5d749340237d1b388c8dce5a198ba7d0c87a0bc4..9d1a962dcb1e7d985894114b99d2ff22c3cbcf36 100644 (file)
                        $is_cat = (bool)db_escape_string($_REQUEST["is_cat"]);
                        $show_excerpt = (bool)db_escape_string($_REQUEST["show_excerpt"]);
                        $show_content = (bool)db_escape_string($_REQUEST["show_content"]);
+                       /* all_articles, unread, adaptive, marked, updated */
+                       $view_mode = db_escape_string($_REQUEST["view_mode"]);
 
                        /* do not rely on params below */
 
                                                "updated" => strtotime($line["updated"]),
                                                "is_updated" => $is_updated,
                                                "title" => $line["title"],
+                                               "link" => $line["link"],
                                                "feed_id" => $line["feed_id"],
                                        );
 
 
                        break;
                case "updateArticle":
-                       $article_id = (int) db_escape_string($_REQUEST["article_id"]);
+                       $article_ids = split(",", db_escape_string($_REQUEST["article_ids"]));
                        $mode = (int) db_escape_string($_REQUEST["mode"]);
                        $field_raw = (int)db_escape_string($_REQUEST["field"]);
 
                                        break;
                        }
 
-                       if ($field && $set_to) {
+                       if ($field && $set_to && count($article_ids) > 0) {
+
+                               $article_ids = join(", ", $article_ids);
+
                                if ($field == "unread") {
                                        $result = db_query($link, "UPDATE ttrss_user_entries SET $field = $set_to,
                                                last_read = NOW()
-                                               WHERE ref_id = '$article_id' AND owner_uid = " . $_SESSION["uid"]);
+                                               WHERE ref_id IN ($article_ids) AND owner_uid = " . $_SESSION["uid"]);
                                } else {
                                        $result = db_query($link, "UPDATE ttrss_user_entries SET $field = $set_to
-                                               WHERE ref_id = '$article_id' AND owner_uid = " . $_SESSION["uid"]);
+                                               WHERE ref_id IN ($article_ids) AND owner_uid = " . $_SESSION["uid"]);
                                }
                        }