You are here

function aggregator_categorize_items_submit in Drupal 7

Same name and namespace in other branches
  1. 6 modules/aggregator/aggregator.pages.inc \aggregator_categorize_items_submit()

Form submission handler for aggregator_categorize_items().

1 string reference to 'aggregator_categorize_items_submit'
aggregator_categorize_items in modules/aggregator/aggregator.pages.inc
Form constructor to build the page list form.

File

modules/aggregator/aggregator.pages.inc, line 248
User page callbacks for the Aggregator module.

Code

function aggregator_categorize_items_submit($form, &$form_state) {
  if (!empty($form_state['values']['categories'])) {
    foreach ($form_state['values']['categories'] as $iid => $selection) {
      db_delete('aggregator_category_item')
        ->condition('iid', $iid)
        ->execute();
      $insert = db_insert('aggregator_category_item')
        ->fields(array(
        'iid',
        'cid',
      ));
      $has_values = FALSE;
      foreach ($selection as $cid) {
        if ($cid && $iid) {
          $has_values = TRUE;
          $insert
            ->values(array(
            'iid' => $iid,
            'cid' => $cid,
          ));
        }
      }
      if ($has_values) {
        $insert
          ->execute();
      }
    }
  }
  drupal_set_message(t('The categories have been saved.'));
}