function aggregator_save_feed
Add/edit/delete an aggregator feed.
Parameters
$edit: An associative array describing the feed to be added/edited/deleted.
3 calls to aggregator_save_feed()
- AggregatorRenderingTestCase::testBlockLinks in modules/
aggregator/ aggregator.test - Adds a feed block to the page and checks its links.
- aggregator_form_feed_submit in modules/
aggregator/ aggregator.admin.inc - Form submission handler for aggregator_form_feed().
- CategorizeFeedTestCase::testCategorizeFeed in modules/
aggregator/ aggregator.test - Creates a feed and makes sure you can add/delete categories to it.
File
-
modules/
aggregator/ aggregator.module, line 499
Code
function aggregator_save_feed($edit) {
if (!empty($edit['fid'])) {
// An existing feed is being modified, delete the category listings.
db_delete('aggregator_category_feed')->condition('fid', $edit['fid'])
->execute();
}
if (!empty($edit['fid']) && !empty($edit['title'])) {
db_update('aggregator_feed')->condition('fid', $edit['fid'])
->fields(array(
'title' => $edit['title'],
'url' => $edit['url'],
'refresh' => $edit['refresh'],
'block' => $edit['block'],
))
->execute();
}
elseif (!empty($edit['fid'])) {
$iids = db_query('SELECT iid FROM {aggregator_item} WHERE fid = :fid', array(
':fid' => $edit['fid'],
))->fetchCol();
if ($iids) {
db_delete('aggregator_category_item')->condition('iid', $iids, 'IN')
->execute();
}
db_delete('aggregator_feed')->condition('fid', $edit['fid'])
->execute();
db_delete('aggregator_item')->condition('fid', $edit['fid'])
->execute();
// Make sure there is no active block for this feed.
if (module_exists('block')) {
db_delete('block')->condition('module', 'aggregator')
->condition('delta', 'feed-' . $edit['fid'])
->execute();
}
}
elseif (!empty($edit['title'])) {
$edit['fid'] = db_insert('aggregator_feed')->fields(array(
'title' => $edit['title'],
'url' => $edit['url'],
'refresh' => $edit['refresh'],
'block' => $edit['block'],
'link' => '',
'description' => '',
'image' => '',
))
->execute();
}
if (!empty($edit['title'])) {
// The feed is being saved, save the categories as well.
if (!empty($edit['category'])) {
foreach ($edit['category'] as $cid => $value) {
if ($value) {
db_insert('aggregator_category_feed')->fields(array(
'fid' => $edit['fid'],
'cid' => $cid,
))
->execute();
}
}
}
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.