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.
1 string reference to 'user_edit_user_form'
- schools_form_alter in modules/
schools/ schools.module - Implements hook_form_alter
File
- modules/
user/ user.module, line 1879
Code
function user_edit_user_form() {
fp_add_js(fp_get_module_path("user") . "/js/user.js");
$form = array();
$m = 0;
$faculty_cwid = strip_tags($_REQUEST ["faculty_cwid"]);
$user_id = db_get_user_id_from_cwid($faculty_cwid);
$school_id = db_get_school_id_for_user_id($user_id);
$de_catalog_year = @strip_tags($_REQUEST ["de_catalog_year"]);
$name = fp_get_faculty_name($faculty_cwid);
fp_set_title(t("Edit Faculty/Staff User @name (@id)", array("@name" => $name, "@id" => $faculty_cwid)));
// Figure out what the page's sub-tabs should be, and set them.
$tab_array = array();
$tab_array [0]["title"] = t("Edit Faculty/Staff User");
$tab_array [0]["active"] = TRUE;
$tab_array [0]["on_click"] = "window.location=\"" . fp_url("admin/users/edit-user", "faculty_cwid=$faculty_cwid&de_catalog_year=$de_catalog_year") . "\"";
$tab_array [1]["title"] = t("Edit Faculty Advisees");
$tab_array [1]["active"] = FALSE;
$tab_array [1]["on_click"] = "window.location=\"" . fp_url("admin/users/edit-user/advisees", "faculty_cwid=$faculty_cwid&de_catalog_year=$de_catalog_year") . "\"";
// If there are attributes for a student, then show the tab.
$attributes = user_get_registered_attributes();
foreach ($attributes as $def) {
if (@$def ['settings']['user_type'] == 'faculty' || @$def ['settings']['user_type'] == 'all') {
$tab_array [2]["title"] = t("Edit User Attributes");
$tab_array [2]["active"] = FALSE;
$tab_array [2]["on_click"] = "window.location=\"" . fp_url("admin/users/edit-user/attributes", "user_id=$user_id&user_type=faculty&faculty_cwid=$faculty_cwid&de_catalog_year=$de_catalog_year") . "\"";
break;
}
}
fp_set_page_sub_tabs($tab_array);
$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,
"weight" => 10,
);
}
/////////////////////
// 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 an alpha-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."),
"weight" => 20,
);
$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."),
"weight" => 30,
);
$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>",
"weight" => 40,
);
}
$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, SAML, or other external login module,
the external password will be unaffected."),
"weight" => 50,
);
$form ["email"] = array(
"label" => t("Email:"),
"type" => "textfield",
"value" => @$cur ["email"],
"weight" => 60,
);
$form ["f_name"] = array(
"label" => t("First name:"),
"type" => "textfield",
"value" => @$cur ["f_name"],
"weight" => 70,
);
$form ["l_name"] = array(
"label" => t("Last name:"),
"type" => "textfield",
"value" => @$cur ["l_name"],
"weight" => 80,
);
$form ["is_disabled"] = array(
"label" => t("Active/Disabled status:"),
"type" => "select",
"options" => array(0 => t("Active (default)"), 1 => t("Disabled")),
"hide_please_select" => TRUE,
"value" => @$cur ["is_disabled"],
"description" => t("If set to 'Disabled', 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 to delete them."),
"weight" => 90,
);
// Unique to faculty...
$form ["college"] = array(
"label" => t("College:"),
"type" => "textfield",
"value" => @$cur ["college"],
"size" => 5,
"weight" => 100,
);
$department_code = @$cur ['department_code'];
$departments = fp_get_departments($school_id);
$form ["department"] = array(
"label" => t("Department:"),
"type" => "select",
"options" => $departments,
"value" => $department_code,
"weight" => 110,
"description" => "Select which department this user belongs to (if any). Note: departments are defined on the 'Configure school settings' admin page.",
);
$form ["major_code_csv"] = array(
"label" => t("Major code CSV:"),
"type" => "textfield",
"value" => @$cur ["major_code_csv"],
"size" => 60,
"maxlength" => 255,
"description" => t("Enter the major codes which this faculty member is over, separated by commas. Ex: ACCT,MATH
<br>If the user is only over 1 major code, just enter that one major code."),
"weight" => 120,
);
// TXT lines (from the engagements module)
if (module_enabled('engagements')) {
$user_id = intval($form ['user_id']['value']);
$options = engagements_get_from_phones_for_fapi(TRUE);
$default_value = engagements_get_user_notify_sms_receipt_values($user_id);
if (count($options) > 0 && $user_id > 0) {
$form ['receive_notifications_from_numbers'] = array(
'type' => 'checkboxes',
'label' => t("Select the SMS/Text lines (if any) that this user should be notified of when receiving a Text message:"),
'options' => $options,
'value' => $default_value,
'weight' => 130,
'description' => t("Note: the user will always receive a notification if the sender is designated as one of this user's advisees."),
);
}
}
$form ["submit"] = array(
"type" => "submit",
"value" => "Submit",
"prefix" => "<hr>",
"weight" => 500,
);
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>",
"weight" => 600,
);
}
return $form;
}