function advise_what_if_selection_form_submit
Search API
7.x advise.module | advise_what_if_selection_form_submit($form, $form_state) |
6.x advise.module | advise_what_if_selection_form_submit($form, $form_state) |
5.x advise.module | advise_what_if_selection_form_submit($form, $form_state) |
Submit handler for the what if selection form. Since at this point we have passed validation, let's just assemble the URL we need to now redirect to.
File
- modules/
advise/ advise.module, line 2115
Code
function advise_what_if_selection_form_submit($form, $form_state) {
$current_student_id = $form_state ["values"]["current_student_id"];
$catalog_year = $form_state ["values"]["catalog_year"];
// Get the major codes CSV
$what_if_major_code = "";
foreach (array(1, 2) as $num) {
if (isset($form_state ["values"]["select_level_{$num}_degrees"]) && is_array($form_state ["values"]["select_level_{$num}_degrees"])) {
foreach ($form_state ["values"]["select_level_{$num}_degrees"] as $k => $v) {
if ((string) $k === (string) $v && $k != "") {
$what_if_major_code .= $k . ",";
}
}
}
}
// Add in the tracks, too, if selected.
foreach ($form_state ["values"] as $key => $val) {
if (strstr($key, "L3__sel__")) {
if (is_array($val) && count($val) > 0) {
// Did the user select this item? Val's key and value will be identical if so.
foreach ($val as $k => $v) {
if ($k == $v && $k != "") {
// YES. It was selected!
//First, make sure it's top-level degree was even selected. If it wasn't, skip it, it doesn't matter.
$temp = explode("|_", $k);
$top_level_code = trim($temp [0]);
if (@$form_state ["values"]["select_level_1_degrees"][$top_level_code] != $top_level_code) {
if (@$form_state ["values"]["select_level_2_degrees"][$top_level_code] != $top_level_code) {
continue;
}
}
$what_if_major_code .= $k . ",";
}
}
} // if is_array val (cause it was a checkbox)
else if (is_string($val) && trim($val) != "") {
// This was from radio buttons.
//First, make sure it's top-level degree was even selected. If it wasn't, skip it, it doesn't matter.
$temp = explode("|_", $val);
$top_level_code = trim($temp [0]);
if (@$form_state ["values"]["select_level_1_degrees"][$top_level_code] != $top_level_code) {
if (@$form_state ["values"]["select_level_2_degrees"][$top_level_code] != $top_level_code) {
continue;
}
}
$what_if_major_code .= $val . ",";
}
}
}
// Remove training comma
$what_if_major_code = rtrim($what_if_major_code, ",");
// Okay, let's redirect the user to their proper destination
$query = "advising_what_if=yes&load_from_cache=no&window_mode=screen¤t_student_id=$current_student_id&what_if_major_code=$what_if_major_code&what_if_catalog_year=$catalog_year";
fp_goto("what-if", $query);
}