function hybridauth_user_identities in HybridAuth Social Login 7
Menu callback; manage Engage 3rd party identities for the specified user.
1 string reference to 'hybridauth_user_identities'
- hybridauth_menu in ./
hybridauth.module - Implements hook_menu().
File
- ./
hybridauth.pages.inc, line 601
Code
function hybridauth_user_identities($account) {
module_load_include('inc', 'hybridauth', 'hybridauth.auth');
drupal_set_title(format_username($account));
$header = array(
t('Account type'),
t('Account ID'),
t('Operations'),
);
$rows = array();
$result = db_query("SELECT am.aid, am.authname, ha.provider_id FROM {authmap} am INNER JOIN {hybridauth_account} ha ON am.aid = ha.aid WHERE module = :module AND uid = :uid", array(
':module' => 'hybridauth',
':uid' => $account->uid,
));
foreach ($result as $identity) {
$provider_id = $identity->provider_id;
$provider_name = hybridauth_get_provider_name($provider_id);
$rows[] = array(
theme('hybridauth_provider_icon', array(
'provider_id' => $provider_id,
'style' => 'hybridauth-icon-inline',
)) . '<span' . drupal_attributes(array(
'class' => 'hybridauth-provider-name',
)) . '>' . $provider_name . '</span>',
check_plain(_hybridauth_get_authmap_identfier($identity->authname)),
l(t('Delete'), 'user/' . $account->uid . '/hybridauth/delete/' . $identity->aid),
);
}
// TODO: Look at RPX overlay code.
/*
hybridauth_js(FALSE);
$realm = variable_get('hybridauth_realm', '');
$realm_scheme = variable_get('hybridauth_realm_scheme', 'http');
$sign_in_url = "$realm_scheme://$realm/openid/v2/signin";
// If we are in overlay, we want the user redirected back to it after the
// account is linked. We have to rely on HTTP_REFERER and do it manually
// since the sign-in widget bypasses the overlay code when POSTing to
// token_url, causing a complete page reload.
//
// Only clobber $_SESSION['hybridauth_overlay_uri'] if we haven't visited an account
// deletetion confirm_form. Otherwise we will get a "Page not found" error
// (@see http://drupal.org/node/1029458#comment-4055748), because HTTP_REFERER
// has been changed to the confirmation form's URI.
if (isset($_SESSION['hybridauth_account_deleted'])) {
unset($_SESSION['hybridauth_account_deleted']);
}
else {
unset($_SESSION['hybridauth_overlay_uri']);
if (function_exists('overlay_get_mode') && overlay_get_mode() == 'child' && isset($_SERVER['HTTP_REFERER'])) {
// Construct referer URI to be passed to token_url.
$referer = $_SERVER['HTTP_REFERER'];
if (variable_get('clean_url', FALSE)) {
// Clean URLs are enabled.
global $base_url;
$referer = substr($referer, strlen($base_url)+1);
}
else {
$referer = substr(parse_url($referer, PHP_URL_QUERY), 2);
}
global $user;
$dest = urlencode('user/' . $user->uid . '/rpx');
if (!variable_get('clean_url', FALSE)) {
$dest = urlencode('?q=') . $dest;
}
$_SESSION['hybridauth_overlay_uri'] = $referer . '#overlay=' . $dest;
}
}
*/
// TODO: Figure out a way to link a new account. Widget?
/*
$token_url = _hybridauth_token_url(array('add_to_account' => 'true'));
$links['add_id'] = array(
'title' => t('Add linked account'),
'href' => $sign_in_url,
'query' => array('token_url' => $token_url),
'attributes' => array('class' => 'rpxnow', 'onclick' => 'return false;'),
);
$build['add_link'] = array(
'#theme' => 'links',
'#links' => $links,
'#attributes' => array('class' => array('action-links')),
);
*/
$build['hybridauth_table'] = array(
'#theme' => 'table',
'#header' => $header,
'#rows' => $rows,
'#empty' => t('You don\'t have any accounts linked yet.'),
);
/*
if (isset($_SESSION['hybridauth_overlay_message'])) {
drupal_set_message($_SESSION['hybridauth_overlay_message']['text'], $_SESSION['hybridauth_overlay_message']['type']);
unset($_SESSION['hybridauth_overlay_message']);
}
*/
return $build;
}