function user_edit_student_user_form_submit
Search API
7.x user.student.inc | user_edit_student_user_form_submit($form, $form_state) |
6.x user.student.inc | user_edit_student_user_form_submit($form, $form_state) |
4.x user.module | user_edit_student_user_form_submit($form, $form_state) |
5.x user.student.inc | user_edit_student_user_form_submit($form, $form_state) |
Submit handler for editing student users.
File
- modules/
user/ user.module, line 796
Code
function user_edit_student_user_form_submit($form, $form_state) {
$values = $form_state ["values"];
foreach ($values as $key => $val) {
if (!is_array($val)) {
$values [$key] = trim($val);
}
}
//fpm($values);
$user_id = $values ["user_id"];
$student_cwid = $values ["student_cwid"];
// Are we supposed to DELETE a student?
if ($values ["perform_action2"] == "delete_student" && user_has_permission("delete_users")) {
db_query("DELETE FROM students WHERE cwid = '?' ", $student_cwid);
db_query("DELETE FROM users WHERE cwid = '?' AND is_student = '1' ", $student_cwid);
fp_add_message(t("User has been deleted."));
fp_goto("admin/users/students");
return;
}
if ($student_cwid != "new") {
// NOT a new student! Insert values normally.
// First-- was there a password given? If so, insert that separate.
if (trim($values ["new_password"]) != "") {
$new_pass = md5(trim($values ["new_password"]));
db_query("UPDATE users
SET password = '?'
WHERE cwid = '?'
AND is_student = '1' ", $new_pass, $student_cwid);
}
// Okay, now we can just update everything else.
// Update users table first...
db_query("UPDATE users
SET email = '?',
f_name = '?',
l_name = '?',
is_disabled = '?'
WHERE cwid = '?'
AND is_student = '1' ", $values ["email"], $values ["f_name"],
$values ["l_name"], $values ["is_disabled"],
$student_cwid);
// Now, update the students table entry.
db_query("UPDATE students
SET cumulative_hours = '?',
gpa = '?',
rank_code = '?',
major_code = '?',
catalog_year = '?',
is_active = '?'
WHERE cwid = '?'", $values ["cumulative_hours"], $values ["gpa"], $values ["rank_code"],
$values ["major_code"], $values ["catalog_year"],
$values ["is_active"], $student_cwid);
}
else {
// This is a NEW user! We need to perform inserts. Thanks to our validate handler,
// we know all of the values we have are valid.
db_query("INSERT INTO users (user_name, password, is_student, email, cwid, f_name, l_name, is_disabled)
VALUES ('?', '?', '1', '?', '?', '?', '?', '?')
", $values ["new_user_name"], md5($values ["new_password"]), $values ["email"], $values ["new_student_cwid"],
$values ["f_name"], $values ["l_name"], $values ["is_disabled"]);
db_query("INSERT INTO students (cwid, cumulative_hours, gpa, rank_code, major_code, catalog_year, is_active)
VALUES ('?', '?', '?', '?', '?', '?', '?')
", $values ["new_student_cwid"], $values ["cumulative_hours"], $values ["gpa"], $values ["rank_code"],
$values ["major_code"], $values ["catalog_year"], $values ["is_active"]);
fp_add_message(t("User created successfully."));
fp_goto("admin/users/edit-student-user", "student_cwid=" . $values ["new_student_cwid"]);
}
fp_add_message(t("User updated successfully."));
}