diff --git a/CHANGELOG.txt b/CHANGELOG.txt index 1c2a3ebefc83a55fc5efcedb9c9c9de26643a3ec..62498f1358e27adbf4d2087b81ca5c2cab18a1c8 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -3,6 +3,7 @@ Feeds 6.x 1.0 xxxxx xx, xxxx-xx-xx ---------------------------------- +- alex_b: Support mapping to OpenID, using OpenID as a unique mapping target. - alex_b: Handle exceptions outside of Importer/Source facade methods. - #600584 alexb: Use Batch API. NOTE: third party plugins/extensions implementing FeedsProcessor::process(), FeedsProcessor::clear() or diff --git a/plugins/FeedsUserProcessor.inc b/plugins/FeedsUserProcessor.inc index 4bdde838fc4951f1d60ab3fc80d39f12136c459e..4f60bfe0e6cfce79fd168be7aafb19097d142c35 100644 --- a/plugins/FeedsUserProcessor.inc +++ b/plugins/FeedsUserProcessor.inc @@ -38,8 +38,17 @@ class FeedsUserProcessor extends FeedsProcessor { } // Save the user. - // @todo Is this really the best way to use this function? user_save($account, (array) $account); + if ($account->uid && $account->openid) { + $authmap = array( + 'uid' => $account->uid, + 'module' => 'openid', + 'authname' => $account->openid, + ); + if (SAVED_UPDATED != drupal_write_record('authmap', $authmap, array('uid', 'module'))) { + drupal_write_record('authmap', $authmap); + } + } if ($uid) { $updated++; @@ -164,6 +173,13 @@ class FeedsUserProcessor extends FeedsProcessor { 'description' => t('The created (e. g. joined) data of the user.'), ), ); + if (module_exists('openid')) { + $targets['openid'] = array( + 'name' => t('OpenID identifier'), + 'description' => t('The OpenID identifier of the user. <strong>CAUTION:</strong> Use only for migration purposes, misconfiguration of the OpenID identifier can lead to severe security breaches like users gaining access to accounts other than their own.'), + 'optional_unique' => TRUE, + ); + } return $targets; } @@ -177,15 +193,18 @@ class FeedsUserProcessor extends FeedsProcessor { foreach ($this->uniqueTargets($source_item) as $target => $value) { switch ($target) { case 'name': - $nid = db_result(db_query('SELECT uid FROM {users} WHERE name = "%s"', $value)); + $uid = db_result(db_query('SELECT uid FROM {users} WHERE name = "%s"', $value)); break; case 'mail': - $nid = db_result(db_query('SELECT uid FROM {users} WHERE mail = "%s"', $value)); + $uid = db_result(db_query('SELECT uid FROM {users} WHERE mail = "%s"', $value)); + break; + case 'openid': + $uid = db_result(db_query("SELECT uid FROM {authmap} WHERE authname = '%s' AND module = 'openid'", $value)); break; } - if ($nid) { + if ($uid) { // Return with the first nid found. - return $nid; + return $uid; } } return 0;