| 1 |
<?php |
<?php |
| 2 |
// $Id: masquerade.module,v 1.16.2.25 2009/08/31 19:03:19 deviantintegral Exp $ |
// $Id: masquerade.module,v 1.16.2.26 2009/09/04 17:07:21 deviantintegral Exp $ |
| 3 |
|
|
| 4 |
/** |
/** |
| 5 |
* @file masquerade.module |
* @file masquerade.module |
| 368 |
$markup_value = ''; |
$markup_value = ''; |
| 369 |
if ($_SESSION['masquerading']) { |
if ($_SESSION['masquerading']) { |
| 370 |
$quick_switch_link[] = l(t('Switch back'), 'masquerade/unswitch', array()); |
$quick_switch_link[] = l(t('Switch back'), 'masquerade/unswitch', array()); |
| 371 |
$markup_value = t('You are masquerading as <a href="@user-url">%masq_as</a>.', array('@user-url' => url('user/' . $user->uid), '%masq_as' => $user->name)) . theme('item_list', $quick_switch_link); |
if ($user->uid > 0) { |
| 372 |
|
$markup_value = t('You are masquerading as <a href="@user-url">%masq_as</a>.', array('@user-url' => url('user/' . $user->uid), '%masq_as' => $user->name)) . theme('item_list', $quick_switch_link); |
| 373 |
|
} |
| 374 |
|
else { |
| 375 |
|
$markup_value = t('You are masquerading as %anonymous.', array('%anonymous' => variable_get('anonymous', t('Anonymous')))) . theme('item_list', $quick_switch_link); |
| 376 |
|
} |
| 377 |
} |
} |
| 378 |
else { |
else { |
| 379 |
$masquerade_switches = variable_get('masquerade_quick_switches', array()); |
$masquerade_switches = variable_get('masquerade_quick_switches', array()); |
| 394 |
} |
} |
| 395 |
|
|
| 396 |
if (masquerade_access('autocomplete')) { |
if (masquerade_access('autocomplete')) { |
| 397 |
$markup_value .= t('Enter username to masquerade as.') . '<br /><br />'; |
$markup_value .= t('Enter the username to masquerade as.') . '<br /><br />'; |
| 398 |
$form['masquerade_user_field'] = array( |
$form['masquerade_user_field'] = array( |
| 399 |
'#prefix' => '<div class="container-inline">', |
'#prefix' => '<div class="container-inline">', |
| 400 |
'#type' => 'textfield', |
'#type' => 'textfield', |
| 401 |
'#size' => '18', |
'#size' => '18', |
| 402 |
'#default_value' => $_SESSION['masquerading'] ? t('Switch back to use') : '', |
'#default_value' => $_SESSION['masquerading'] ? t('Switch back to use') : '', |
| 403 |
'#autocomplete_path' => 'masquerade/autocomplete', |
'#autocomplete_path' => 'masquerade/autocomplete', |
| 404 |
|
'#required' => TRUE, |
| 405 |
); |
); |
| 406 |
$form['submit'] = array( |
$form['submit'] = array( |
| 407 |
'#type' => 'submit', |
'#type' => 'submit', |
| 428 |
*/ |
*/ |
| 429 |
function masquerade_block_1_validate($form, &$form_state) { |
function masquerade_block_1_validate($form, &$form_state) { |
| 430 |
unset($form); |
unset($form); |
| 431 |
if ($form_state['values']['masquerade_user_field'] == 's') { |
$name = $form_state['values']['masquerade_user_field']; |
| 432 |
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')))); |
if ($name == variable_get('anonymous', t('Anonymous'))) { |
| 433 |
|
$name = ''; |
| 434 |
} |
} |
| 435 |
if ($_SESSION['masquerading']) { |
if ($_SESSION['masquerading']) { |
| 436 |
form_set_error('masquerade_user_field', t('You are already masquerading. Please <a href="@unswitch">switch back</a> to your account to masquerade as another user.', array('@unswitch' => url('masquerade/unswitch')))); |
form_set_error('masquerade_user_field', t('You are already masquerading. Please <a href="@unswitch">switch back</a> to your account to masquerade as another user.', array('@unswitch' => url('masquerade/unswitch')))); |
| 440 |
if (!$masq_user) { |
if (!$masq_user) { |
| 441 |
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']))); |
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']))); |
| 442 |
} |
} |
| 443 |
if ($masq_user->uid == $user->uid) { |
else if ($masq_user->uid == $user->uid) { |
| 444 |
form_set_error('masquerade_user_field', t('You cannot masquerade as yourself. Please choose a different user to masquerade as.')); |
form_set_error('masquerade_user_field', t('You cannot masquerade as yourself. Please choose a different user to masquerade as.')); |
| 445 |
} |
} |
| 446 |
if (variable_get('site_offline', 0)) { |
else if (variable_get('site_offline', 0)) { |
| 447 |
form_set_error('masquerade_user_field', t('It is not possible to masquerade in off-line mode. Please <a href="@site-maintenance">set the site status</a> to "online" to switch to masquerade.', array('@site-maintenance' => url('admin/settings/site-maintenance')))); |
form_set_error('masquerade_user_field', t('It is not possible to masquerade in off-line mode. Please <a href="@site-maintenance">set the site status</a> to "online" to switch to masquerade.', array('@site-maintenance' => url('admin/settings/site-maintenance')))); |
| 448 |
} |
} |
| 449 |
|
else { |
| 450 |
|
$form_state['values']['masquerade_user_field'] = $name; |
| 451 |
|
} |
| 452 |
} |
} |
| 453 |
|
|
| 454 |
/** |
/** |
| 469 |
while ($user = db_fetch_object($result)) { |
while ($user = db_fetch_object($result)) { |
| 470 |
$matches[$user->name] = check_plain($user->name); |
$matches[$user->name] = check_plain($user->name); |
| 471 |
} |
} |
| 472 |
|
$matches[variable_get('anonymous', t('Anonymous'))] = variable_get('anonymous', t('Anonymous')); |
| 473 |
if (module_exists('devel')) { |
if (module_exists('devel')) { |
| 474 |
$GLOBALS['devel_shutdown'] = FALSE; |
$GLOBALS['devel_shutdown'] = FALSE; |
| 475 |
} |
} |