protected function FeedsUserProcessor::existingEntityId in Feeds 7.2
Get id of an existing feed item term if available.
Overrides FeedsProcessor::existingEntityId
File
- plugins/
FeedsUserProcessor.inc, line 386 - Contains FeedsUserProcessor.
Class
- FeedsUserProcessor
- Feeds processor plugin. Create users from feed items.
Code
protected function existingEntityId(FeedsSource $source, FeedsParserResult $result) {
if ($uid = parent::existingEntityId($source, $result)) {
return $uid;
}
// Iterate through all unique targets and try to find a user for the
// target's value.
foreach ($this
->uniqueTargets($source, $result) as $target => $value) {
switch ($target) {
case 'uid':
$uid = db_query("SELECT uid FROM {users} WHERE uid = :uid", array(
':uid' => $value,
))
->fetchField();
break;
case 'name':
$uid = db_query("SELECT uid FROM {users} WHERE name = :name", array(
':name' => $value,
))
->fetchField();
break;
case 'mail':
$uid = db_query("SELECT uid FROM {users} WHERE mail = :mail", array(
':mail' => $value,
))
->fetchField();
break;
case 'openid':
$uid = db_query("SELECT uid FROM {authmap} WHERE authname = :authname AND module = 'openid'", array(
':authname' => $value,
))
->fetchField();
break;
}
if ($uid) {
// Return with the first nid found.
return $uid;
}
}
return 0;
}