initial split ttrss_entries work
This commit is contained in:
parent
0bc694bfe4
commit
4c193675d0
56
backend.php
56
backend.php
|
@ -50,15 +50,18 @@
|
||||||
/* FIXME this needs reworking */
|
/* FIXME this needs reworking */
|
||||||
|
|
||||||
function getGlobalCounters($link) {
|
function getGlobalCounters($link) {
|
||||||
$result = db_query($link, "SELECT count(id) as c_id FROM ttrss_entries
|
$result = db_query($link, "SELECT count(id) as c_id FROM ttrss_entries,ttrss_user_entries
|
||||||
WHERE unread = true AND owner_uid = " . $_SESSION["uid"]);
|
WHERE unread = true AND
|
||||||
|
ttrss_user_entries.ref_id = ttrss_entries.id AND
|
||||||
|
owner_uid = " . $_SESSION["uid"]);
|
||||||
$c_id = db_fetch_result($result, 0, "c_id");
|
$c_id = db_fetch_result($result, 0, "c_id");
|
||||||
print "<counter id='global-unread' counter='$c_id'/>";
|
print "<counter id='global-unread' counter='$c_id'/>";
|
||||||
}
|
}
|
||||||
|
|
||||||
function getTagCounters($link) {
|
function getTagCounters($link) {
|
||||||
$result = db_query($link, "SELECT tag_name,count(ttrss_entries.id) AS count
|
$result = db_query($link, "SELECT tag_name,count(ttrss_entries.id) AS count
|
||||||
FROM ttrss_tags,ttrss_entries WHERE
|
FROM ttrss_tags,ttrss_entries,ttrss_user_entries WHERE
|
||||||
|
ttrss_user_entries.ref_id = ttrss_entries.id AND
|
||||||
ttrss_tags.owner_uid = ".$_SESSION["uid"]." AND
|
ttrss_tags.owner_uid = ".$_SESSION["uid"]." AND
|
||||||
post_id = ttrss_entries.id AND unread = true GROUP BY tag_name
|
post_id = ttrss_entries.id AND unread = true GROUP BY tag_name
|
||||||
UNION
|
UNION
|
||||||
|
@ -81,8 +84,9 @@
|
||||||
|
|
||||||
function getLabelCounters($link) {
|
function getLabelCounters($link) {
|
||||||
|
|
||||||
$result = db_query($link, "SELECT count(id) as count FROM ttrss_entries
|
$result = db_query($link, "SELECT count(id) as count FROM ttrss_entries,ttrss_user_entries
|
||||||
WHERE marked = true AND unread = true AND owner_uid = ".$_SESSION["uid"]);
|
WHERE marked = true AND ttrss_user_entries.ref_id = ttrss_entries.id AND
|
||||||
|
unread = true AND owner_uid = ".$_SESSION["uid"]);
|
||||||
|
|
||||||
$count = db_fetch_result($result, 0, "count");
|
$count = db_fetch_result($result, 0, "count");
|
||||||
|
|
||||||
|
@ -97,8 +101,9 @@
|
||||||
|
|
||||||
error_reporting (0);
|
error_reporting (0);
|
||||||
|
|
||||||
$tmp_result = db_query($link, "SELECT count(id) as count FROM ttrss_entries
|
$tmp_result = db_query($link, "SELECT count(id) as count FROM ttrss_user_entries,ttrss_entries
|
||||||
WHERE (" . $line["sql_exp"] . ") AND unread = true AND
|
WHERE (" . $line["sql_exp"] . ") AND unread = true AND
|
||||||
|
ttrss_user_entries.ref_id = ttrss_entries.id AND
|
||||||
owner_uid = ".$_SESSION["uid"]);
|
owner_uid = ".$_SESSION["uid"]);
|
||||||
|
|
||||||
$count = db_fetch_result($tmp_result, 0, "count");
|
$count = db_fetch_result($tmp_result, 0, "count");
|
||||||
|
@ -113,8 +118,9 @@
|
||||||
function getFeedCounter($link, $id) {
|
function getFeedCounter($link, $id) {
|
||||||
|
|
||||||
$result = db_query($link, "SELECT
|
$result = db_query($link, "SELECT
|
||||||
count(id) as count FROM ttrss_entries
|
count(id) as count FROM ttrss_entries,ttrss_user_entries
|
||||||
WHERE feed_id = '$id' AND unread = true");
|
WHERE feed_id = '$id' AND unread = true
|
||||||
|
AND ttrss_user_entries.ref_id = ttrss_entries.id");
|
||||||
|
|
||||||
$count = db_fetch_result($result, 0, "count");
|
$count = db_fetch_result($result, 0, "count");
|
||||||
|
|
||||||
|
@ -124,7 +130,9 @@
|
||||||
function getFeedCounters($link) {
|
function getFeedCounters($link) {
|
||||||
|
|
||||||
$result = db_query($link, "SELECT id,
|
$result = db_query($link, "SELECT id,
|
||||||
(SELECT count(id) FROM ttrss_entries WHERE feed_id = ttrss_feeds.id
|
(SELECT count(id)
|
||||||
|
FROM ttrss_entries,ttrss_user_entries
|
||||||
|
WHERE feed_id = ttrss_feeds.id AND ttrss_user_entries.ref_id = ttrss_entries.id
|
||||||
AND unread = true AND owner_uid = ".$_SESSION["uid"].") as count
|
AND unread = true AND owner_uid = ".$_SESSION["uid"].") as count
|
||||||
FROM ttrss_feeds WHERE owner_uid = ".$_SESSION["uid"]);
|
FROM ttrss_feeds WHERE owner_uid = ".$_SESSION["uid"]);
|
||||||
|
|
||||||
|
@ -165,7 +173,10 @@
|
||||||
/* virtual feeds */
|
/* virtual feeds */
|
||||||
|
|
||||||
$result = db_query($link, "SELECT count(id) as num_starred
|
$result = db_query($link, "SELECT count(id) as num_starred
|
||||||
FROM ttrss_entries WHERE marked = true AND unread = true AND owner_uid = '$owner_uid'");
|
FROM ttrss_entries,ttrss_user_entries
|
||||||
|
WHERE marked = true AND
|
||||||
|
ttrss_user_entries.ref_id = ttrss_entries.id AND
|
||||||
|
unread = true AND owner_uid = '$owner_uid'");
|
||||||
$num_starred = db_fetch_result($result, 0, "num_starred");
|
$num_starred = db_fetch_result($result, 0, "num_starred");
|
||||||
|
|
||||||
$class = "virt";
|
$class = "virt";
|
||||||
|
@ -188,8 +199,9 @@
|
||||||
|
|
||||||
error_reporting (0);
|
error_reporting (0);
|
||||||
|
|
||||||
$tmp_result = db_query($link, "SELECT count(id) as count FROM ttrss_entries
|
$tmp_result = db_query($link, "SELECT count(id) as count FROM ttrss_entries,ttrss_user_entries
|
||||||
WHERE (" . $line["sql_exp"] . ") AND unread = true
|
WHERE (" . $line["sql_exp"] . ") AND unread = true AND
|
||||||
|
ttrss_user_entries.ref_id = ttrss_entries.id
|
||||||
AND owner_uid = '$owner_uid'");
|
AND owner_uid = '$owner_uid'");
|
||||||
|
|
||||||
$count = db_fetch_result($tmp_result, 0, "count");
|
$count = db_fetch_result($tmp_result, 0, "count");
|
||||||
|
@ -211,10 +223,13 @@
|
||||||
print "<li><hr></li>";
|
print "<li><hr></li>";
|
||||||
|
|
||||||
$result = db_query($link, "SELECT *,
|
$result = db_query($link, "SELECT *,
|
||||||
(SELECT count(id) FROM ttrss_entries
|
(SELECT count(id) FROM ttrss_entries,ttrss_user_entries
|
||||||
WHERE feed_id = ttrss_feeds.id AND owner_uid = '$owner_uid') AS total,
|
WHERE feed_id = ttrss_feeds.id AND
|
||||||
(SELECT count(id) FROM ttrss_entries
|
ttrss_user_entries.ref_id = ttrss_entries.id AND
|
||||||
|
owner_uid = '$owner_uid') AS total,
|
||||||
|
(SELECT count(id) FROM ttrss_entries,ttrss_user_entries
|
||||||
WHERE feed_id = ttrss_feeds.id AND unread = true
|
WHERE feed_id = ttrss_feeds.id AND unread = true
|
||||||
|
AND ttrss_user_entries.ref_id = ttrss_entries.id
|
||||||
AND owner_uid = '$owner_uid') as unread
|
AND owner_uid = '$owner_uid') as unread
|
||||||
FROM ttrss_feeds WHERE owner_uid = '$owner_uid' ORDER BY title");
|
FROM ttrss_feeds WHERE owner_uid = '$owner_uid' ORDER BY title");
|
||||||
|
|
||||||
|
@ -431,14 +446,16 @@
|
||||||
$id = $_GET["id"];
|
$id = $_GET["id"];
|
||||||
$feed_id = $_GET["feed"];
|
$feed_id = $_GET["feed"];
|
||||||
|
|
||||||
$result = db_query($link, "UPDATE ttrss_entries SET unread = false,last_read = NOW() WHERE id = '$id'");
|
$result = db_query($link, "UPDATE ttrss_user_entries
|
||||||
|
SET unread = false,last_read = NOW()
|
||||||
|
WHERE ref_id = '$id' AND feed_id = '$feed_id' AND owner_uid = " . $_SESSION["uid"]);
|
||||||
|
|
||||||
$addheader = $_GET["addheader"];
|
$addheader = $_GET["addheader"];
|
||||||
|
|
||||||
$result = db_query($link, "SELECT title,link,content,feed_id,comments,
|
$result = db_query($link, "SELECT title,link,content,feed_id,comments,
|
||||||
(SELECT icon_url FROM ttrss_feeds WHERE id = feed_id) as icon_url
|
(SELECT icon_url FROM ttrss_feeds WHERE id = feed_id) as icon_url
|
||||||
FROM ttrss_entries
|
FROM ttrss_entries,ttrss_user_entries
|
||||||
WHERE id = '$id'");
|
WHERE id = '$id' AND ref_id = id");
|
||||||
|
|
||||||
if ($addheader) {
|
if ($addheader) {
|
||||||
print "<html><head>
|
print "<html><head>
|
||||||
|
@ -678,8 +695,9 @@
|
||||||
$vfeed_query_part
|
$vfeed_query_part
|
||||||
SUBSTRING(updated,1,19) as updated_noms
|
SUBSTRING(updated,1,19) as updated_noms
|
||||||
FROM
|
FROM
|
||||||
ttrss_entries
|
ttrss_entries,ttrss_user_entries
|
||||||
WHERE
|
WHERE
|
||||||
|
ttrss_user_entries.ref_id = ttrss_entries.id AND
|
||||||
owner_uid = '".$_SESSION["uid"]."' AND
|
owner_uid = '".$_SESSION["uid"]."' AND
|
||||||
$search_query_part
|
$search_query_part
|
||||||
$view_query_part
|
$view_query_part
|
||||||
|
|
|
@ -4,13 +4,12 @@
|
||||||
require_once 'config.php';
|
require_once 'config.php';
|
||||||
require_once 'db-prefs.php';
|
require_once 'db-prefs.php';
|
||||||
|
|
||||||
// $_SESSION["uid"] = PLACEHOLDER_UID; // FIXME: placeholder
|
|
||||||
// $_SESSION["name"] = PLACEHOLDER_NAME;
|
|
||||||
|
|
||||||
define('MAGPIE_OUTPUT_ENCODING', 'UTF-8');
|
define('MAGPIE_OUTPUT_ENCODING', 'UTF-8');
|
||||||
|
|
||||||
function purge_feed($link, $feed_id, $purge_interval) {
|
function purge_feed($link, $feed_id, $purge_interval) {
|
||||||
|
|
||||||
|
return; // FIXME disabled for now
|
||||||
|
|
||||||
if (DB_TYPE == "pgsql") {
|
if (DB_TYPE == "pgsql") {
|
||||||
db_query($link, "DELETE FROM ttrss_entries WHERE
|
db_query($link, "DELETE FROM ttrss_entries WHERE
|
||||||
marked = false AND feed_id = '$feed_id' AND
|
marked = false AND feed_id = '$feed_id' AND
|
||||||
|
@ -262,7 +261,75 @@
|
||||||
|
|
||||||
$entry_guid = db_escape_string($entry_guid);
|
$entry_guid = db_escape_string($entry_guid);
|
||||||
|
|
||||||
$result = db_query($link, "
|
$result = db_query($link, "SELECT id FROM ttrss_entries WHERE guid = '$entry_guid'");
|
||||||
|
|
||||||
|
$owner_uid = $_SESSION["uid"];
|
||||||
|
|
||||||
|
if (db_num_rows($result) == 0) {
|
||||||
|
|
||||||
|
// base post entry does not exist, create it
|
||||||
|
|
||||||
|
error_reporting(0);
|
||||||
|
if (is_filtered($entry_title, $entry_content, $filters)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
error_reporting (E_ERROR | E_WARNING | E_PARSE);
|
||||||
|
|
||||||
|
$entry_content = db_escape_string($entry_content);
|
||||||
|
$entry_title = db_escape_string($entry_title);
|
||||||
|
$entry_link = db_escape_string($entry_link);
|
||||||
|
$entry_comments = db_escape_string($entry_comments);
|
||||||
|
|
||||||
|
$result = db_query($link,
|
||||||
|
"INSERT INTO ttrss_entries
|
||||||
|
(title,
|
||||||
|
guid,
|
||||||
|
link,
|
||||||
|
updated,
|
||||||
|
content,
|
||||||
|
content_hash,
|
||||||
|
no_orig_date,
|
||||||
|
date_entered,
|
||||||
|
comments)
|
||||||
|
VALUES
|
||||||
|
('$entry_title',
|
||||||
|
'$entry_guid',
|
||||||
|
'$entry_link',
|
||||||
|
'$entry_timestamp_fmt',
|
||||||
|
'$entry_content',
|
||||||
|
'$content_hash',
|
||||||
|
$no_orig_date,
|
||||||
|
NOW(),
|
||||||
|
'$entry_comments')");
|
||||||
|
}
|
||||||
|
|
||||||
|
// now it should exist, if not - bad luck then
|
||||||
|
|
||||||
|
$result = db_query($link, "SELECT id FROM ttrss_entries WHERE guid = '$entry_guid'");
|
||||||
|
|
||||||
|
if (db_num_rows($result) == 1) {
|
||||||
|
|
||||||
|
$ref_id = db_fetch_result($result, 0, "id");
|
||||||
|
|
||||||
|
// check for user post link to main table
|
||||||
|
|
||||||
|
$result = db_query($link,
|
||||||
|
"SELECT ref_id FROM ttrss_user_entries WHERE
|
||||||
|
ref_id = '$ref_id' AND owner_uid = '$owner_uid' AND feed_id = '$feed'");
|
||||||
|
|
||||||
|
// okay it doesn't exist - create user entry
|
||||||
|
|
||||||
|
if (db_num_rows($result) == 0) {
|
||||||
|
|
||||||
|
$result = db_query($link,
|
||||||
|
"INSERT INTO ttrss_user_entries
|
||||||
|
(ref_id, owner_uid, feed_id)
|
||||||
|
VALUES ('$ref_id', '$owner_uid', '$feed')");
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* $result = db_query($link, "
|
||||||
SELECT
|
SELECT
|
||||||
id,last_read,no_orig_date,title,feed_id,content_hash,
|
id,last_read,no_orig_date,title,feed_id,content_hash,
|
||||||
substring(updated,1,19) as updated
|
substring(updated,1,19) as updated
|
||||||
|
@ -273,8 +340,6 @@
|
||||||
owner_uid = " . $_SESSION["uid"]." AND
|
owner_uid = " . $_SESSION["uid"]." AND
|
||||||
feed_id = '$feed'");
|
feed_id = '$feed'");
|
||||||
|
|
||||||
// print db_num_rows($result) . "$entry_guid<br/>";
|
|
||||||
|
|
||||||
if (db_num_rows($result) == 0) {
|
if (db_num_rows($result) == 0) {
|
||||||
|
|
||||||
error_reporting(0);
|
error_reporting(0);
|
||||||
|
@ -379,12 +444,12 @@
|
||||||
|
|
||||||
$result = db_query($link, $query);
|
$result = db_query($link, $query);
|
||||||
}
|
}
|
||||||
}
|
} */
|
||||||
|
|
||||||
/* taaaags */
|
/* taaaags */
|
||||||
// <a href="http://technorati.com/tag/Xorg" rel="tag">Xorg</a>, //
|
// <a href="http://technorati.com/tag/Xorg" rel="tag">Xorg</a>, //
|
||||||
|
|
||||||
$entry_tags = null;
|
/* $entry_tags = null;
|
||||||
|
|
||||||
preg_match_all("/<a.*?rel=.tag.*?>([^>]+)<\/a>/i", $entry_content,
|
preg_match_all("/<a.*?rel=.tag.*?>([^>]+)<\/a>/i", $entry_content,
|
||||||
$entry_tags);
|
$entry_tags);
|
||||||
|
@ -423,7 +488,7 @@
|
||||||
VALUES ('".$_SESSION["uid"]."','$tag', '$entry_id')");
|
VALUES ('".$_SESSION["uid"]."','$tag', '$entry_id')");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
} */
|
||||||
}
|
}
|
||||||
|
|
||||||
db_query($link, "UPDATE ttrss_feeds
|
db_query($link, "UPDATE ttrss_feeds
|
||||||
|
|
|
@ -37,7 +37,6 @@ insert into ttrss_feeds (owner_uid,title,feed_url) values (1,'Technocrat.net',
|
||||||
'http://syndication.technocrat.net/rss');
|
'http://syndication.technocrat.net/rss');
|
||||||
|
|
||||||
create table ttrss_entries (id serial not null primary key,
|
create table ttrss_entries (id serial not null primary key,
|
||||||
feed_id int references ttrss_feeds(id) ON DELETE CASCADE not null,
|
|
||||||
title text not null,
|
title text not null,
|
||||||
guid text not null unique,
|
guid text not null unique,
|
||||||
link text not null,
|
link text not null,
|
||||||
|
@ -49,7 +48,8 @@ create table ttrss_entries (id serial not null primary key,
|
||||||
comments varchar(250) not null default '');
|
comments varchar(250) not null default '');
|
||||||
|
|
||||||
create table ttrss_user_entries (
|
create table ttrss_user_entries (
|
||||||
id integer unique not null references ttrss_entries(id) ON DELETE CASCADE,
|
ref_id integer not null references ttrss_entries(id) ON DELETE CASCADE,
|
||||||
|
feed_id int references ttrss_feeds(id) ON DELETE CASCADE not null,
|
||||||
owner_uid integer not null references ttrss_users(id) ON DELETE CASCADE,
|
owner_uid integer not null references ttrss_users(id) ON DELETE CASCADE,
|
||||||
marked boolean not null default false,
|
marked boolean not null default false,
|
||||||
last_read timestamp,
|
last_read timestamp,
|
||||||
|
|
Loading…
Reference in New Issue