public function FeedsCommentProcessor::clear in Feeds Comment Processor 6
Implementation of FeedsProcessor::clear().
Overrides FeedsProcessor::clear
File
- ./
FeedsCommentProcessor.inc, line 99 - Class definition of FeedsCommentProcessor.
Class
- FeedsCommentProcessor
- Creates comments from feed items.
Code
public function clear(FeedsBatch $batch, FeedsSource $source) {
if (!$batch
->getTotal(FEEDS_CLEARING)) {
$total = db_result(db_query("SELECT COUNT(cid) FROM {feeds_comment_item} WHERE id = '%s' AND feed_nid = %d", $source->id, $source->feed_nid));
$batch
->setTotal(FEEDS_CLEARING, $total);
}
$result = db_query_range("SELECT cid FROM {feeds_comment_item} WHERE id = '%s' AND feed_nid = %d", $source->id, $source->feed_nid, 0, variable_get('feeds_comment_batch_size', FEEDS_COMMENT_BATCH_SIZE));
while ($comment = db_fetch_object($result)) {
_feeds_comment_delete($comment->cid);
$batch->deleted++;
}
if (db_result(db_query_range("SELECT cid FROM {feeds_comment_item} WHERE id = '%s' AND feed_nid = %d", $source->id, $source->feed_nid, 0, 1))) {
$batch
->setProgress(FEEDS_CLEARING, $batch->deleted);
return;
}
// Set message.
drupal_get_messages('status');
if ($batch->deleted) {
drupal_set_message(format_plural($batch->deleted, 'Deleted @number comment.', 'Deleted @number comments.', array(
'@number' => $batch->deleted,
)));
}
else {
drupal_set_message(t('There is no content to be deleted.'));
}
$batch
->setProgress(FEEDS_CLEARING, FEEDS_BATCH_COMPLETE);
}