]> git.wh0rd.org - tt-rss.git/commitdiff
getFeeds: add necessary parameters for pagination
authorAndrew Dolgov <fox@bah.org.ru>
Mon, 21 Dec 2009 10:04:23 +0000 (13:04 +0300)
committerAndrew Dolgov <fox@bah.org.ru>
Mon, 21 Dec 2009 10:04:23 +0000 (13:04 +0300)
api/index.php

index c9d134df12e6bcb25809c21dabf7c8615616c127..29608d57808e143930c3e28fb4d38870500c6556 100644 (file)
                case "getFeeds":
                        $cat_id = db_escape_string($_REQUEST["cat_id"]);
                        $unread_only = (bool)db_escape_string($_REQUEST["unread_only"]);
+                       $limit = (int) db_escape_string($_REQUEST["limit"]);
+                       $offset = (int) db_escape_string($_REQUEST["offset"]);
+
+                       if ($limit) {
+                               $limit_qpart = "LIMIT $limit OFFSET $offset";
+                       } else {
+                               $limit_qpart = "";
+                       }
 
                        if (!$cat_id) {
                                $result = db_query($link, "SELECT 
                                        id, feed_url, cat_id, title, ".
                                                SUBSTRING_FOR_DATE."(last_updated,1,19) AS last_updated
-                                               FROM ttrss_feeds WHERE owner_uid = " . $_SESSION["uid"]);
+                                               FROM ttrss_feeds WHERE owner_uid = " . $_SESSION["uid"] . 
+                                               "ORDER BY cat_id, title " . $limit_qpart);
                        } else {
                                $result = db_query($link, "SELECT 
                                        id, feed_url, cat_id, title, ".
                                                SUBSTRING_FOR_DATE."(last_updated,1,19) AS last_updated
                                                FROM ttrss_feeds WHERE 
-                                                       cat_id = '$cat_id' AND owner_uid = " . $_SESSION["uid"]);
+                                               cat_id = '$cat_id' AND owner_uid = " . $_SESSION["uid"] . 
+                                               "ORDER BY cat_id, title " . $limit_qpart);
                        }
 
                        $feeds = array();