Skip to content
Snippets Groups Projects
Commit 4966c0de authored by Alex Barth's avatar Alex Barth
Browse files

Support mapping to OpenID, using OpenID as a unique mapping target.

parent ca1a5603
No related branches found
No related tags found
No related merge requests found
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
Feeds 6.x 1.0 xxxxx xx, xxxx-xx-xx 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. - alex_b: Handle exceptions outside of Importer/Source facade methods.
- #600584 alexb: Use Batch API. NOTE: third party plugins/extensions - #600584 alexb: Use Batch API. NOTE: third party plugins/extensions
implementing FeedsProcessor::process(), FeedsProcessor::clear() or implementing FeedsProcessor::process(), FeedsProcessor::clear() or
......
...@@ -38,8 +38,17 @@ class FeedsUserProcessor extends FeedsProcessor { ...@@ -38,8 +38,17 @@ class FeedsUserProcessor extends FeedsProcessor {
} }
// Save the user. // Save the user.
// @todo Is this really the best way to use this function?
user_save($account, (array) $account); 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) { if ($uid) {
$updated++; $updated++;
...@@ -164,6 +173,13 @@ class FeedsUserProcessor extends FeedsProcessor { ...@@ -164,6 +173,13 @@ class FeedsUserProcessor extends FeedsProcessor {
'description' => t('The created (e. g. joined) data of the user.'), '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; return $targets;
} }
...@@ -177,15 +193,18 @@ class FeedsUserProcessor extends FeedsProcessor { ...@@ -177,15 +193,18 @@ class FeedsUserProcessor extends FeedsProcessor {
foreach ($this->uniqueTargets($source_item) as $target => $value) { foreach ($this->uniqueTargets($source_item) as $target => $value) {
switch ($target) { switch ($target) {
case 'name': 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; break;
case 'mail': 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; break;
} }
if ($nid) { if ($uid) {
// Return with the first nid found. // Return with the first nid found.
return $nid; return $uid;
} }
} }
return 0; return 0;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment