diff --git a/masquerade.module b/masquerade.module
index be5a94b..24ce3fc 100644
--- a/masquerade.module
+++ b/masquerade.module
@@ -546,7 +546,7 @@ function masquerade_block_view($delta = '') {
function masquerade_block_1() {
global $user;
$quick_switch_links = array();
- $markup_value = '';
+
if (isset($_SESSION['masquerading'])) {
$quick_switch_links[] = l(t('Switch back'), 'masquerade/unswitch', array('query' => array('token' => drupal_get_token('masquerade/unswitch'))));
if ($user->uid > 0) {
@@ -555,8 +555,37 @@ function masquerade_block_1() {
else {
$markup_value = t('You are masquerading as %anonymous.', array('%anonymous' => variable_get('anonymous', t('Anonymous'))));
}
+ $form['masquerade_desc'] = array(
+ '#prefix' => '
',
+ );
}
else {
+ // Add form to masquerade as any entered user.
+ if (masquerade_menu_access('autocomplete')) {
+ $form['masquerade_user_field'] = array(
+ '#prefix' => '',
+ '#type' => 'textfield',
+ '#size' => '18',
+ '#default_value' => '',
+ '#autocomplete_path' => 'masquerade/autocomplete',
+ '#required' => TRUE,
+ '#title' => t('Username'),
+ );
+ $form['submit'] = array(
+ '#type' => 'submit',
+ '#value' => t('Go'),
+ '#suffix' => '
',
+ );
+ }
+ // Add instructions for form above. Don't use description for input because
+ // this used for input and submit both.
+ $form['masquerade_desc'] = array(
+ '#prefix' => '',
+ );
$quick_switches = variable_get('masquerade_quick_switches', array());
// Add in user-specific switches, and prevent duplicates.
@@ -578,33 +607,15 @@ function masquerade_block_1() {
}
}
}
-
- if (masquerade_menu_access('autocomplete')) {
- $markup_value .= t('Enter the username to masquerade as.');
- $form['masquerade_user_field'] = array(
- '#prefix' => '',
- '#type' => 'textfield',
- '#size' => '18',
- '#default_value' => '',
- '#autocomplete_path' => 'masquerade/autocomplete',
- '#required' => TRUE,
- );
- $form['submit'] = array(
- '#type' => 'submit',
- '#value' => t('Go'),
- '#suffix' => '
',
- );
- }
-
}
+
if ($quick_switch_links) {
- $markup_value .= '' . t('Quick switches:') . theme('item_list', array('items' => $quick_switch_links)) . '
';
- }
- $form['masquerade_desc'] = array(
- '#prefix' => '',
- );
+ $form['masquerade_links'] = array(
+ '#theme' => 'item_list',
+ '#title' => t('Quick switches:'),
+ '#items' => $quick_switch_links,
+ );
+ };
return $form;
}