new option: MARK_UNREAD_ON_UPDATE (closes #76)

This commit is contained in:
Andrew Dolgov 2006-07-25 09:11:13 +01:00
parent ee09766cf7
commit 4919fb42c9
4 changed files with 32 additions and 8 deletions

View file

@ -16,7 +16,7 @@
$op = $_REQUEST["op"]; $op = $_REQUEST["op"];
define('SCHEMA_VERSION', 8); define('SCHEMA_VERSION', 9);
require_once "sanity_check.php"; require_once "sanity_check.php";
require_once "config.php"; require_once "config.php";

View file

@ -676,8 +676,13 @@
num_comments = '$num_comments' num_comments = '$num_comments'
WHERE id = '$ref_id'"); WHERE id = '$ref_id'");
db_query($link, "UPDATE ttrss_user_entries if (get_pref($link, "MARK_UNREAD_ON_UPDATE")) {
SET last_read = null WHERE ref_id = '$ref_id' AND unread = false"); db_query($link, "UPDATE ttrss_user_entries
SET last_read = null, unread = true WHERE ref_id = '$ref_id'");
} else {
db_query($link, "UPDATE ttrss_user_entries
SET last_read = null WHERE ref_id = '$ref_id' AND unread = false");
}
} }
} }
@ -1413,7 +1418,7 @@
$result = db_query($link, "SELECT COUNT(int_id) AS unread $result = db_query($link, "SELECT COUNT(int_id) AS unread
FROM ttrss_user_entries FROM ttrss_user_entries
WHERE unread = true AND $match_part AND owner_uid = " . $_SESSION["uid"]); WHERE unread = true AND ($match_part) AND owner_uid = " . $_SESSION["uid"]);
$unread = 0; $unread = 0;
@ -1433,11 +1438,13 @@
return getCategoryUnread($link, $n_feed); return getCategoryUnread($link, $n_feed);
} else if ($n_feed == -1) { } else if ($n_feed == -1) {
$match_part = "marked = true"; $match_part = "marked = true";
} else if ($feed > 0) { } else if ($n_feed > 0) {
$result = db_query($link, "SELECT id FROM ttrss_feeds WHERE parent_feed = '$n_feed'"); $result = db_query($link, "SELECT id FROM ttrss_feeds WHERE parent_feed = '$n_feed'
AND owner_uid = " . $_SESSION["uid"]);
if (db_num_rows($result) > 0) { if (db_num_rows($result) > 0) {
$linked_feeds = array(); $linked_feeds = array();
while ($line = db_fetch_assoc($result)) { while ($line = db_fetch_assoc($result)) {
array_push($linked_feeds, "feed_id = " . $line["id"]); array_push($linked_feeds, "feed_id = " . $line["id"]);
@ -1445,6 +1452,19 @@
$match_part = implode(" OR ", $linked_feeds); $match_part = implode(" OR ", $linked_feeds);
$result = db_query($link, "SELECT COUNT(int_id) AS unread
FROM ttrss_user_entries
WHERE unread = true AND ($match_part) AND owner_uid = " . $_SESSION["uid"]);
$unread = 0;
# this needs to be rewritten
while ($line = db_fetch_assoc($result)) {
$unread += $line["unread"];
}
return $unread;
} else { } else {
$match_part = "feed_id = '$n_feed'"; $match_part = "feed_id = '$n_feed'";
} }

View file

@ -179,7 +179,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 (8); insert into ttrss_version values (9);
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;
@ -251,6 +251,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('EXTENDED_FEEDLIST', 1, 'false', 'Show additional information in feedlist',2); insert into ttrss_prefs (pref_name,type_id,def_value,short_desc,section_id) values('EXTENDED_FEEDLIST', 1, 'false', 'Show additional information in feedlist',2);
insert into ttrss_prefs (pref_name,type_id,def_value,short_desc,section_id) values('MARK_UNREAD_ON_UPDATE', 1, 'false', 'Set articles as unread on update',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),

View file

@ -163,7 +163,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 (8); insert into ttrss_version values (9);
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);
@ -231,6 +231,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('EXTENDED_FEEDLIST', 1, 'false', 'Show additional information in feedlist',2); insert into ttrss_prefs (pref_name,type_id,def_value,short_desc,section_id) values('EXTENDED_FEEDLIST', 1, 'false', 'Show additional information in feedlist',2);
insert into ttrss_prefs (pref_name,type_id,def_value,short_desc,section_id) values('MARK_UNREAD_ON_UPDATE', 1, 'false', 'Set articles as unread on update',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,