You are here

protected function FeedsUserProcessor::existingItemId in Feeds 6

Same name and namespace in other branches
  1. 7 plugins/FeedsUserProcessor.inc \FeedsUserProcessor::existingItemId()

Get id of an existing feed item term if available.

Overrides FeedsProcessor::existingItemId

1 call to FeedsUserProcessor::existingItemId()
FeedsUserProcessor::process in plugins/FeedsUserProcessor.inc
Implementation of FeedsProcessor::process().

File

plugins/FeedsUserProcessor.inc, line 206
FeedsUserProcessor class.

Class

FeedsUserProcessor
Feeds processor plugin. Create users from feed items.

Code

protected function existingItemId(FeedsImportBatch $batch, FeedsSource $source) {

  // Iterate through all unique targets and try to find a user for the
  // target's value.
  foreach ($this
    ->uniqueTargets($batch) as $target => $value) {
    switch ($target) {
      case 'name':
        $uid = db_result(db_query("SELECT uid FROM {users} WHERE name = '%s'", $value));
        break;
      case 'mail':
        $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 ($uid) {

      // Return with the first nid found.
      return $uid;
    }
  }
  return 0;
}