function masquerade_form_submit
Search API
7.x masquerade.module | masquerade_form_submit($form, &$form_state) |
6.x masquerade.module | masquerade_form_submit($form, &$form_state) |
The submit handler for masquerade_form.
We want to look up the user(s) for the username or CWID entered, placing that information in the SESSION. When we return to the form, it will display these results for the user to select.
_state
Parameters
unknown_type $form:
File
- modules/
masquerade/ masquerade.module, line 186 - The masquerade module, which allows admin users to impersonate other users.
Code
function masquerade_form_submit($form, &$form_state) {
$username_or_cwid = trim($form_state ["values"]["username_or_cwid"]);
if ($username_or_cwid == "") {
return;
}
$users = array();
$res = db_query("SELECT user_id FROM users WHERE cwid LIKE ?
LIMIT 20", array("%$username_or_cwid%"));
while ($cur = db_fetch_array($res)) {
$users [intval($cur ['user_id'])] = $cur ['user_id'];
}
$res = db_query("SELECT user_id FROM users WHERE user_name LIKE ?
LIMIT 20", array("%$username_or_cwid%"));
while ($cur = db_fetch_array($res)) {
$users [intval($cur ['user_id'])] = $cur ['user_id'];
}
$res = db_query("SELECT user_id FROM users WHERE email LIKE ?
LIMIT 20", array("%$username_or_cwid%"));
while ($cur = db_fetch_array($res)) {
$users [intval($cur ['user_id'])] = $cur ['user_id'];
}
$res = db_query("SELECT user_id FROM users WHERE l_name LIKE ?
LIMIT 20", array("%$username_or_cwid%"));
while ($cur = db_fetch_array($res)) {
$users [intval($cur ['user_id'])] = $cur ['user_id'];
}
if (isset($users [1])) {
unset($users [1]); // do not allow admin user to be selected.
}
// Okay, let's add the users we found to the SESSION.
$_SESSION ["masquerade_lookup_users"] = $users;
}