Index: openid_cp_field.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/openid_cp_field/openid_cp_field.module,v
retrieving revision 1.1.2.7
diff -u -p -r1.1.2.7 openid_cp_field.module
--- openid_cp_field.module	21 Apr 2009 14:28:35 -0000	1.1.2.7
+++ openid_cp_field.module	22 Apr 2009 21:56:01 -0000
@@ -274,12 +274,70 @@ function openid_cp_field_openid_provider
 }
 
 /**
+ * Implementation of hook_openid_client_ax()
+ */
+function openid_cp_field_openid_client_ax($op, $response = NULL, $account = NULL) {
+  if ($op == 'get') {
+    $mapping = array();
+    openid_cp_field_get_mapping($mapping);
+    return array_keys($mapping);
+  }
+  if ($op == 'save') {
+    $mapping = array();
+    openid_cp_field_get_mapping($mapping);
+    if (empty($mapping)) {
+      return;
+    }
+    $types = content_profile_get_types('names');
+    foreach ($types as $type => $value) {
+      break;
+    }
+    // If profile already exists, do nothing.
+    if (db_result(db_query("SELECT COUNT(*) FROM {node} WHERE uid = %d AND type = '%s'", $account->uid, $type)) > 0) {
+      return;
+    }
+    $profile = new StdClass();
+    $matched_attribute = 0;
+    foreach ($mapping as $openid => $node) {
+      $short_name = array_pop(explode('/', $openid));
+      if (isset($response['openid.ax.value.'. $short_name])) {
+        $field_value = $response['openid.ax.value.'. $short_name];
+        if (!empty($field_value)) {
+          $matched_attribute++;
+          $profile->$node = array();
+          // Check if it's a CCK field or not.
+          if (strstr($node, 'field_') && module_exists('content_profile')) {
+            $profile->{$node}[0]['value'] = $field_value;
+          }
+          else {
+            $profile->{$node} = $field_value;
+          }
+        }
+      }
+    }
+    if (!isset($profile->title)) {
+      $profile->title = $account->name;
+    }
+    // Only create the profile if there is data available from the provider.
+    if ($matched_attribute > 0) {
+      $profile = node_submit($profile);
+      $profile->uid = $account->uid;
+      $profile->type = $type;
+      // Set title through auto_nodetitle if available.
+      if (module_exists('auto_nodetitle')) {
+        auto_nodetitle_set_title($profile);
+      }
+      node_save($profile);
+    }
+  }
+}
+
+/**
  * Implementation of hook_openid_provider_ax()
  */
 function openid_cp_field_openid_provider_ax($op, $attributes) {
   if ($op == 'load') {
     $response = array();
-    $fields = array();
     $short_names = array();
     if (isset($attributes['openid.ax.if_available'])) {
       $short_names += explode(',', $attributes['openid.ax.if_available']);
