You are here

protected function FeedsUserProcessor::clean in Feeds 7.2

Overrides FeedsProcessor::clean().

Block users instead of deleting them.

Parameters

FeedsState $state: The FeedsState object for the given stage.

Overrides FeedsProcessor::clean

File

plugins/FeedsUserProcessor.inc, line 439
Contains FeedsUserProcessor.

Class

FeedsUserProcessor
Feeds processor plugin. Create users from feed items.

Code

protected function clean(FeedsState $state) {

  // Delegate to parent if not blocking or option not set.
  if (!isset($this->config['update_non_existent']) || $this->config['update_non_existent'] !== FEEDS_BLOCK_NON_EXISTENT) {
    return parent::clean($state);
  }
  if (!empty($state->removeList)) {

    // @see user_user_operations_block().
    // The following foreach is copied from above function but with an added
    // counter to count blocked users.
    foreach (user_load_multiple($state->removeList) as $account) {
      $this
        ->loadItemInfo($account);
      $account->feeds_item->hash = $this->config['update_non_existent'];

      // For efficiency manually save the original account before applying any
      // changes.
      $account->original = clone $account;
      user_save($account, array(
        'status' => 0,
      ));
      $state->blocked++;
    }
  }
}