function purge_feed($link, $feed_id, $purge_interval, $debug = false) {
+ if (!$purge_interval) $purge_interval = feed_purge_interval($link, $feed_id);
+
$rows = -1;
+ $result = db_query($link,
+ "SELECT owner_uid FROM ttrss_feeds WHERE id = '$feed_id'");
+
+ $owner_uid = false;
+
+ if (db_num_rows($result) == 1) {
+ $owner_uid = db_fetch_result($result, 0, "owner_uid");
+ }
+
+ if (!$owner_uid) return;
+
+ $purge_unread = get_pref($link, "PURGE_UNREAD_ARTICLES",
+ $owner_uid, false);
+
+ if (!$purge_unread) $query_limit = " unread = false AND ";
+
if (DB_TYPE == "pgsql") {
/* $result = db_query($link, "DELETE FROM ttrss_user_entries WHERE
marked = false AND feed_id = '$feed_id' AND
ttrss_entries.id = ref_id AND
marked = false AND
feed_id = '$feed_id' AND
+ $query_limit
ttrss_entries.date_entered < NOW() - INTERVAL '$purge_interval days'");
} else {
WHERE ttrss_entries.id = ref_id AND
marked = false AND
feed_id = '$feed_id' AND
+ $query_limit
ttrss_entries.date_entered < NOW() - INTERVAL '$purge_interval days'");
}
WHERE ttrss_entries.id = ref_id AND
marked = false AND
feed_id = '$feed_id' AND
+ $query_limit
ttrss_entries.date_entered < DATE_SUB(NOW(), INTERVAL $purge_interval DAY)");
$rows = mysql_affected_rows($link);
}
+ function feed_purge_interval($link, $feed_id) {
+
+ $result = db_query($link, "SELECT purge_interval, owner_uid FROM ttrss_feeds
+ WHERE id = '$feed_id'");
+
+ if (db_num_rows($result) == 1) {
+ $purge_interval = db_fetch_result($result, 0, "purge_interval");
+ $owner_uid = db_fetch_result($result, 0, "owner_uid");
+
+ if ($purge_interval == 0) $purge_interval = get_pref($link,
+ 'PURGE_OLD_DAYS', $user_id);
+
+ return $purge_interval;
+
+ } else {
+ return -1;
+ }
+ }
+
function purge_old_posts($link) {
$user_id = $_SESSION["uid"];
require_once "functions.php";
define('EXPECTED_CONFIG_VERSION', 11);
- define('SCHEMA_VERSION', 25);
+ define('SCHEMA_VERSION', 26);
if (!file_exists("config.php")) {
print __("<b>Fatal Error</b>: You forgot to copy
create table ttrss_version (schema_version int not null) TYPE=InnoDB;
-insert into ttrss_version values (25);
+insert into ttrss_version values (26);
create table ttrss_prefs_types (id integer not null primary key,
type_name varchar(100) not null) TYPE=InnoDB;
insert into ttrss_prefs (pref_name,type_id,def_value,short_desc,section_id) values('CDM_EXPANDED', 1, 'true', 'Automatically expand articles in combined mode',3);
+insert into ttrss_prefs (pref_name,type_id,def_value,short_desc,section_id) values('PURGE_UNREAD_ARTICLES', 1, 'true', 'Purge unread articles',3);
+
create table ttrss_user_prefs (
owner_uid integer not null,
pref_name varchar(250),
create table ttrss_version (schema_version int not null);
-insert into ttrss_version values (25);
+insert into ttrss_version values (26);
create table ttrss_prefs_types (id integer not null primary key,
type_name varchar(100) not null);
insert into ttrss_prefs (pref_name,type_id,def_value,short_desc,section_id) values('CDM_EXPANDED', 1, 'true', 'Automatically expand articles in combined mode',3);
+insert into ttrss_prefs (pref_name,type_id,def_value,short_desc,section_id) values('PURGE_UNREAD_ARTICLES', 1, 'true', 'Purge unread articles',3);
+
create table ttrss_user_prefs (
owner_uid integer not null references ttrss_users(id) ON DELETE CASCADE,
pref_name varchar(250) not null references ttrss_prefs(pref_name) ON DELETE CASCADE,
--- /dev/null
+insert into ttrss_prefs (pref_name,type_id,def_value,short_desc,section_id) values('PURGE_UNREAD_ARTICLES', 1, 'true', 'Purge unread articles',3);
+
+update ttrss_version set schema_version = 26;
--- /dev/null
+insert into ttrss_prefs (pref_name,type_id,def_value,short_desc,section_id) values('PURGE_UNREAD_ARTICLES', 1, 'true', 'Purge unread articles',3);
+
+update ttrss_version set schema_version = 26;