function hybridauth_popup in HybridAuth Social Login 7
1 string reference to 'hybridauth_popup'
- hybridauth_menu in ./hybridauth.module
- Implements hook_menu().
File
- ./hybridauth.pages.inc, line 21
Code
function hybridauth_popup() {
global $user;
$provider_id = isset($_REQUEST['provider']) ? $_REQUEST['provider'] : NULL;
if (empty($provider_id) || $provider_id == 'none') {
if (isset($_COOKIE['__ha_provider']) && !empty($_COOKIE['__ha_provider'])) {
$provider_id = $_COOKIE['__ha_provider'];
}
}
else {
setcookie('__ha_provider', $provider_id, REQUEST_TIME + 31536000, base_path(), variable_get('cookie_domain', ''));
}
drupal_session_start();
module_load_include('inc', 'hybridauth', 'hybridauth.auth');
try {
$hybridauth = hybridauth_get_instance();
} catch (ErrorException $e) {
drupal_set_message(t('There was an error processing your request!'), 'error');
watchdog_exception('hybridauth', $e);
$GLOBALS['devel_shutdown'] = FALSE;
$destination = isset($_GET['destination']) ? $_GET['destination'] : 'user';
drupal_add_js('
if (window.opener){
try { window.opener.parent.$.colorbox.close(); } catch(err) {}
window.opener.parent.location.href = "' . url($destination, array(
'absolute' => TRUE,
)) . '";
}
window.self.close();
', 'inline');
$page = array(
'page_top' => '',
'#children' => 'Closing...',
'page_bottom' => '',
);
print theme('html', array(
'page' => $page,
));
drupal_exit();
} catch (Exception $e) {
$redirect = TRUE;
switch ($e
->getCode()) {
case 5:
$redirect = FALSE;
break;
case 0:
case 1:
case 2:
case 3:
case 4:
default:
drupal_set_message(t('There was an error processing your request!'), 'error');
watchdog_exception('hybridauth', $e);
}
$GLOBALS['devel_shutdown'] = FALSE;
$destination = isset($_GET['destination']) ? $_GET['destination'] : 'user';
drupal_add_js('
var redirect = ' . ($redirect ? 'true' : 'false') . ';
if (window.opener && redirect) {
try { window.opener.parent.$.colorbox.close(); } catch(err) {}
window.opener.parent.location.href = "' . url($destination, array(
'absolute' => TRUE,
)) . '";
}
window.self.close();
', 'inline');
$page = array(
'page_top' => '',
'#children' => 'Closing...',
'page_bottom' => '',
);
print theme('html', array(
'page' => $page,
));
drupal_exit();
}
if (empty($provider_id) || $provider_id == 'none' || $provider_id == 'list') {
return _hybridauth_popup_list($hybridauth);
}
elseif ($provider_id == 'OpenID' && !isset($_GET['openid_identifier'])) {
$destination = isset($_GET['destination']) ? $_GET['destination'] : 'user';
unset($_GET['destination']);
$query = drupal_get_query_parameters();
$query['destination'] = $destination;
drupal_goto('hybridauth/popup/openid', array(
'query' => $query,
));
}
elseif (isset($_GET['authenticate']) && $_GET['authenticate']) {
return _hybridauth_popup_auth($hybridauth, $provider_id);
}
else {
return _hybridauth_popup_provider($hybridauth, $provider_id);
}
return MENU_ACCESS_DENIED;
}