]> git.wh0rd.org - tt-rss.git/blobdiff - classes/pref/feeds.php
remove magpie, fix article filter plugins
[tt-rss.git] / classes / pref / feeds.php
index 9dc2f7e6a33c9f20c22fbe4236cbdaed93b188cc..373498f3c696f204125f17756c259252da755aaf 100644 (file)
@@ -3,7 +3,7 @@ class Pref_Feeds extends Handler_Protected {
 
        function csrf_ignore($method) {
                $csrf_ignored = array("index", "getfeedtree", "add", "editcats", "editfeed",
-                       "savefeedorder", "uploadicon");
+                       "savefeedorder", "uploadicon", "feedswitherrors", "inactivefeeds");
 
                return array_search($method, $csrf_ignored) !== false;
        }
@@ -25,7 +25,11 @@ class Pref_Feeds extends Handler_Protected {
        }
 
        private function get_category_items($cat_id) {
-               $search = $_SESSION["prefs_feed_search"];
+
+               if ($_REQUEST['mode'] != 2)
+                       $search = $_SESSION["prefs_feed_search"];
+               else
+                       $search = "";
 
                if ($search) $search_qpart = " AND LOWER(title) LIKE LOWER('%$search%')";
 
@@ -85,7 +89,10 @@ class Pref_Feeds extends Handler_Protected {
 
        function getfeedtree() {
 
-               $search = $_SESSION["prefs_feed_search"];
+               if ($_REQUEST['mode'] != 2)
+                       $search = $_SESSION["prefs_feed_search"];
+               else
+                       $search = "";
 
                if ($search) $search_qpart = " AND LOWER(title) LIKE LOWER('%$search%')";
 
@@ -320,8 +327,11 @@ class Pref_Feeds extends Handler_Protected {
                                                $cat_id = ($item_id != "root") ?
                                                        db_escape_string($bare_item_id) : "NULL";
 
+                                               $cat_qpart = ($cat_id != 0) ? "cat_id = '$cat_id'" :
+                                                       "cat_id = NULL";
+
                                                db_query($this->link, "UPDATE ttrss_feeds
-                                                       SET order_id = $order_id, cat_id = '$cat_id'
+                                                       SET order_id = $order_id, $cat_qpart
                                                        WHERE id = '$bare_id' AND
                                                                owner_uid = " . $_SESSION["uid"]);
 
@@ -465,7 +475,6 @@ class Pref_Feeds extends Handler_Protected {
        function editfeed() {
                global $purge_intervals;
                global $update_intervals;
-               global $update_methods;
 
                $feed_id = db_escape_string($_REQUEST["id"]);
 
@@ -537,20 +546,10 @@ class Pref_Feeds extends Handler_Protected {
                print_select_hash("update_interval", $update_interval, $update_intervals,
                        'dojoType="dijit.form.Select"');
 
-               /* Update method */
-
-               $update_method = db_fetch_result($result, 0, "update_method",
-                       'dojoType="dijit.form.Select"');
-
-               print " " . __('using') . " ";
-               print_select_hash("update_method", $update_method, $update_methods,
-                       'dojoType="dijit.form.Select"');
+               /* Purge intl */
 
                $purge_interval = db_fetch_result($result, 0, "purge_interval");
 
-
-                       /* Purge intl */
-
                print "<hr/>";
                print __('Article purging:') . " ";
 
@@ -643,6 +642,19 @@ class Pref_Feeds extends Handler_Protected {
                        $checked>&nbsp;<label for=\"cache_images\">".
                __('Cache images locally')."</label>";
 
+               $cache_content = sql_bool_to_bool(db_fetch_result($result, 0, "cache_content"));
+
+               if ($cache_content) {
+                       $checked = "checked=\"1\"";
+               } else {
+                       $checked = "";
+               }
+
+               print "<hr/><input dojoType=\"dijit.form.CheckBox\" type=\"checkbox\" id=\"cache_content\"
+               name=\"cache_content\"
+                       $checked>&nbsp;<label for=\"cache_content\">".
+               __('Cache content locally')."</label>";
+
                $mark_unread_on_update = sql_bool_to_bool(db_fetch_result($result, 0, "mark_unread_on_update"));
 
                if ($mark_unread_on_update) {
@@ -723,7 +735,6 @@ class Pref_Feeds extends Handler_Protected {
        function editfeeds() {
                global $purge_intervals;
                global $update_intervals;
-               global $update_methods;
 
                $feed_ids = db_escape_string($_REQUEST["ids"]);
 
@@ -782,13 +793,6 @@ class Pref_Feeds extends Handler_Protected {
 
                $this->batch_edit_cbox("update_interval");
 
-               /* Update method */
-
-               print " " . __('using') . " ";
-               print_select_hash("update_method", $update_method, $update_methods,
-                       'disabled="1" dojoType="dijit.form.Select"');
-               $this->batch_edit_cbox("update_method");
-
                /* Purge intl */
 
                if (FORCE_ARTICLE_PURGE == 0) {
@@ -904,7 +908,8 @@ class Pref_Feeds extends Handler_Protected {
                        db_escape_string($_POST["include_in_digest"]));
                $cache_images = checkbox_to_sql_bool(
                        db_escape_string($_POST["cache_images"]));
-               $update_method = (int) db_escape_string($_POST["update_method"]);
+               $cache_content = checkbox_to_sql_bool(
+                       db_escape_string($_POST["cache_content"]));
 
                $always_display_enclosures = checkbox_to_sql_bool(
                        db_escape_string($_POST["always_display_enclosures"]));
@@ -928,8 +933,6 @@ class Pref_Feeds extends Handler_Protected {
                        $category_qpart_nocomma = "";
                }
 
-               $cache_images_qpart = "cache_images = $cache_images,";
-
                if (!$batch) {
 
                        $result = db_query($this->link, "UPDATE ttrss_feeds SET
@@ -941,13 +944,13 @@ class Pref_Feeds extends Handler_Protected {
                                auth_pass = '$auth_pass',
                                private = $private,
                                rtl_content = $rtl_content,
-                               $cache_images_qpart
+                               cache_images = $cache_images,
+                               cache_content = $cache_content,
                                include_in_digest = $include_in_digest,
                                always_display_enclosures = $always_display_enclosures,
                                mark_unread_on_update = $mark_unread_on_update,
                                update_on_checksum_change = $update_on_checksum_change,
-                               update_method = '$update_method'
-                               WHERE id = '$feed_id' AND owner_uid = " . $_SESSION["uid"]);
+                       WHERE id = '$feed_id' AND owner_uid = " . $_SESSION["uid"]);
 
                } else {
                        $feed_data = array();
@@ -1013,12 +1016,12 @@ class Pref_Feeds extends Handler_Protected {
                                                $qpart = "cache_images = $cache_images";
                                                break;
 
-                                       case "rtl_content":
-                                               $qpart = "rtl_content = $rtl_content";
+                                       case "cache_content":
+                                               $qpart = "cache_content = $cache_content";
                                                break;
 
-                                       case "update_method":
-                                               $qpart = "update_method = '$update_method'";
+                                       case "rtl_content":
+                                               $qpart = "rtl_content = $rtl_content";
                                                break;
 
                                        case "cat_id":
@@ -1067,6 +1070,8 @@ class Pref_Feeds extends Handler_Protected {
        }
 
        function rescore() {
+               require_once "rssfuncs.php";
+
                $ids = split(",", db_escape_string($_REQUEST["ids"]));
 
                foreach ($ids as $id) {
@@ -1470,7 +1475,7 @@ class Pref_Feeds extends Handler_Protected {
 
                print "<p>" . __("Use this bookmarklet to publish arbitrary pages using Tiny Tiny RSS") . "</p>";
 
-               $bm_url = htmlspecialchars("javascript:(function(){var d=document,w=window,e=w.getSelection,k=d.getSelection,x=d.selection,s=(e?e():(k)?k():(x?x.createRange().text:0)),f='".SELF_URL_PATH."/public.php?op=sharepopup',l=d.location,e=encodeURIComponent,g=f+'&title='+((e(s))?e(s):e(document.title))+'&url='+e(l.href);function a(){if(!w.open(g,'t','toolbar=0,resizable=0,scrollbars=1,status=1,width=500,height=200')){l.href=g;}}a();})()");
+               $bm_url = htmlspecialchars("javascript:(function(){var d=document,w=window,e=w.getSelection,k=d.getSelection,x=d.selection,s=(e?e():(k)?k():(x?x.createRange().text:0)),f='".SELF_URL_PATH."/public.php?op=sharepopup',l=d.location,e=encodeURIComponent,g=f+'&title='+((e(s))?e(s):e(document.title))+'&url='+e(l.href);function a(){if(!w.open(g,'t','toolbar=0,resizable=0,scrollbars=1,status=1,width=500,height=250')){l.href=g;}}a();})()");
 
                print "<a href=\"$bm_url\" class='bookmarklet'>" . __('Share with Tiny Tiny RSS'). "</a>";
 
@@ -1500,6 +1505,10 @@ class Pref_Feeds extends Handler_Protected {
 
                print "</div>"; #pane
 
+               global $pluginhost;
+               $pluginhost->run_hooks($pluginhost::HOOK_PREFS_TAB,
+                       "hook_prefs_tab", "prefFeeds");
+
                print "</div>"; #container
 
        }
@@ -1547,5 +1556,160 @@ class Pref_Feeds extends Handler_Protected {
                return $obj;
        }
 
+       function inactiveFeeds() {
+
+               if (DB_TYPE == "pgsql") {
+                       $interval_qpart = "NOW() - INTERVAL '3 months'";
+               } else {
+                       $interval_qpart = "DATE_SUB(NOW(), INTERVAL 3 MONTH)";
+               }
+
+               $result = db_query($this->link, "SELECT ttrss_feeds.title, ttrss_feeds.site_url,
+                               ttrss_feeds.feed_url, ttrss_feeds.id, MAX(updated) AS last_article
+                       FROM ttrss_feeds, ttrss_entries, ttrss_user_entries WHERE
+                               (SELECT MAX(updated) FROM ttrss_entries, ttrss_user_entries WHERE
+                                       ttrss_entries.id = ref_id AND
+                                               ttrss_user_entries.feed_id = ttrss_feeds.id) < $interval_qpart
+                       AND ttrss_feeds.owner_uid = ".$_SESSION["uid"]." AND
+                               ttrss_user_entries.feed_id = ttrss_feeds.id AND
+                               ttrss_entries.id = ref_id
+                       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 "<div dojoType=\"dijit.Toolbar\">";
+               print "<div dojoType=\"dijit.form.DropDownButton\">".
+                               "<span>" . __('Select')."</span>";
+               print "<div dojoType=\"dijit.Menu\" style=\"display: none;\">";
+               print "<div onclick=\"selectTableRows('prefInactiveFeedList', 'all')\"
+                       dojoType=\"dijit.MenuItem\">".__('All')."</div>";
+               print "<div onclick=\"selectTableRows('prefInactiveFeedList', 'none')\"
+                       dojoType=\"dijit.MenuItem\">".__('None')."</div>";
+               print "</div></div>";
+               print "</div>"; #toolbar
+
+               print "<div class=\"inactiveFeedHolder\">";
+
+               print "<table width=\"100%\" cellspacing=\"0\" id=\"prefInactiveFeedList\">";
+
+               $lnum = 1;
+
+               while ($line = db_fetch_assoc($result)) {
+
+                       $class = ($lnum % 2) ? "even" : "odd";
+                       $feed_id = $line["id"];
+                       $this_row_id = "id=\"FUPDD-$feed_id\"";
+
+                       # class needed for selectTableRows()
+                       print "<tr class=\"placeholder\" $this_row_id>";
+
+                       $edit_title = htmlspecialchars($line["title"]);
+
+                       # id needed for selectTableRows()
+                       print "<td width='5%' align='center'><input
+                               onclick='toggleSelectRow2(this);' dojoType=\"dijit.form.CheckBox\"
+                               type=\"checkbox\" id=\"FUPDC-$feed_id\"></td>";
+                       print "<td>";
+
+                       print "<a class=\"visibleLink\" href=\"#\" ".
+                               "title=\"".__("Click to edit feed")."\" ".
+                               "onclick=\"editFeed(".$line["id"].")\">".
+                               htmlspecialchars($line["title"])."</a>";
+
+                       print "</td><td class=\"insensitive\" align='right'>";
+                       print make_local_datetime($this->link, $line['last_article'], false);
+                       print "</td>";
+                       print "</tr>";
+
+                       ++$lnum;
+               }
+
+               print "</table>";
+               print "</div>";
+
+               print "<div class='dlgButtons'>";
+               print "<div style='float : left'>";
+               print "<button dojoType=\"dijit.form.Button\" onclick=\"dijit.byId('inactiveFeedsDlg').removeSelected()\">"
+                       .__('Unsubscribe from selected feeds')."</button> ";
+               print "</div>";
+
+               print "<button dojoType=\"dijit.form.Button\" onclick=\"dijit.byId('inactiveFeedsDlg').hide()\">".
+                       __('Close this window')."</button>";
+
+               print "</div>";
+
+       }
+
+       function feedsWithErrors() {
+               print "<div class=\"dialogNotice\">" . __("These feeds have not been updated because of errors:") . "</div>";
+
+               $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"]);
+
+               print "<div dojoType=\"dijit.Toolbar\">";
+               print "<div dojoType=\"dijit.form.DropDownButton\">".
+                               "<span>" . __('Select')."</span>";
+               print "<div dojoType=\"dijit.Menu\" style=\"display: none;\">";
+               print "<div onclick=\"selectTableRows('prefErrorFeedList', 'all')\"
+                       dojoType=\"dijit.MenuItem\">".__('All')."</div>";
+               print "<div onclick=\"selectTableRows('prefErrorFeedList', 'none')\"
+                       dojoType=\"dijit.MenuItem\">".__('None')."</div>";
+               print "</div></div>";
+               print "</div>"; #toolbar
+
+               print "<div class=\"inactiveFeedHolder\">";
+
+               print "<table width=\"100%\" cellspacing=\"0\" id=\"prefErrorFeedList\">";
+
+               $lnum = 1;
+
+               while ($line = db_fetch_assoc($result)) {
+
+                       $class = ($lnum % 2) ? "even" : "odd";
+                       $feed_id = $line["id"];
+                       $this_row_id = "id=\"FERDD-$feed_id\"";
+
+                       # class needed for selectTableRows()
+                       print "<tr class=\"placeholder\" $this_row_id>";
+
+                       $edit_title = htmlspecialchars($line["title"]);
+
+                       # id needed for selectTableRows()
+                       print "<td width='5%' align='center'><input
+                               onclick='toggleSelectRow2(this);' dojoType=\"dijit.form.CheckBox\"
+                               type=\"checkbox\" id=\"FERDC-$feed_id\"></td>";
+                       print "<td>";
+
+                       print "<a class=\"visibleLink\" href=\"#\" ".
+                               "title=\"".__("Click to edit feed")."\" ".
+                               "onclick=\"editFeed(".$line["id"].")\">".
+                               htmlspecialchars($line["title"])."</a>: ";
+
+                       print "<span class=\"insensitive\">";
+                       print htmlspecialchars($line["last_error"]);
+                       print "</span>";
+
+                       print "</td>";
+                       print "</tr>";
+
+                       ++$lnum;
+               }
+
+               print "</table>";
+               print "</div>";
+
+               print "<div class='dlgButtons'>";
+               print "<div style='float : left'>";
+               print "<button dojoType=\"dijit.form.Button\" onclick=\"dijit.byId('errorFeedsDlg').removeSelected()\">"
+                       .__('Unsubscribe from selected feeds')."</button> ";
+               print "</div>";
+
+               print "<button dojoType=\"dijit.form.Button\" onclick=\"dijit.byId('errorFeedsDlg').hide()\">".
+                       __('Close this window')."</button>";
+
+               print "</div>";
+       }
+
 }
 ?>