function aggregator_save_item in Drupal 6
Same name and namespace in other branches
- 4 modules/aggregator.module \aggregator_save_item()
- 5 modules/aggregator/aggregator.module \aggregator_save_item()
- 7 modules/aggregator/aggregator.processor.inc \aggregator_save_item()
Add/edit/delete an aggregator item.
Parameters
$edit: An associative array describing the item to be added/edited/deleted.
1 call to aggregator_save_item()
- aggregator_parse_feed in modules/
aggregator/ aggregator.module - Parse a feed and store its items.
File
- modules/
aggregator/ aggregator.module, line 840 - Used to aggregate syndicated content (RSS, RDF, and Atom).
Code
function aggregator_save_item($edit) {
if ($edit['iid'] && $edit['title']) {
db_query("UPDATE {aggregator_item} SET title = '%s', link = '%s', author = '%s', description = '%s', guid = '%s', timestamp = %d WHERE iid = %d", $edit['title'], $edit['link'], $edit['author'], $edit['description'], $edit['guid'], $edit['timestamp'], $edit['iid']);
}
else {
if ($edit['iid']) {
db_query('DELETE FROM {aggregator_item} WHERE iid = %d', $edit['iid']);
db_query('DELETE FROM {aggregator_category_item} WHERE iid = %d', $edit['iid']);
}
else {
if ($edit['title'] && $edit['link']) {
db_query("INSERT INTO {aggregator_item} (fid, title, link, author, description, timestamp, guid) VALUES (%d, '%s', '%s', '%s', '%s', %d, '%s')", $edit['fid'], $edit['title'], $edit['link'], $edit['author'], $edit['description'], $edit['timestamp'], $edit['guid']);
$edit['iid'] = db_last_insert_id('aggregator_item', 'iid');
// 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)) {
db_query('INSERT INTO {aggregator_category_item} (cid, iid) VALUES (%d, %d)', $category->cid, $edit['iid']);
}
}
}
}
}