You are here

function janrain_capture_url in Janrain Registration 7.2

Same name and namespace in other branches
  1. 6 janrain_capture.module \janrain_capture_url()
  2. 7.4 janrain_capture.module \janrain_capture_url()
  3. 7 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

5 calls to janrain_capture_url()
janrain_capture_oauth in includes/janrain_capture.endpoints.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 includes/janrain_capture.endpoints.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_signin in ./janrain_capture.module
Menu callback to override user/login and user/register.
janrain_capture_signin_link in ./janrain_capture.module
Returns a render array for the 'Register / Sign in' link for Janrain Capture.
janrain_capture_tokens in ./janrain_capture.module
Implements hook_tokens().

File

./janrain_capture.module, line 357
This module implements authentication endpoints for Janrain Capture.

Code

function janrain_capture_url($options = NULL) {

  //TODO: set new
  $ver = variable_get('janrain_capture_ver', JANRAIN_CAPTURE_VERSION_DEFAULT);
  if ($ver == JANRAIN_CAPTURE_VERSION_LEGACY) {
    $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' => 'Drupal.janrainCapture.closeRecoverPassword',
          'response_type' => 'code',
        );
      }
      else {
        $defaults = array(
          'callback' => 'Drupal.janrainCapture.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 {
      return '';
    }
  }
  else {
    return '';
  }
  return $url;
}