Skip navigation
Help

aggregator_save_category

6 aggregator.module aggregator_save_category($edit)
7 aggregator.module aggregator_save_category($edit)

Add/edit/delete aggregator categories.

Parameters

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

1 call to aggregator_save_category()

File

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

Code

function aggregator_save_category($edit) {
  $link_path = 'aggregator/categories/';
  if (!empty($edit['cid'])) {
    $link_path .= $edit['cid'];
    if (!empty($edit['title'])) {
      db_merge('aggregator_category')
        ->key(array('cid' => $edit['cid']))
        ->fields(array(
        'title' => $edit['title'], 
        'description' => $edit['description'],
      ))
        ->execute();
      $op = 'update';
    }
    else {
      db_delete('aggregator_category')
        ->condition('cid', $edit['cid'])
        ->execute();
      // Make sure there is no active block for this category.
      db_delete('block')
        ->condition('module', 'aggregator')
        ->condition('delta', 'category-' . $edit['cid'])
        ->execute();
      $edit['title'] = '';
      $op = 'delete';
    }
  }
  elseif (!empty($edit['title'])) {
    // A single unique id for bundles and feeds, to use in blocks.
    $link_path .= db_insert('aggregator_category')
      ->fields(array(
      'title' => $edit['title'], 
      'description' => $edit['description'], 
      'block' => 5,
    ))
      ->execute();
    $op = 'insert';
  }
  if (isset($op)) {
    menu_link_maintain('aggregator', $op, $link_path, $edit['title']);
  }
}