cvs diff: Diffing .
? .project
Index: masquerade.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/masquerade/masquerade.module,v
retrieving revision 1.16.2.26
diff -u -p -r1.16.2.26 masquerade.module
--- masquerade.module 4 Sep 2009 17:07:21 -0000 1.16.2.26
+++ masquerade.module 4 Sep 2009 21:03:09 -0000
@@ -368,7 +368,12 @@ function masquerade_block_1($record) {
$markup_value = '';
if ($_SESSION['masquerading']) {
$quick_switch_link[] = l(t('Switch back'), 'masquerade/unswitch', array());
- $markup_value = t('You are masquerading as %masq_as.', array('@user-url' => url('user/' . $user->uid), '%masq_as' => $user->name)) . theme('item_list', $quick_switch_link);
+ if ($user->uid > 0) {
+ $markup_value = t('You are masquerading as %masq_as.', array('@user-url' => url('user/' . $user->uid), '%masq_as' => $user->name)) . theme('item_list', $quick_switch_link);
+ }
+ else {
+ $markup_value = t('You are masquerading as %anonymous.', array('%anonymous' => variable_get('anonymous', 'Anonymous'))) . theme('item_list', $quick_switch_link);
+ }
}
else {
$masquerade_switches = variable_get('masquerade_quick_switches', array());
@@ -389,13 +394,14 @@ function masquerade_block_1($record) {
}
if (masquerade_access('autocomplete')) {
- $markup_value .= t('Enter username to masquerade as.') . '
';
+ $markup_value .= t('Enter the username to masquerade as.') . '
';
$form['masquerade_user_field'] = array(
'#prefix' => '
',
'#type' => 'textfield',
'#size' => '18',
'#default_value' => $_SESSION['masquerading'] ? t('Switch back to use') : '',
'#autocomplete_path' => 'masquerade/autocomplete',
+ '#required' => TRUE,
);
$form['submit'] = array(
'#type' => 'submit',
@@ -422,8 +428,9 @@ function masquerade_block_1($record) {
*/
function masquerade_block_1_validate($form, &$form_state) {
unset($form);
- if ($form_state['values']['masquerade_user_field'] == 's') {
- form_set_error('masquerade_user_field', t('You cannot masquerade as %anonymous. Please choose a different user to masquerade as.', array('%anonymous' => variable_get('anonymous', 'Anonymous'))));
+ $name = $form_state['values']['masquerade_user_field'];
+ if ($name == variable_get('anonymous', 'Anonymous')) {
+ $name = '';
}
if ($_SESSION['masquerading']) {
form_set_error('masquerade_user_field', t('You are already masquerading. Please
switch back to your account to masquerade as another user.', array('@unswitch' => url('masquerade/unswitch'))));
@@ -433,12 +440,15 @@ function masquerade_block_1_validate($fo
if (!$masq_user) {
form_set_error('masquerade_user_field', t('User %masq_as does not exist. Please enter a valid username.', array('%masq_as' => $form_state['values']['masquerade_user_field'])));
}
- if ($masq_user->uid == $user->uid) {
+ else if ($masq_user->uid == $user->uid) {
form_set_error('masquerade_user_field', t('You cannot masquerade as yourself. Please choose a different user to masquerade as.'));
}
- if (variable_get('site_offline', 0)) {
+ else if (variable_get('site_offline', 0)) {
form_set_error('masquerade_user_field', t('It is not possible to masquerade in off-line mode. Please
set the site status to "online" to switch to masquerade.', array('@site-maintenance' => url('admin/settings/site-maintenance'))));
}
+ else {
+ $form_state['values']['masquerade_user_field'] = $name;
+ }
}
/**
@@ -459,6 +469,7 @@ function masquerade_autocomplete($string
while ($user = db_fetch_object($result)) {
$matches[$user->name] = check_plain($user->name);
}
+ $matches[variable_get('anonymous', 'Anonymous')] = variable_get('anonymous', 'Anonymous');
if (module_exists('devel')) {
$GLOBALS['devel_shutdown'] = FALSE;
}