function aggregator_save_feed

cis7 aggregator.module aggregator_save_feed($edit)
cle7 aggregator.module aggregator_save_feed($edit)
elmsmedia7 aggregator.module aggregator_save_feed($edit)
icor7 aggregator.module aggregator_save_feed($edit)
meedjum_blog7 aggregator.module aggregator_save_feed($edit)
mooc7 aggregator.module aggregator_save_feed($edit)

Add/edit/delete an aggregator feed.

Parameters

$edit: An associative array describing the feed to be added/edited/deleted.

1 call to aggregator_save_feed()
aggregator_form_feed_submit in modules/aggregator/aggregator.admin.inc
Form submission handler for aggregator_form_feed().

File

modules/aggregator/aggregator.module, line 491
Used to aggregate syndicated content (RSS, RDF, and Atom).

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();
        }
      }
    }
  }
}