function user_edit_user_advisees_form_submit

7.x user.module user_edit_user_advisees_form_submit($form, $form_state)
6.x user.module user_edit_user_advisees_form_submit($form, $form_state)
5.x user.module user_edit_user_advisees_form_submit($form, $form_state)

Save to the advisor_student table

File

modules/user/user.module, line 1847

Code

function user_edit_user_advisees_form_submit($form, $form_state) {

  // Begin by clearing the table for this advisor.
  $faculty_cwid = trim($form_state ["values"]["faculty_cwid"]);
  db_query("DELETE FROM advisor_student WHERE faculty_id = ? ", $faculty_cwid);

  $students = trim($form_state ["values"]["students"]);
  $lines = explode("\n", $students);
  foreach ($lines as $line) {
    $temp = explode("#", $line);
    $line = trim($temp [0]);
    if ($line == "") {
      continue;
    }
    // Okay, $line should now contain the CWID.
    // Insert into db.  (use REPLACE to prevent an error if data was entered twice)
    db_query("REPLACE INTO advisor_student (faculty_id, student_id)
              VALUES (?, ?) ", $faculty_cwid, $line);

  }

  watchdog("user_edit_advisees", "Update faculty (@cwid) advisees values: @other", array("@cwid" => $faculty_cwid, "@other" => ppm($form_state ['values'], TRUE)));


  fp_add_message(t("The advisees have been updated for this faculty member."));

}