')),
);
$form['tokenauth_text'] = array(
'#type' => 'fieldset',
'#title' => t('User text'),
'#description' => t('This text will be displayed on a tab in each user\'s profile. Use it to explain what functionality Tokenauth provides your site.'),
'#collapsible' => TRUE,
'#collapsed' => TRUE,
'#tree' => TRUE,
);
$tokenauth_text = tokenauth_text_load();
$form['tokenauth_text']['body'] = array(
'#type' => 'textarea',
'#title' => t('Body'),
'#default_value' => $tokenauth_text['body'],
'#rows' => 5,
);
$form['tokenauth_text']['format'] = filter_form(FILTER_FORMAT_DEFAULT);
if (module_exists('token')) {
$form['tokenauth_text']['view']['token_help'] = array(
'#title' => t('Replacement patterns'),
'#type' => 'fieldset',
'#collapsible' => TRUE,
'#collapsed' => TRUE,
);
$form['tokenauth_text']['view']['token_help']['help'] = array(
'#value' => theme('token_help', array('user', 'global')),
);
}
$form['tokenauth_advanced'] = array(
'#type' => 'fieldset',
'#title' => t('Token actions'),
'#description' => t('Reset the tokens for all users. If you have changed token length, be sure to save that change before resetting all tokens.'),
);
$form['tokenauth_advanced']['tokenauth_reset'] = array(
'#type' => 'submit',
'#value' => t('Reset tokens')
);
return system_settings_form($form);
}
/**
* Validate callback.
*/
function tokenauth_admin_settings_validate($form, &$form_state) {
if ($form_state['values']['op'] == t('Reset tokens')) {
drupal_goto('admin/settings/tokenauth/reset');
}
if ($form_state['values']['tokenauth_length'] > 33) {
form_set_error('tokenauth_length', t('The maximum token length is 32.'));
}
}
/**
* Menu callback: confirm reset tokens.
*/
function tokenauth_reset_confirm() {
return confirm_form(array(), t('Are you sure you want to reset all tokens?'),
'admin/settings/tokenauth', t('After the tokens have been reset, all users who use tokenised URLs will have to update them. This action cannot be undone.'), t('Reset tokens'), t('Cancel'));
}
/**
* Handler for reset tokens confirmation
*/
function tokenauth_reset_confirm_submit(&$form_state) {
tokenauth_reset();
drupal_set_message(t('All tokens have been reset.'));
$form_state['#redirect'] = 'admin/settings/tokenauth';
}
/**
* Menu callback: confirm reset users token.
*/
function tokenauth_user_reset_confirm() {
if (arg(0) == 'user' && is_numeric(arg(1))) {
$uid = arg(1);
}
return confirm_form(
array('uid' => array('#type' => 'hidden', '#value' => $uid)),
t('Are you sure you want to reset this user token?'),
"user/$uid/tokenauth",
t('After the token has been reset, please update your feed readers or other applications that depend on them. This action cannot be undone.'),
t('Reset token'),
t('Cancel')
);
}
/**
* Handler for reset tokens confirmation
*/
function tokenauth_user_reset_confirm_submit($form, &$form_state) {
tokenauth_reset($form['uid']['#value']);
drupal_set_message(t('The token has been reset.'));
$form_state['redirect'] = 'user/' . $form['uid']['#value'] . '/tokenauth';
}
/**
* Menu callback. Prints the token and instructions.
*/
function tokenauth_user_profile_form(&$form_state, $account) {
drupal_set_title(check_plain($account->name));
$token = tokenauth_get_token($account->uid);
$form['preamble'] = array('#value' => tokenauth_text_load($account, TRUE));
if (!module_exists('token')) {
$form['preamble']['#value'] .= "" . t('Your token:') . " ?token=$token
";
}
$form = array_merge($form, tokenauth_reset_user_form($account->uid, NULL, $token));
return $form;
}