You are here

protected function FeedsUserProcessor::setPassTarget in Feeds 7.2

Sets the password on the user target.

See also

setTargetElement()

1 call to FeedsUserProcessor::setPassTarget()
FeedsUserProcessor::setTargetElement in plugins/FeedsUserProcessor.inc
Overrides setTargetElement() to operate on a target item that is an user.

File

plugins/FeedsUserProcessor.inc, line 694
Contains FeedsUserProcessor.

Class

FeedsUserProcessor
Feeds processor plugin. Create users from feed items.

Code

protected function setPassTarget($source, $target_user, $target_element, $value, $mapping) {
  if (empty($value)) {
    return;
  }
  if (!isset($mapping['pass_encryption'])) {
    $mapping['pass_encryption'] = self::PASS_UNENCRYPTED;
  }
  switch ($mapping['pass_encryption']) {
    case self::PASS_MD5:
      require_once DRUPAL_ROOT . '/' . variable_get('password_inc', 'includes/password.inc');
      $new_hash = user_hash_password($value);
      if ($new_hash) {

        // Indicate an updated password.
        $new_hash = 'U' . $new_hash;
        $target_user->pass = $target_user->pass_crypted = $new_hash;
      }
      break;
    case self::PASS_SHA512:
      $target_user->pass = $target_user->pass_crypted = $value;
      break;
    default:
      $target_user->pass = $value;
      break;
  }
}