new preference: PURGE_UNREAD_ARTICLES (closes #161), fix bug in user purge
This commit is contained in:
parent
dda1396f92
commit
07d0efe959
6 changed files with 53 additions and 3 deletions
|
@ -81,8 +81,26 @@
|
||||||
|
|
||||||
function purge_feed($link, $feed_id, $purge_interval, $debug = false) {
|
function purge_feed($link, $feed_id, $purge_interval, $debug = false) {
|
||||||
|
|
||||||
|
if (!$purge_interval) $purge_interval = feed_purge_interval($link, $feed_id);
|
||||||
|
|
||||||
$rows = -1;
|
$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") {
|
if (DB_TYPE == "pgsql") {
|
||||||
/* $result = db_query($link, "DELETE FROM ttrss_user_entries WHERE
|
/* $result = db_query($link, "DELETE FROM ttrss_user_entries WHERE
|
||||||
marked = false AND feed_id = '$feed_id' AND
|
marked = false AND feed_id = '$feed_id' AND
|
||||||
|
@ -97,6 +115,7 @@
|
||||||
ttrss_entries.id = ref_id AND
|
ttrss_entries.id = ref_id AND
|
||||||
marked = false AND
|
marked = false AND
|
||||||
feed_id = '$feed_id' AND
|
feed_id = '$feed_id' AND
|
||||||
|
$query_limit
|
||||||
ttrss_entries.date_entered < NOW() - INTERVAL '$purge_interval days'");
|
ttrss_entries.date_entered < NOW() - INTERVAL '$purge_interval days'");
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
@ -106,6 +125,7 @@
|
||||||
WHERE ttrss_entries.id = ref_id AND
|
WHERE ttrss_entries.id = ref_id AND
|
||||||
marked = false AND
|
marked = false AND
|
||||||
feed_id = '$feed_id' AND
|
feed_id = '$feed_id' AND
|
||||||
|
$query_limit
|
||||||
ttrss_entries.date_entered < NOW() - INTERVAL '$purge_interval days'");
|
ttrss_entries.date_entered < NOW() - INTERVAL '$purge_interval days'");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -123,6 +143,7 @@
|
||||||
WHERE ttrss_entries.id = ref_id AND
|
WHERE ttrss_entries.id = ref_id AND
|
||||||
marked = false AND
|
marked = false AND
|
||||||
feed_id = '$feed_id' AND
|
feed_id = '$feed_id' AND
|
||||||
|
$query_limit
|
||||||
ttrss_entries.date_entered < DATE_SUB(NOW(), INTERVAL $purge_interval DAY)");
|
ttrss_entries.date_entered < DATE_SUB(NOW(), INTERVAL $purge_interval DAY)");
|
||||||
|
|
||||||
$rows = mysql_affected_rows($link);
|
$rows = mysql_affected_rows($link);
|
||||||
|
@ -185,6 +206,25 @@
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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) {
|
function purge_old_posts($link) {
|
||||||
|
|
||||||
$user_id = $_SESSION["uid"];
|
$user_id = $_SESSION["uid"];
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
require_once "functions.php";
|
require_once "functions.php";
|
||||||
|
|
||||||
define('EXPECTED_CONFIG_VERSION', 11);
|
define('EXPECTED_CONFIG_VERSION', 11);
|
||||||
define('SCHEMA_VERSION', 25);
|
define('SCHEMA_VERSION', 26);
|
||||||
|
|
||||||
if (!file_exists("config.php")) {
|
if (!file_exists("config.php")) {
|
||||||
print __("<b>Fatal Error</b>: You forgot to copy
|
print __("<b>Fatal Error</b>: You forgot to copy
|
||||||
|
|
|
@ -200,7 +200,7 @@ create table ttrss_tags (id integer primary key auto_increment,
|
||||||
|
|
||||||
create table ttrss_version (schema_version int not null) TYPE=InnoDB;
|
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,
|
create table ttrss_prefs_types (id integer not null primary key,
|
||||||
type_name varchar(100) not null) TYPE=InnoDB;
|
type_name varchar(100) not null) TYPE=InnoDB;
|
||||||
|
@ -304,6 +304,8 @@ insert into ttrss_prefs (pref_name,type_id,def_value,short_desc,section_id) valu
|
||||||
|
|
||||||
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('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 (
|
create table ttrss_user_prefs (
|
||||||
owner_uid integer not null,
|
owner_uid integer not null,
|
||||||
pref_name varchar(250),
|
pref_name varchar(250),
|
||||||
|
|
|
@ -179,7 +179,7 @@ create index ttrss_tags_owner_uid_index on ttrss_tags(owner_uid);
|
||||||
|
|
||||||
create table ttrss_version (schema_version int not null);
|
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,
|
create table ttrss_prefs_types (id integer not null primary key,
|
||||||
type_name varchar(100) not null);
|
type_name varchar(100) not null);
|
||||||
|
@ -279,6 +279,8 @@ insert into ttrss_prefs (pref_name,type_id,def_value,short_desc,section_id) valu
|
||||||
|
|
||||||
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('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 (
|
create table ttrss_user_prefs (
|
||||||
owner_uid integer not null references ttrss_users(id) ON DELETE CASCADE,
|
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,
|
pref_name varchar(250) not null references ttrss_prefs(pref_name) ON DELETE CASCADE,
|
||||||
|
|
3
schema/versions/mysql/26.sql
Normal file
3
schema/versions/mysql/26.sql
Normal file
|
@ -0,0 +1,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);
|
||||||
|
|
||||||
|
update ttrss_version set schema_version = 26;
|
3
schema/versions/pgsql/26.sql
Normal file
3
schema/versions/pgsql/26.sql
Normal file
|
@ -0,0 +1,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);
|
||||||
|
|
||||||
|
update ttrss_version set schema_version = 26;
|
Loading…
Reference in a new issue