You are here

function _feedapi_invoke_purge in FeedAPI 5

Same name and namespace in other branches
  1. 6 feedapi.module \_feedapi_invoke_purge()

Helper function for feedapi_invoke(). Delete all feed items of a feed.

1 call to _feedapi_invoke_purge()
feedapi_invoke in ./feedapi.module
Invoke feedapi API callback functions.

File

./feedapi.module, line 1219
Handle the submodules (for feed and item processing) Provide a basic management of feeds

Code

function _feedapi_invoke_purge(&$feed, $param) {
  $node = node_load($feed->nid);

  // Reset hash.
  db_query("UPDATE {feedapi} SET hash = 0 WHERE nid = %d", $feed->nid);
  if ($param == 'items') {
    return drupal_get_form('feedapi_purge_confirm', $node);
  }
  feedapi_invoke('load', $feed);

  // Delete items from the processors
  foreach ($feed->items as $item) {
    foreach ($feed->processors as $processor) {

      // FIXME: it's possible now to accidentally delete an item from another processor
      module_invoke($processor, 'feedapi_item', 'delete', $item, $feed->settings['processors'][$processor]);
    }
  }
  if ($param == 'items_confirmed') {
    drupal_set_message(t('!count feed items have been deleted successfully from the feed.', array(
      '!count' => count($feed->items),
    )));
  }
}