function user_edit_user_form
Search API
7.x user.module | user_edit_user_form() |
6.x user.module | user_edit_user_form() |
4.x user.module | user_edit_user_form() |
5.x user.module | user_edit_user_form() |
Let the user edit a user's roles and other information.
File
- modules/
user/ user.module, line 886
Code
function user_edit_user_form() {
fp_add_js(fp_get_module_path("user") . "/js/user.js");
$form = array();
$faculty_cwid = $_REQUEST ["faculty_cwid"];
$user_id = db_get_user_id_from_cwid($faculty_cwid);
$name = fp_get_faculty_name($faculty_cwid);
fp_set_title(t("Edit Faculty/Staff User @name (@id)", array("@name" => $name, "@id" => $faculty_cwid)));
$user_roles = system_get_roles_for_user($user_id);
//fpm($user_roles);
$default_values = array();
foreach ($user_roles as $rid => $val) {
$default_values [$rid] = $rid;
}
$form ["user_id"] = array(
"type" => "hidden",
"value" => $user_id,
);
$form ["perform_action2"] = array(
"type" => "hidden",
"value" => "",
);
$form ["faculty_cwid"] = array(
"type" => "hidden",
"value" => $faculty_cwid,
);
// Show a list of roles in the system which we may select from, and check the ones
// all ready assigned to this user.
if ($faculty_cwid != "new") {
// Not for new users, since we don't have a user_id for them yet.
$options = array();
$res = db_query("SELECT * FROM roles ORDER BY rid");
while ($cur = db_fetch_array($res)) {
$key = $cur ["rid"];
$value = $cur ["name"];
if ($key > 2) {
$options [$key] = $value;
}
}
//fpm($default_values);
$form ["roles"] = array(
"label" => t("Check which roles this user should have."),
"type" => "checkboxes",
"options" => $options,
"value" => $default_values,
);
}
/////////////////////
// Let's present the form elements to allow some basic editing of this user.
// Only if we are making a new user...
if ($faculty_cwid == "new") {
$form ["new_faculty_cwid"] = array(
"label" => t("Enter a new CWID, unique to faculty:"),
"type" => "textfield",
"size" => 20,
"required" => TRUE,
"description" => t("Enter a numeric ID for this faculty. It may be the same
as a student, but may not be the same as any existing
faculty. You will not be able to edit this value, once saved."),
);
$form ["new_user_name"] = array(
"label" => t("Enter a new username, unique to all users:"),
"type" => "textfield",
"size" => 20,
"required" => TRUE,
"description" => t("Enter a username for this user. This is what the user will
use to log in. It must be unique to all users (cannot have both
a faculty and a student with the same username). You will not
be able to edit this value, once saved."),
);
$cur = array();
}
else {
// NOT a new faculty. Load their information normally.
$res = db_query("SELECT * FROM users u, faculty s
WHERE u.cwid = '?'
AND u.is_faculty = '1'
AND u.cwid = s.cwid", $faculty_cwid);
$cur = db_fetch_array($res);
}
$user_name = $cur ["user_name"];
if ($user_name != "") {
$form ["mark" . $m++] = array(
"value" => "<p><b>Username:</b> $user_name</p>",
);
}
$form ["new_password"] = array(
"label" => t("Enter a new password for this user:"),
"type" => "textfield",
"size" => 20,
"required" => ($faculty_cwid == "new") ? TRUE : FALSE,
"description" => t("If you enter any value here, it will change the
user's password in FlightPath. If you are using the LDAP module,
the LDAP password will be unaffected."),
);
$form ["email"] = array(
"label" => t("Email:"),
"type" => "textfield",
"value" => $cur ["email"],
);
$form ["f_name"] = array(
"label" => t("First name:"),
"type" => "textfield",
"value" => $cur ["f_name"],
);
$form ["l_name"] = array(
"label" => t("Last name:"),
"type" => "textfield",
"value" => $cur ["l_name"],
);
$form ["is_disabled"] = array(
"label" => t("Is disabled:"),
"type" => "textfield",
"value" => $cur ["is_disabled"],
"size" => 5,
"description" => t("Enter only 1 or 0 (number one for 'yes', or number zero for 'no'). This setting means the user will
be ignored by FlightPath, and they will not be able to log in or be searched for.
It is safer to disable a user, than delete them."),
);
// Unique to faculty...
$form ["college"] = array(
"label" => t("College:"),
"type" => "textfield",
"value" => $cur ["college"],
"size" => 5,
);
$form ["department"] = array(
"label" => t("Department:"),
"type" => "textfield",
"value" => $cur ["department"],
"size" => 30,
);
$form ["major_code"] = array(
"label" => t("Major code:"),
"type" => "textfield",
"value" => $cur ["major_code"],
"size" => 10,
);
$form ["submit"] = array(
"type" => "submit",
"value" => "Submit",
"prefix" => "<hr>",
);
if ($faculty_cwid != "new" && user_has_permission("delete_users")) {
$form ["mark" . $m++] = array(
"type" => "markup",
"value" => "<div align='right'>
" . t("Delete this faculty member?") . " <input type='button' value='X'
onClick='userDeleteFaculty();'>
</div>",
);
}
return $form;
}