function masquerade_admin_settings_validate in Masquerade 6
Same name and namespace in other branches
- 7 masquerade.module \masquerade_admin_settings_validate()
1 string reference to 'masquerade_admin_settings_validate'
File
- ./
masquerade.module, line 255 - masquerade.module
Code
function masquerade_admin_settings_validate($form, &$form_state) {
if (!empty($form_state['values']['masquerade_test_user'])) {
$test_user = _masquerade_user_load($form_state['values']['masquerade_test_user']);
if (!$test_user) {
form_set_error('masquerade_test_user', t('%user does not exist. Please enter a valid username.', array(
'%user' => $form_state['values']['masquerade_test_user'],
)));
}
}
// Needs to rebuild menu in masquerade_admin_settings_submit().
$form_state['masquerade_rebuild_menu'] = variable_get('masquerade_test_user', '') != $form_state['values']['masquerade_test_user'];
// A comma-separated list of users.
$masquerade_switches = drupal_explode_tags($form_state['values']['masquerade_quick_switches']);
// Change user names to user ID's for system_settings_form_submit() to save.
$masquerade_uids = array();
foreach ($masquerade_switches as $switch_user) {
$test_user = _masquerade_user_load($switch_user);
if (!$test_user) {
form_set_error('masquerade_quick_switches', t('%user does not exist. Please enter a valid username.', array(
'%user' => $switch_user,
)));
}
else {
$masquerade_uids[] = $test_user->uid;
}
}
$form_state['values']['masquerade_quick_switches'] = $masquerade_uids;
}