]> git.wh0rd.org Git - tt-rss.git/commitdiff
per-feed purge intervals
authorAndrew Dolgov <fox@madoka.spb.ru>
Wed, 16 Nov 2005 09:37:50 +0000 (10:37 +0100)
committerAndrew Dolgov <fox@madoka.spb.ru>
Wed, 16 Nov 2005 09:37:50 +0000 (10:37 +0100)
backend.php
functions.php
prefs.js
tt-rss.css

index 3a15509081b06bd9487238e0b77b192204249887..7781828a758c431fd0870d566c221cc17c811c0d 100644 (file)
                        $feed_title = db_escape_string($_GET["t"]);
                        $feed_link = db_escape_string($_GET["l"]);
                        $upd_intl = db_escape_string($_GET["ui"]);
+                       $purge_intl = db_escape_string($_GET["pi"]);
                        $feed_id = $_GET["id"];
 
                        if (strtoupper($upd_intl) == "DEFAULT")
                                $upd_intl = 0;
 
+                       if (strtoupper($purge_intl) == "DEFAULT")
+                               $purge_intl = 0;
+
                        $result = db_query($link, "UPDATE ttrss_feeds SET 
                                title = '$feed_title', feed_url = '$feed_link',
-                               update_interval = '$upd_intl' WHERE id = '$feed_id'");                  
+                               update_interval = '$upd_intl',
+                               purge_interval = '$purge_intl' 
+                               WHERE id = '$feed_id'");                        
 
                }
 
 
                $result = db_query($link, "SELECT 
                                id,title,feed_url,substring(last_updated,1,16) as last_updated,
-                               update_interval
+                               update_interval,purge_interval
                        FROM 
                                ttrss_feeds ORDER by title");
 
                print "<p><table width=\"100%\" class=\"prefFeedList\" id=\"prefFeedList\">";
                print "<tr class=\"title\">
-                                       <td>&nbsp;</td><td>Select</td><td width=\"40%\">Title</td>
-                                       <td width=\"30%\">Link</td><td width=\"10%\">Update Interval</td>
+                                       <td>&nbsp;</td><td>Select</td><td width=\"30%\">Title</td>
+                                       <td width=\"30%\">Link</td>
+                                       <td width=\"10%\">Update Interval</td>
+                                       <td width=\"10%\">Purge Days</td>
                                        <td>Last updated</td></tr>";
                
                $lnum = 0;
                                type=\"checkbox\" id=\"FRCHK-".$line["id"]."\"></td>";
 
                                print "<td><a href=\"javascript:editFeed($feed_id);\">" . 
-                                       $edit_title . "</td>";          
+                                       $edit_title . "</a></td>";              
                                print "<td><a href=\"javascript:editFeed($feed_id);\">" . 
-                                       $edit_link . "</td>";           
+                                       $edit_link . "</a></td>";               
 
                                if ($line["update_interval"] == "0")
                                        $line["update_interval"] = "Default";
 
-                               print "<td>" . $line["update_interval"] . "</td>";
+                               print "<td><a href=\"javascript:editFeed($feed_id);\">" . 
+                                       $line["update_interval"] . "</a></td>";
 
+                               if ($line["purge_interval"] == "0")
+                                       $line["purge_interval"] = "Default";
+
+                               print "<td><a href=\"javascript:editFeed($feed_id);\">" . 
+                                       $line["purge_interval"] . "</a></td>";
 
                        } else if ($feed_id != $edit_feed_id) {
 
 
                                print "<td>" . $line["update_interval"] . "</td>";
 
+                               if ($line["purge_interval"] == "0")
+                                       $line["purge_interval"] = "Default";
+
+                               print "<td>" . $line["purge_interval"] . "</td>";
+
                        } else {
 
                                print "<td><input disabled=\"true\" type=\"checkbox\"></td>";
                                print "<td><input id=\"iedit_title\" value=\"$edit_title\"></td>";
                                print "<td><input id=\"iedit_link\" value=\"$edit_link\"></td>";
                                print "<td><input id=\"iedit_updintl\" value=\"".$line["update_interval"]."\"></td>";
+                               print "<td><input id=\"iedit_purgintl\" value=\"".$line["purge_interval"]."\"></td>";
                                        
                        }
 
index 28cbb1cdda2d5a5774f05e3de02215a582f3455e..4ab9ac7dffdc96b8cf96ba71f58601e25e2c0c90 100644 (file)
@@ -4,18 +4,43 @@
        define('MAGPIE_OUTPUT_ENCODING', 'UTF-8');
 
        function purge_old_posts($link) {
+
+               $result = db_query($link, "SELECT id,purge_interval FROM ttrss_feeds");
+
+               while ($line = db_fetch_assoc($result)) {
+
+                       $feed_id = $line["id"];
+                       $purge_interval = $line["purge_interval"];
+
+                       if ($purge_interval == 0) $purge_interval = PURGE_OLD_DAYS;
+
+                       if ($purge_interval != 0) {
+
+                               if (DB_TYPE == "pgsql") {
+                                       db_query($link, "DELETE FROM ttrss_entries WHERE
+                                               marked = false AND feed_id = '$feed_id' AND
+                                               date_entered < NOW() - INTERVAL '$purge_interval days'");
+                               } else {
+                                       db_query($link, "DELETE FROM ttrss_entries WHERE
+                                               marked = false AND AND feed_id = '$feed_id' AND
+                                               date_entered < DATE_SUB(NOW(), INTERVAL $purge_interval DAY)");
+                               }
+                       }
+               }       
+
+       /*      
                if (PURGE_OLD_DAYS > 0) {
 
                        if (DB_TYPE == "pgsql") {
                                $result = db_query($link, "DELETE FROM ttrss_entries WHERE
-                                       marked = false AND 
+                                       marked = false AND feed_id = '$feed_id' AND
                                        date_entered < NOW() - INTERVAL '".PURGE_OLD_DAYS." days'");
                        } else {
                                $result = db_query($link, "DELETE FROM ttrss_entries WHERE
-                                       marked = false AND 
+                                       marked = false AND AND feed_id = '$feed_id' AND
                                        date_entered < DATE_SUB(NOW(), INTERVAL ".PURGE_OLD_DAYS." DAY)");
                        }
-               }
+               } */
        }
 
        function update_all_feeds($link, $fetch) {
index 0f545b7f88fcc9edf59f3fb9a000751b2039997c..5c6f7a7f60faa19694a738f3a7bc90e1ea6f07bc 100644 (file)
--- a/prefs.js
+++ b/prefs.js
@@ -462,6 +462,7 @@ function feedEditSave() {
        var link = document.getElementById("iedit_link").value;
        var title = document.getElementById("iedit_title").value;
        var upd_intl = document.getElementById("iedit_updintl").value;
+       var purge_intl = document.getElementById("iedit_purgintl").value;
 
 //     notify("Saving feed.");
 
@@ -470,6 +471,10 @@ function feedEditSave() {
                return;
        }
 
+       if (purge_intl < 0) {
+               notify("Purge days must be &gt;= 0 (0 = default)");
+               return;
+       }
 
        if (link.length == 0) {
                notify("Feed link cannot be blank.");
@@ -485,7 +490,7 @@ function feedEditSave() {
 
        xmlhttp.open("GET", "backend.php?op=pref-feeds&subop=editSave&id=" +
                feed + "&l=" + param_escape(link) + "&t=" + param_escape(title) +
-               "&ui=" + param_escape(upd_intl), true);
+               "&ui=" + param_escape(upd_intl) + "&pi=" + param_escape(purge_intl), true);
        xmlhttp.onreadystatechange=feedlist_callback;
        xmlhttp.send(null);
 
index ed5796eb5b19051f5c56513cf94d63fc5e1ea2ca..933575aba2949c716e1b45ad0cc9aa15cf2b89ea 100644 (file)
@@ -240,7 +240,8 @@ a:hover {
        opacity : 0.8;
 }
 
-#iedit_title, #iedit_link, #iedit_regexp, #iedit_descr, #iedit_expr, #iedit_updintl {
+#iedit_title, #iedit_link, #iedit_regexp, #iedit_descr, #iedit_expr, #iedit_updintl,
+#iedit_purgintl {
        width : 100%;
        padding-left : 2px;
 }