function aggregator_save_item

7.x aggregator.processor.inc aggregator_save_item($edit)
6.x aggregator.module aggregator_save_item($edit)

Adds/edits/deletes an aggregator item.

Parameters

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

1 call to aggregator_save_item()
aggregator_aggregator_process in drupal-7.x/modules/aggregator/aggregator.processor.inc
Implements hook_aggregator_process().

File

drupal-7.x/modules/aggregator/aggregator.processor.inc, line 151
Processor functions for the aggregator module.

Code

function aggregator_save_item($edit) {
  if ($edit['title'] && empty($edit['iid'])) {
    $edit['iid'] = db_insert('aggregator_item')
      ->fields(array(
        'title' => $edit['title'],
        'link' => $edit['link'],
        'author' => $edit['author'],
        'description' => $edit['description'],
        'guid' => $edit['guid'],
        'timestamp' => $edit['timestamp'],
        'fid' => $edit['fid'],
      ))
      ->execute();
  }
  if ($edit['iid'] && !$edit['title']) {
    db_delete('aggregator_item')
      ->condition('iid', $edit['iid'])
      ->execute();
    db_delete('aggregator_category_item')
      ->condition('iid', $edit['iid'])
      ->execute();
  }
  elseif ($edit['title'] && $edit['link']) {
    // file the items in the categories indicated by the feed
    $result = db_query('SELECT cid FROM {aggregator_category_feed} WHERE fid = :fid', array(':fid' => $edit['fid']));
    foreach ($result as $category) {
      db_merge('aggregator_category_item')
        ->key(array(
          'iid' => $edit['iid'],
          'cid' => $category->cid,
        ))
        ->execute();
    }
  }
}