]> git.wh0rd.org - tt-rss.git/blobdiff - classes/pref/feeds.php
add (disabled) per-feed view_settings handling placeholder
[tt-rss.git] / classes / pref / feeds.php
index d2e69c502e7238aeaafa9bf3b6cd53e4a973a2fb..7895a0396795889ef559893c798d0231832b76a1 100644 (file)
@@ -33,8 +33,10 @@ class Pref_Feeds extends Handler_Protected {
 
                if ($search) $search_qpart = " AND LOWER(title) LIKE LOWER('%$search%')";
 
-               $show_empty_cats = $_REQUEST['mode'] != 2 && !$search &&
-                       get_pref($this->link, '_PREFS_SHOW_EMPTY_CATS');
+               // first one is set by API
+               $show_empty_cats = $_REQUEST['force_show_empty'] ||
+                       ($_REQUEST['mode'] != 2 && !$search &&
+                               get_pref($this->link, '_PREFS_SHOW_EMPTY_CATS'));
 
                $items = array();
 
@@ -87,6 +89,10 @@ class Pref_Feeds extends Handler_Protected {
        }
 
        function getfeedtree() {
+               print json_encode($this->makefeedtree());
+       }
+
+       function makefeedtree() {
 
                if ($_REQUEST['mode'] != 2)
                        $search = $_SESSION["prefs_feed_search"];
@@ -179,8 +185,9 @@ class Pref_Feeds extends Handler_Protected {
                }
 
                if ($enable_cats) {
-                       $show_empty_cats = $_REQUEST['mode'] != 2 && !$search &&
-                               get_pref($this->link, '_PREFS_SHOW_EMPTY_CATS');
+                       $show_empty_cats = $_REQUEST['force_show_empty'] ||
+                               ($_REQUEST['mode'] != 2 && !$search &&
+                               get_pref($this->link, '_PREFS_SHOW_EMPTY_CATS'));
 
                        $result = db_query($this->link, "SELECT id, title FROM ttrss_feed_categories
                                WHERE owner_uid = " . $_SESSION["uid"] . " AND parent_cat IS NULL ORDER BY order_id, title");
@@ -284,8 +291,7 @@ class Pref_Feeds extends Handler_Protected {
                        $fl['items'] =& $root['items'];
                }
 
-               print json_encode($fl);
-               return;
+               return $fl;
        }
 
        function catsortreset() {
@@ -736,7 +742,9 @@ class Pref_Feeds extends Handler_Protected {
 
                $feed_ids = db_escape_string($this->link, $_REQUEST["ids"]);
 
-               print "<div class=\"dialogNotice\">" . __("Enable the options you wish to apply using checkboxes on the right:") . "</div>";
+               print_notice("Enable the options you wish to apply using checkboxes on the right:");
+
+               print "<p>";
 
                print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"ids\" value=\"$feed_ids\">";
                print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"op\" value=\"pref-feeds\">";
@@ -1517,7 +1525,7 @@ class Pref_Feeds extends Handler_Protected {
                        GROUP BY ttrss_feeds.title, ttrss_feeds.id, ttrss_feeds.site_url, ttrss_feeds.feed_url
                        ORDER BY last_article");
 
-               print "<div class=\"dialogNotice\">" . __("These feeds have not been updated with new content for 3 months (oldest first):") . "</div>";
+               print "<h2" .__("These feeds have not been updated with new content for 3 months (oldest first):") . "</h2>";
 
                print "<div dojoType=\"dijit.Toolbar\">";
                print "<div dojoType=\"dijit.form.DropDownButton\">".
@@ -1583,7 +1591,8 @@ class Pref_Feeds extends Handler_Protected {
        }
 
        function feedsWithErrors() {
-               print "<div class=\"dialogNotice\">" . __("These feeds have not been updated because of errors:") . "</div>";
+               print "<h2>" . __("These feeds have not been updated because of errors:") .
+                       "</h2>";
 
                $result = db_query($this->link, "SELECT id,title,feed_url,last_error,site_url
                FROM ttrss_feeds WHERE last_error != '' AND owner_uid = ".$_SESSION["uid"]);
@@ -1693,18 +1702,27 @@ class Pref_Feeds extends Handler_Protected {
 
                        /* prepare feed if necessary */
 
+                       $result = db_query($link, "SELECT feed_url FROM ttrss_feeds WHERE id = $id
+                               AND owner_uid = $owner_uid");
+
+                       $feed_url = db_escape_string($link, db_fetch_result($result, 0, "feed_url"));
+
                        $result = db_query($link, "SELECT id FROM ttrss_archived_feeds
-                               WHERE id = '$id'");
+                               WHERE feed_url = '$feed_url' AND owner_uid = $owner_uid");
 
                        if (db_num_rows($result) == 0) {
                                db_query($link, "INSERT INTO ttrss_archived_feeds
                                        (id, owner_uid, title, feed_url, site_url)
                                SELECT id, owner_uid, title, feed_url, site_url from ttrss_feeds
-                               WHERE id = '$id'");
+                               WHERE id = '$id'");
+
+                               $archive_id = $id;
+                       } else {
+                               $archive_id = db_fetch_result($result, 0, "id");
                        }
 
                        db_query($link, "UPDATE ttrss_user_entries SET feed_id = NULL,
-                               orig_feed_id = '$id' WHERE feed_id = '$id' AND
+                               orig_feed_id = '$archive_id' WHERE feed_id = '$id' AND
                                        marked = true AND owner_uid = $owner_uid");
 
                        /* Remove access key for the feed */