function aggregator_save_category
Adds/edits/deletes aggregator categories.
Parameters
$edit: An associative array describing the category to be added/edited/deleted.
3 calls to aggregator_save_category()
- aggregator_form_category_submit in modules/
aggregator/ aggregator.admin.inc - Form submission handler for aggregator_form_category().
- CategorizeFeedItemTestCase::testCategorizeFeedItem in modules/
aggregator/ aggregator.test - Checks that children of a feed inherit a defined category.
- CategorizeFeedTestCase::testCategorizeFeed in modules/
aggregator/ aggregator.test - Creates a feed and makes sure you can add/delete categories to it.
File
-
modules/
aggregator/ aggregator.module, line 440
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();
// Remove category from feeds.
db_delete('aggregator_category_feed')->condition('cid', $edit['cid'])
->execute();
// Remove category from feed items.
db_delete('aggregator_category_item')->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']);
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.