$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> </td><td>Select</td><td width=\"40%\">Title</td>
- <td width=\"30%\">Link</td><td width=\"10%\">Update Interval</td>
+ <td> </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>";
}
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) {
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.");
return;
}
+ if (purge_intl < 0) {
+ notify("Purge days must be >= 0 (0 = default)");
+ return;
+ }
if (link.length == 0) {
notify("Feed link cannot be blank.");
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);