function ulogin_user_identity_delete in uLogin (advanced version) 7
Same name and namespace in other branches
- 6 ulogin.pages.inc \ulogin_user_identity_delete()
1 string reference to 'ulogin_user_identity_delete'
- ulogin_menu in ./
ulogin.module - Implements hook_menu().
File
- ./
ulogin.pages.inc, line 186
Code
function ulogin_user_identity_delete($form, &$form_state, $account, $id) {
$del_identity = _ulogin_identity_load_by_id($id);
if (!$del_identity || $account->uid != $del_identity['uid']) {
drupal_set_message(t('You are trying to delete non-existing identity.'), 'error');
drupal_access_denied();
}
$del_identity_data = unserialize($del_identity['data']);
$username = format_username($account);
$question = t('Are you sure you want to detach the uLogin identity !identity from %user?', array(
'!identity' => l($del_identity_data['identity'], $del_identity_data['identity'], array(
'attributes' => array(
'target' => '_blank',
),
'external' => TRUE,
)),
'%user' => $username,
));
$form = array();
$form['#user'] = $account;
$form['#del_identity_data'] = $del_identity_data;
$form['question'] = array(
'#markup' => $question,
'#prefix' => '<div>',
'#suffix' => '</div>',
);
if (!empty($account->data['ulogin']) && $account->data['ulogin']['network'] == $del_identity_data['network'] && $account->data['ulogin']['uid'] == $del_identity_data['uid']) {
$identities = _ulogin_identity_load_by_uid($account->uid);
$providers = _ulogin_providers_list();
$options = array();
foreach ($identities as $key => $identity) {
$data = unserialize($identity['data']);
if ($key != $id) {
$options[$key] = $providers[$identity['network']] . ' - ' . l($data['identity'], $data['identity'], array(
'attributes' => array(
'target' => '_blank',
),
'external' => TRUE,
));
}
}
if (!empty($options)) {
$form['explanation'] = array(
'#markup' => t('This identity was used to create your account. Please choose another identity to replace it.'),
'#prefix' => '<div>',
'#suffix' => '</div>',
);
$form['identity_choice'] = array(
'#type' => 'radios',
//'#title' => t('Identities'),
'#options' => $options,
'#default_value' => count($options) == 1 ? $key : NULL,
);
}
else {
$form['explanation'] = array(
'#markup' => t('This identity was used to create your account. To delete it you should first add another identity to your account.'),
'#prefix' => '<div>',
'#suffix' => '</div>',
);
return $form;
}
}
$form = confirm_form($form, '', 'user/' . $account->uid . '/ulogin');
drupal_set_title($username);
return $form;
}