summaryrefslogtreecommitdiff
path: root/modules/aggregator/aggregator.module
diff options
context:
space:
mode:
authorDries Buytaert <dries@buytaert.net>2006-06-20 09:44:52 +0000
committerDries Buytaert <dries@buytaert.net>2006-06-20 09:44:52 +0000
commitcbe0081a8c7e955870a374b5232a0f0487adb176 (patch)
tree59cf037ff3078f479b47c5fb7f1eec4d0f4bd18a /modules/aggregator/aggregator.module
parent0147fa3b757f92ebdcf95321db6042554b4422b3 (diff)
downloadbrdo-cbe0081a8c7e955870a374b5232a0f0487adb176.tar.gz
brdo-cbe0081a8c7e955870a374b5232a0f0487adb176.tar.bz2
- Patch #61433 by Steve Dondley: added support for GUIDs to prevent duplicate posts being inserted.
Diffstat (limited to 'modules/aggregator/aggregator.module')
-rw-r--r--modules/aggregator/aggregator.module17
1 files changed, 10 insertions, 7 deletions
diff --git a/modules/aggregator/aggregator.module b/modules/aggregator/aggregator.module
index 1625ad4e8..e9fe10d02 100644
--- a/modules/aggregator/aggregator.module
+++ b/modules/aggregator/aggregator.module
@@ -829,7 +829,7 @@ function aggregator_parse_feed(&$data, $feed) {
$items = array_reverse($items);
foreach ($items as $item) {
- unset($title, $link, $author, $description);
+ unset($title, $link, $author, $description, $guid);
// Prepare the item:
foreach ($item as $key => $value) {
@@ -856,8 +856,8 @@ function aggregator_parse_feed(&$data, $feed) {
if ($item['LINK']) {
$link = $item['LINK'];
}
- elseif ($item['GUID'] && (strncmp($item['GUID'], 'http://', 7) == 0)) {
- $link = $item['GUID'];
+ if ($item['GUID']) {
+ $guid = $item['GUID'];
}
else {
$link = $feed['link'];
@@ -902,14 +902,17 @@ function aggregator_parse_feed(&$data, $feed) {
** pass along it's ID such that we can update it if needed.
*/
- if ($link && $link != $feed['link'] && $link != $feed['url']) {
+ if ($guid) {
+ $entry = db_fetch_object(db_query("SELECT iid FROM {aggregator_item} WHERE fid = %d AND guid = '%s'", $feed['fid'], $guid));
+ }
+ else if ($link && $link != $feed['link'] && $link != $feed['url']) {
$entry = db_fetch_object(db_query("SELECT iid FROM {aggregator_item} WHERE fid = %d AND link = '%s'", $feed['fid'], $link));
}
else {
$entry = db_fetch_object(db_query("SELECT iid FROM {aggregator_item} WHERE fid = %d AND title = '%s'", $feed['fid'], $title));
}
- aggregator_save_item(array('iid' => $entry->iid, 'fid' => $feed['fid'], 'timestamp' => $timestamp, 'title' => $title, 'link' => $link, 'author' => $item['AUTHOR'], 'description' => $item['DESCRIPTION']));
+ aggregator_save_item(array('iid' => $entry->iid, 'fid' => $feed['fid'], 'timestamp' => $timestamp, 'title' => $title, 'link' => $link, 'author' => $item['AUTHOR'], 'description' => $item['DESCRIPTION'], 'guid' => $guid));
}
/*
@@ -933,7 +936,7 @@ function aggregator_parse_feed(&$data, $feed) {
function aggregator_save_item($edit) {
if ($edit['iid'] && $edit['title']) {
- db_query("UPDATE {aggregator_item} SET title = '%s', link = '%s', author = '%s', description = '%s' WHERE iid = %d", $edit['title'], $edit['link'], $edit['author'], $edit['description'], $edit['iid']);
+ db_query("UPDATE {aggregator_item} SET title = '%s', link = '%s', author = '%s', description = '%s', guid = '%s' WHERE iid = %d", $edit['title'], $edit['link'], $edit['author'], $edit['description'], $edit['iid'], $edit['gid']);
}
else if ($edit['iid']) {
db_query('DELETE FROM {aggregator_item} WHERE iid = %d', $edit['iid']);
@@ -941,7 +944,7 @@ function aggregator_save_item($edit) {
}
else if ($edit['title'] && $edit['link']) {
$edit['iid'] = db_next_id('{aggregator_item}_iid');
- db_query("INSERT INTO {aggregator_item} (iid, fid, title, link, author, description, timestamp) VALUES (%d, %d, '%s', '%s', '%s', '%s', %d)", $edit['iid'], $edit['fid'], $edit['title'], $edit['link'], $edit['author'], $edit['description'], $edit['timestamp']);
+ db_query("INSERT INTO {aggregator_item} (iid, fid, title, link, author, description, timestamp, guid) VALUES (%d, %d, '%s', '%s', '%s', '%s', %d, '%s')", $edit['iid'], $edit['fid'], $edit['title'], $edit['link'], $edit['author'], $edit['description'], $edit['timestamp'], $edit['guid']);
// file the items in the categories indicated by the feed
$categories = db_query('SELECT cid FROM {aggregator_category_feed} WHERE fid = %d', $edit['fid']);
while ($category = db_fetch_object($categories)) {