function aggregator_save_category
7.x aggregator.module | aggregator_save_category($edit) |
6.x aggregator.module | aggregator_save_category($edit) |
Adds/edits/deletes aggregator categories.
Parameters
$edit: An associative array describing the category to be added/edited/deleted.
1 call to aggregator_save_category()
- aggregator_form_category_submit in drupal-7.x/
modules/ aggregator/ aggregator.admin.inc - Form submission handler for aggregator_form_category().
File
- drupal-7.x/
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']);
}
}