You are here

public function FeedsTermProcessor::clear in Feeds 6

Same name and namespace in other branches
  1. 7 plugins/FeedsTermProcessor.inc \FeedsTermProcessor::clear()

Implementation of FeedsProcessor::clear().

Overrides FeedsProcessor::clear

File

plugins/FeedsTermProcessor.inc, line 119
FeedsTermProcessor class.

Class

FeedsTermProcessor
Feeds processor plugin. Create taxonomy terms from feed items.

Code

public function clear(FeedsBatch $batch, FeedsSource $source) {
  $deleted = 0;
  $vocabulary = $this
    ->vocabulary();
  $result = db_query("SELECT td.tid\n                        FROM {term_data} td\n                        JOIN {feeds_term_item} ft ON td.tid = ft.tid\n                        WHERE td.vid = %d\n                        AND ft.id = '%s'\n                        AND ft.feed_nid = %d", $vocabulary->vid, $this->id, $source->feed_nid);
  while ($term = db_fetch_object($result)) {
    if (taxonomy_del_term($term->tid) == SAVED_DELETED) {
      $deleted++;
    }
  }

  // Set messages.
  if ($deleted) {
    drupal_set_message(format_plural($deleted, 'Deleted @number term from !vocabulary.', 'Deleted @number terms from !vocabulary.', array(
      '@number' => $deleted,
      '!vocabulary' => $vocabulary->name,
    )));
  }
  else {
    drupal_set_message(t('No terms to be deleted.'));
  }
}