Skip navigation
Help

aggregator_categorize_items_submit

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

Process aggregator_categorize_items() form submissions.

1 string reference to 'aggregator_categorize_items_submit'

File

drupal/modules/aggregator/aggregator.pages.inc, line 210
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.'));
}