Index: openid_provider_ax.install
===================================================================
RCS file: openid_provider_ax.install
diff -N openid_provider_ax.install
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ openid_provider_ax.install	30 Jun 2009 09:30:01 -0000
@@ -0,0 +1,46 @@
+<?php
+// $Id$
+
+/**
+ * Implementation of hook_schema().
+ */
+function openid_provider_ax_schema() {
+  $schema['openid_provider_ax'] = array(
+    'description' => 'Connect profiles to the relying parties.',
+    'fields' => array(
+      'uid' => array(
+        'description' => 'The user identifier.',
+        'type' => 'int',
+        'unsigned' => TRUE,
+        'not null' => TRUE),
+      'request' => array(
+        'description' => 'The fields that requested by the relying party.',
+        'type' => 'text',
+        'not null' => TRUE),
+      'response' => array(
+        'description' => 'The fields that requested by the relying party.',
+        'type' => 'text',
+        'not null' => TRUE),
+      'update_url' => array(
+        'description' => 'The URL of the relying party where the updated profile data should be sent.',
+        'type' => 'text',
+        'not null' => TRUE),
+    ),
+    'primary key' => array('uid', 'update_url'),
+  );
+  return $schema;
+}
+
+/**
+ * Implementation of hook_install().
+ */
+function openid_provider_ax_install() {
+  drupal_install_schema('openid_provider_ax');
+}
+
+/**
+ * Implementation of hook_uninstall().
+ */
+function openid_provider_ax_uninstall() {
+  drupal_uninstall_schema('openid_provider_ax');
+}
Index: openid_provider_ax.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/openid_provider_ax/openid_provider_ax.module,v
retrieving revision 1.3.2.4
diff -u -p -r1.3.2.4 openid_provider_ax.module
--- openid_provider_ax.module	9 Apr 2009 15:49:06 -0000	1.3.2.4
+++ openid_provider_ax.module	30 Jun 2009 09:30:03 -0000
@@ -23,11 +23,24 @@ function openid_provider_ax_xrds($accoun
 /**
  * Implementation of hook_openid_provider()
  */
-function openid_provider_ax_openid_provider($op = 'response', $response = array(), $request = array()) {
+function openid_provider_ax_openid_provider($op = 'response') {
+  $args = func_get_args();
   switch ($op) {
     case 'response':
-      return openid_provider_ax_response_process($response, $request);
+      if (count($args) < 3) {
+        return FALSE;
+      }
+      return openid_provider_ax_response_process($args[1], $args[2]);
       break;
+    case 'update':
+      $uid = array_pop($args);
+      $relying_parties = db_query("SELECT * FROM {openid_provider_ax} WHERE uid = %d", $uid);
+      foreach ($relying_parties as $rp) {
+        $update_url = $rp['request']['openid.ax.update_url'];
+        unset($rp['request']['openid.ax.update_url']);
+        $response = openid_provider_ax_response_process($rp['response'], $rp['request'], $uid);
+        openid_provider_unsolicited_assertion($response, $update_url);
+      }
     case 'signed':
       break;
   }
@@ -41,7 +54,9 @@ function openid_provider_ax_openid_provi
  * @param $request
  *      Keyed array holding the request that was received
  */
-function openid_provider_ax_response_process($response = array(), $request = array()) {
+function openid_provider_ax_response_process($response = array(), $request = array(), $uid = FALSE) {
+  global $user;
+  
   $processed = array();
   // OPENID Attribute Exchange was requested hence get the alias per
   // OPENID specification and then determine the type of request it was
@@ -55,8 +70,14 @@ function openid_provider_ax_response_pro
     $attributes = openid_provider_ax_parse_request($request, $alias);
     switch ($request_type) {
       case 'fetch_request':
-        $processed = array_merge($processed, module_invoke_all('openid_provider_ax', 'load', $attributes, $request));
+        $processed = array_merge($processed, module_invoke_all('openid_provider_ax', 'load', $attributes, $uid));
         $processed = array_merge($processed, array($alias_key => OPENID_PROVIDER_AX, sprintf('openid%smode', $alias) => 'fetch_response'));
+        // Relying party asks for updates.
+        if (isset($request['openid.ax.update_url'])) {
+          if (valid_url($request['openid.ax.update_url'], TRUE)) {
+            db_query("INSERT INTO {openid_provider_ax} VALUES (%d, '%s', '%s', '%s')", $user->uid, serialize($request), serialize($response), $request['openid.ax.update_url']);
+          }
+        }
         break;
       case 'store_request':
         break;
