function janrain_capture_page_alter in Janrain Registration 7.2
Same name and namespace in other branches
- 7.4 janrain_capture.module \janrain_capture_page_alter()
Implements hook_page_alter().
File
- ./
janrain_capture.module, line 1189 - This module implements authentication endpoints for Janrain Capture.
Code
function janrain_capture_page_alter(&$page) {
global $user, $base_url;
$enforce = variable_get('janrain_capture_enforce', FALSE);
if (!empty($page['content']) && !empty($page['content']['system_main']) && !empty($page['content']['system_main']['#form_id'])) {
if ($page['content']['system_main']['#form_id'] == 'user_profile_form') {
$account = $page['content']['system_main']['#user'];
if ($enforce || janrain_capture_mapping_exists($account->uid)) {
// Check to make sure the user accounts match
if ($user->uid == $account->uid) {
$ver = variable_get('janrain_capture_ver', JANRAIN_CAPTURE_VERSION_DEFAULT);
if ($ver == JANRAIN_CAPTURE_VERSION_WIDGET) {
// Widget
// Capture profiles enabled
$screen = _janrain_capture_get_screen("edit-profile.html");
if (REQUEST_TIME >= $_SESSION['janrain_capture_expires_in']) {
$api = new JanrainCaptureApi();
$api
->refreshAccessToken();
$access_token = $_SESSION['janrain_capture_access_token'];
$token = "<script type='text/javascript'>access_token = '{$access_token}';</script>";
}
$markup = isset($token) ? $token . $screen : $screen;
$profile = array(
'#title' => t('Profile'),
'#weight' => -100,
'#type' => 'fieldset',
'content' => array(
'#markup' => $markup,
),
);
if ($js = _janrain_capture_get_screen("edit-profile.js")) {
// JS for the edit profile screen that should go into <head> before the widget.
drupal_add_js($js, array(
'type' => 'inline',
'every_page' => TRUE,
'weight' => 2,
'preprocess' => FALSE,
));
}
$page['content']['janrain_capture_profile'] = $profile;
unset($page['content']['#sorted']);
}
else {
// Legacy
$page['content']['janrain_capture_profile'] = array(
'#type' => 'fieldset',
'#title' => t('Profile'),
'#weight' => -100,
'content' => array(
'#markup' => '<iframe width="900" height="1300" frameborder="0" src="' . $base_url . '/janrain_capture/profile" />',
),
);
}
}
else {
$page['content']['janrain_capture_profile'] = array(
'#type' => 'fieldset',
'#title' => t('Profile'),
'#weight' => -100,
'content' => array(
'#markup' => t('Profile managed in Janrain Capture'),
),
);
}
}
}
}
}