]> git.wh0rd.org Git - tt-rss.git/commitdiff
adaptive view mode
authorAndrew Dolgov <fox@madoka.spb.ru>
Mon, 12 Dec 2005 04:58:38 +0000 (05:58 +0100)
committerAndrew Dolgov <fox@madoka.spb.ru>
Mon, 12 Dec 2005 04:58:38 +0000 (05:58 +0100)
backend.php
tt-rss.php

index 790a016cb182bba260829f1d12b5812be8fcca72..b87c6cf316dbf19c459591a9fa378f6fcdf0e400 100644 (file)
                getGlobalCounters($link);
        }       
 
+       function getFeedUnread($link, $feed) {
+               $n_feed = sprintf("%d", $feed);
+       
+               if ($n_feed == -1) {
+                       $match_part = "marked = true";
+               } else if ($feed > 0) {
+                       $match_part = "feed_id = '$n_feed'";
+               } else if ($feed < -10) {
+                       $label_id = -$feed - 11;
+
+                       $result = db_query($link, "SELECT sql_exp FROM ttrss_labels WHERE
+                               id = '$label_id' AND owner_uid = " . $_SESSION["uid"]);
+
+                       $match_part = db_fetch_result($result, 0, "sql_exp");
+               }
+
+               if ($match_part) {
+               
+                       $result = db_query($link, "SELECT count(int_id) AS unread 
+                               FROM ttrss_user_entries 
+                               WHERE   unread = true AND $match_part AND owner_uid = " . $_SESSION["uid"]);
+                               
+               } else {
+               
+                       $result = db_query($link, "SELECT COUNT(post_int_id) AS unread
+                               FROM ttrss_tags,ttrss_user_entries 
+                               WHERE tag_name = '$feed' AND post_int_id = int_id AND unread = true AND
+                                       ttrss_tags.owner_uid = " . $_SESSION["uid"]);
+               }
+               
+               $unread = db_fetch_result($result, 0, "unread");
+               return $unread;
+       }
+
        /* FIXME this needs reworking */
 
        function getGlobalCounters($link) {
 
                $view_query_part = "";
 
+               if ($view_mode == "Adaptive") {
+                       if ($feed != -1) {
+                               $unread = getFeedUnread($link, $feed);
+                               if ($unread > 0) {
+                                       $view_query_part = " unread = true AND ";
+                               }
+                       }
+               }
+
                if ($view_mode == "Starred") {
                        $view_query_part = " marked = true AND ";
                }
                        $view_query_part = " unread = true AND ";
                }
 
-               if ($view_mode == "Unread or Starred") {
+/*             if ($view_mode == "Unread or Starred") {
                        $view_query_part = " (unread = true OR marked = true) AND ";
                }
 
                if ($view_mode == "Unread or Updated") {
                        $view_query_part = " (unread = true OR last_read is NULL) AND ";
-               }
+               } */
 
 /*             $result = db_query($link, "SELECT count(id) AS total_entries 
                        FROM ttrss_entries WHERE 
index 5c15a507baa3f6aa830bd62801ff1958ce81cfc3..f76614c2ea4c9a0ee895a50cc5dec006e4521d56 100644 (file)
                &nbsp;View: 
                
                <select id="viewbox" onchange="javascript:viewCurrentFeed(0, '')">
+                       <option selected>Adaptive</option>
                        <option>All Articles</option>
                        <option>Starred</option>
-                       <option selected>Unread</option>
-                       <option>Unread or Starred</option>
-                       <option>Unread or Updated</option>
+                       <option>Unread</option>
                </select>
 
                &nbsp;Limit: