function aggregator_categorize_items_submit

7.x aggregator.pages.inc aggregator_categorize_items_submit($form, &$form_state)
6.x aggregator.pages.inc aggregator_categorize_items_submit($form, &$form_state)

Form submission handler for aggregator_categorize_items().

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

File

drupal/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.'));
}