function masquerade_block_1 in Masquerade 5
Same name and namespace in other branches
- 6 masquerade.module \masquerade_block_1()
- 7 masquerade.module \masquerade_block_1()
Masquerade block form.
1 string reference to 'masquerade_block_1'
- masquerade_block in ./
masquerade.module - Implementation of hook_block().
File
- ./
masquerade.module, line 224 - masquerade.module
Code
function masquerade_block_1($record) {
$attributes = $GLOBALS['masquerading'] ? array(
'disabled' => 'disabled',
) : array();
if ($GLOBALS['masquerading']) {
global $user;
$quick_switch_link[] = l(t('Switch back'), 'masquerade/unswitch', array());
$markup_value = t('You are masquerading as:<br />%masq_as', array(
'%masq_as' => $user->name,
)) . theme('item_list', $quick_switch_link);
}
else {
$masquerade_switches = variable_get('masquerade_quick_switches', array());
foreach ($masquerade_switches as $switch_user) {
if ($switch_user != $GLOBALS['user']) {
$user = user_load(array(
'uid' => $switch_user,
));
if ($user->name) {
$quick_switch_link[] = l($user->name, 'masquerade/switch/' . $switch_user);
}
}
}
if (isset($quick_switch_link) && count($quick_switch_link)) {
$markup_value .= '<div id="quick_switch_links">' . t('Quick switches:') . theme('item_list', $quick_switch_link) . '</div>';
}
$form['masquerade_user_field'] = array(
'#prefix' => '<div class="container-inline">',
'#type' => 'textfield',
'#size' => '20',
'#default_value' => $GLOBALS['masquerading'] ? t('Switch back to use') : $default_test_user->name,
'#attributes' => $attributes,
'#autocomplete_path' => 'masquerade/autocomplete',
'#description' => t('Enter username to masquerade.'),
);
$form['submit'] = array(
'#type' => 'submit',
'#value' => t('Go'),
'#attributes' => $attributes,
'#suffix' => '</div>',
);
}
$form['masquerade_desc'] = array(
'#prefix' => '<div class="form-item"><div class="description">',
'#type' => 'markup',
'#value' => $markup_value,
'#suffix' => '</div></div>',
);
return $form;
}