function masquerade_form
Search API
7.x masquerade.module | masquerade_form() |
6.x masquerade.module | masquerade_form() |
This form will let the user specify which user they wish to impersonate.
File
- modules/
masquerade/ masquerade.module, line 107 - The masquerade module, which allows admin users to impersonate other users.
Code
function masquerade_form() {
$form = array();
$form ["mark" . $m++] = array(
"value" => "<p>" . t("Use this form to decide which user you wish to impersonate. Once selected,
you will experience FlightPath as that user would until you log out.") . "</p>",
);
$form ["username_or_cwid"] = array(
"label" => t("Last name, Email, Username, or CWID:"),
"type" => "textfield",
"value" => $_REQUEST ["username_or_cwid"],
"description" => t("Enter the last name, email, username, or CWID of the person you wish to impersonate. Will display the first 20 results only.
<br>Ex: peacocrj7 or 10022312."),
);
$form ["submit"] = array(
"type" => "submit",
"spinner" => TRUE,
"value" => t("Look up"),
);
$users = $_SESSION ["masquerade_lookup_users"];
if (is_array($users) && count($users) > 0) {
$form ["mark" . $m++] = array(
"value" => "<hr><p>" . t("Please click on the user you wish to impersonate:") . "</p>
<ul>",
);
$c = 0;
foreach ($users as $uid) {
$account = fp_load_user($uid);
$type = "";
if ($account->is_student) {
$type .= t("student");
}
if ($account->is_faculty) {
$type .= t("faculty");
}
$form ["mark" . $m++] = array(
"value" => "<li>" . l("$account->name - $account->f_name $account->l_name ($account->cwid) - $type", "masquerade", "user_id=$account->id") . "</li>",
);
$c++;
if ($c >= 20) {
break;
}
}
$form ["mark" . $m++] = array(
"value" => "</ul>",
);
unset($_SESSION ["masquerade_lookup_users"]);
}
else if (is_array($users)) {
$form ["mark" . $m++] = array(
"value" => "<hr><p>" . t("Sorry, no results.") . "</p>
<ul>",
);
unset($_SESSION ["masquerade_lookup_users"]);
}
return $form;
}