create_published_article: check for duplicate URLs

This commit is contained in:
Andrew Dolgov 2012-09-15 19:44:33 +04:00
parent c6c010d98a
commit 71b6a2360e
1 changed files with 34 additions and 12 deletions

View File

@ -5617,6 +5617,29 @@
if (filter_var($url, FILTER_VALIDATE_URL) === FALSE) return false;
$result = db_query($link, "SELECT id FROM ttrss_entries WHERE
link = '$url' LIMIT 1");
if (db_num_rows($result) != 0) {
$ref_id = db_fetch_result($result, 0, "id");
$result = db_query($link, "SELECT int_id FROM ttrss_user_entries WHERE
ref_id = '$ref_id' AND owner_uid = '$owner_uid'");
if (db_num_rows($result) != 0) {
db_query($link, "UPDATE ttrss_user_entries SET published = true WHERE
ref_id = '$ref_id' AND owner_uid = '$owner_uid'");
} else {
db_query($link, "INSERT INTO ttrss_user_entries
(ref_id, uuid, feed_id, orig_feed_id, owner_uid, published, tag_cache, label_cache, last_read, note, unread)
VALUES
('$ref_id', '', NULL, NULL, $owner_uid, true, '', '', NOW(), '', false)");
}
return true;
} else {
$result = db_query($link, "INSERT INTO ttrss_entries
(title, guid, link, updated, content, content_hash, date_entered, date_updated)
VALUES
@ -5633,10 +5656,9 @@
('$ref_id', '', NULL, NULL, $owner_uid, true, '', '', NOW(), '', false)");
return true;
}
return false;
}
}
?>