View source
<?php
require_once 'janrain_capture.api.inc';
function janrain_capture_menu() {
$items['janrain_capture/oauth'] = array(
'title' => 'Capture Oauth Receiver',
'page callback' => 'janrain_capture_oauth',
'access callback' => 'user_is_anonymous',
'type' => MENU_CALLBACK,
'file' => 'janrain_capture.pages.inc',
);
$items['janrain_capture/profile'] = array(
'title' => 'Capture Profile',
'page callback' => 'janrain_capture_profile',
'access callback' => 'user_is_logged_in',
'type' => MENU_CALLBACK,
'file' => 'janrain_capture.pages.inc',
);
$items['janrain_capture/profile_sync'] = array(
'title' => 'Capture Profile Receiver',
'page callback' => 'janrain_capture_profile_sync',
'access callback' => 'user_is_logged_in',
'type' => MENU_CALLBACK,
'file' => 'janrain_capture.pages.inc',
);
$items['janrain_capture/resend_verification_email'] = array(
'title' => 'Capture Verification Email Resent',
'page callback' => 'janrain_capture_resend_verification_email',
'access callback' => TRUE,
'type' => MENU_CALLBACK,
'file' => 'janrain_capture.pages.inc',
);
$items['admin/settings/janrain_capture'] = array(
'title' => 'Janrain Capture',
'description' => 'Configure settings for Janrain Capture module.',
'page callback' => 'drupal_get_form',
'page arguments' => array(
'janrain_capture_settings',
),
'access arguments' => array(
'administer site configuration',
),
'file' => 'janrain_capture.admin.inc',
);
$items['janrain_capture/token_expired/%'] = array(
'title' => 'Capture Token Expired',
'page callback' => 'janrain_capture_token_expired',
'access callback' => 'janrain_capture_token_expired_access',
'access arguments' => array(
2,
),
'type' => MENU_CALLBACK,
'file' => 'janrain_capture.pages.inc',
);
return $items;
}
function janrain_capture_token_expired_access($token) {
return user_is_logged_in() && $token === drupal_get_token('janrain_capture_token_expired');
}
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;
}