aggregator_save_category

Versions
4.6 – 7
aggregator_save_category($edit)

Add/edit/delete aggregator categories.

Parameters

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

Code

modules/aggregator/aggregator.module, line 373

<?php
function aggregator_save_category($edit) {
  $link_path = 'aggregator/categories/';
  if (!empty($edit['cid'])) {
    $link_path .= $edit['cid'];
    if (!empty($edit['title'])) {
      db_query("UPDATE {aggregator_category} SET title = '%s', description = '%s' WHERE cid = %d", $edit['title'], $edit['description'], $edit['cid']);
      $op = 'update';
    }
    else {
      db_query('DELETE FROM {aggregator_category} WHERE cid = %d', $edit['cid']);
      // Make sure there is no active block for this category.
      db_query("DELETE FROM {blocks} WHERE module = '%s' AND delta = '%s'", 'aggregator', 'category-' . $edit['cid']);
      $edit['title'] = '';
      $op = 'delete';
    }
  }
  else if (!empty($edit['title'])) {
    // A single unique id for bundles and feeds, to use in blocks
    db_query("INSERT INTO {aggregator_category} (title, description, block) VALUES ('%s', '%s', 5)", $edit['title'], $edit['description']);
    $link_path .= db_last_insert_id('aggregator_category', 'cid');
    $op = 'insert';
  }
  if (isset($op)) {
    menu_link_maintain('aggregator', $op, $link_path, $edit['title']);
  }
}
?>
Login or register to post comments
 
 

All source code and documentation on this site is released under the terms of the GNU General Public License, version 2 and later. Drupal is a registered trademark of Dries Buytaert.