function aggregator_save_category

aggregator_save_category($edit)

Adds/edits/deletes aggregator categories.

Parameters

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

File

modules/aggregator/aggregator.module, line 440
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.
      if (module_exists('block')) {
        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']);
  }
}

© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/modules!aggregator!aggregator.module/function/aggregator_save_category/7.x