You are here

function janrain_capture_url in Janrain Registration 6

Same name and namespace in other branches
  1. 7.4 janrain_capture.module \janrain_capture_url()
  2. 7 janrain_capture.module \janrain_capture_url()
  3. 7.2 janrain_capture.module \janrain_capture_url()
  4. 7.3 janrain_capture.module \janrain_capture_url()

Returns the full URL of a specified CaptureUI screen

Parameters

array $options: An associative array of options to use in constructing the URL

Return value

string The full URL string of the Capture URL screen being requested

3 calls to janrain_capture_url()
janrain_capture_oauth in ./janrain_capture.pages.inc
Callback for the janrain_capture/oauth menu item. This serves as the redirect_uri Capture redirects the user to and performs the authentication.
janrain_capture_profile in ./janrain_capture.pages.inc
Callback for the janrain_capture/profile menu item. Ensures the access_token is valid before redirecting the user to the Capture profile screen.
janrain_capture_ui_block in ./janrain_capture_ui.module
Implements of hook_block().

File

./janrain_capture.module, line 87

Code

function janrain_capture_url($options = NULL) {
  $janrain_capture_main = variable_get('janrain_capture_main', array());
  $janrain_capture_optional = variable_get('janrain_capture_optional', array());
  if (!empty($janrain_capture_main['capture_address']) && !empty($janrain_capture_main['capture_client_id'])) {
    $required = array(
      'redirect_uri' => url('janrain_capture/oauth', array(
        'absolute' => TRUE,
      )),
      'xd_receiver' => url(NULL, array(
        'absolute' => TRUE,
      )) . drupal_get_path('module', 'janrain_capture') . '/xdcomm.html',
      'client_id' => $janrain_capture_main['capture_client_id'],
    );
    if (!$options || strpos($options['action'], 'profile') !== 0) {
      if (!$options) {
        $options = array();
      }
      $defaults = array(
        'action' => 'signin',
        'recover_password_callback' => 'CAPTURE.closeRecoverPassword',
        'response_type' => 'code',
      );
    }
    else {
      $defaults = array(
        'callback' => 'CAPTURE.closeProfileEditor',
      );
    }
    $args = array_merge($required, $defaults, $options);
    $action = $args['action'];
    unset($args['action']);
    $url = 'https://' . (!empty($janrain_capture_optional['captureui_address']) ? $janrain_capture_optional['captureui_address'] : $janrain_capture_main['capture_address']) . '/oauth/' . $action . '?' . http_build_query($args, '', '&');
  }
  else {
    $url = '';
  }
  return $url;
}