advise.module
Search API
- 7.x modules/advise/advise.module
- 6.x modules/advise/advise.module
- 4.x modules/advise/advise.module
- 5.x modules/advise/advise.module
File
modules/advise/advise.moduleView source
- <?php
-
-
- function advise_menu() {
- $items = array();
-
-
- $items["admin-tools/toggle-draft"] = array(
- "title" => "Toggle Draft Mode",
- "page_callback" => "fp_render_form",
- "page_arguments" => array("advise_toggle_draft_form"),
- "access_arguments" => array("toggle_draft"),
- "page_settings" => array(
- "menu_links" => array(
- 0 => array(
- "text" => "Back to Main",
- "path" => "main",
- ),
- ),
- ),
- "type" => MENU_TYPE_TAB,
- "tab_parent" => "main",
- );
-
-
- $items["admin-tools/clear-advising-cache"] = array(
- "title" => "Clear advising cache",
- "page_callback" => "advise_perform_clear_advising_cache",
- "access_arguments" => array("toggle_draft"),
- "type" => MENU_TYPE_NORMAL_ITEM,
- );
-
-
- $items["view"] = array(
- "title" => "View",
- "page_callback" => "advise_display_view",
- "page_arguments" => array("view"),
- "access_callback" => "advise_can_access_view",
- "tab_family" => "system",
- "page_settings" => array (
- "display_currently_advising" => TRUE,
- "display_greeting" => TRUE,
- "page_has_search" => TRUE,
- ),
- "weight" => 30,
- "type" => MENU_TYPE_TAB,
- );
-
-
- $items["view/print"] = array(
- "title" => "View",
- "page_callback" => "advise_display_view",
- "page_arguments" => array("view"),
- "access_callback" => TRUE,
- "page_settings" => array (
- "display_currently_advising" => TRUE,
- "bool_print" => TRUE,
- "screen_mode" => "not_advising",
- ),
- "type" => MENU_TYPE_CALLBACK,
- );
-
-
-
- $items["what-if"] = array(
- "title" => "What If?",
- "page_callback" => "advise_display_view",
- "page_arguments" => array("what-if"),
- "access_callback" => "advise_can_access_view",
- "tab_family" => "system",
- "page_settings" => array (
- "display_currently_advising" => TRUE,
- "display_greeting" => TRUE,
- "page_has_search" => TRUE,
- ),
- "weight" => 60,
- "type" => MENU_TYPE_TAB,
- );
-
-
- $items["what-if/print"] = array(
- "title" => "What If?",
- "page_callback" => "advise_display_view",
- "page_arguments" => array("what-if"),
- "access_callback" => TRUE,
- "page_settings" => array (
- "display_currently_advising" => TRUE,
- "bool_print" => TRUE,
- "screen_mode" => "not_advising",
- ),
- "type" => MENU_TYPE_CALLBACK,
- );
-
-
-
-
- $items["history"] = array(
- "title" => "History",
- "page_callback" => "advise_display_history",
- "access_callback" => "advise_can_access_view",
- "tab_family" => "system",
- "page_settings" => array (
- "display_currently_advising" => TRUE,
- "display_greeting" => TRUE,
- "page_has_search" => TRUE,
- ),
- "weight" => 40,
- "type" => MENU_TYPE_TAB,
- "file" => menu_get_module_path("advise") . "/advise.history.inc",
- );
-
-
-
- // My popups....
-
-
- $items["advise/popup-display-summary"] = array(
- "title" => "Advising Summary",
- "page_callback" => "advise_popup_display_summary",
- "access_callback" => "advise_user_can_view_advising_session_access_callback",
- "page_settings" => array(
- "page_is_popup" => TRUE,
- "page_hide_report_error" => TRUE,
- "bool_print" => TRUE,
- ),
- "type" => MENU_TYPE_CALLBACK,
- "file" => menu_get_module_path("advise") . "/advise.history.inc",
-
- );
-
-
- $items["advise/popup-change-term"] = array(
- "title" => "Change advising term",
- "page_callback" => "advise_display_popup_change_term",
- "access_arguments" => array("can_advise_students"),
- "page_settings" => array(
- "page_is_popup" => TRUE,
- "page_hide_report_error" => TRUE,
- ),
- "type" => MENU_TYPE_CALLBACK,
- );
-
- $items["advise/popup-change-track"] = array(
- "title" => "Change advising track",
- "page_callback" => "advise_display_popup_change_track",
- "access_arguments" => array("access_logged_in_content"),
- "page_settings" => array(
- "page_is_popup" => TRUE,
- "page_hide_report_error" => TRUE,
- ),
- "type" => MENU_TYPE_CALLBACK,
- );
-
-
-
- $items["advise/popup-course-description"] = array(
- "title" => "Description",
- "page_callback" => "advise_display_popup_course_description",
- "access_callback" => TRUE,
- "page_settings" => array(
- "page_is_popup" => TRUE,
- "page_hide_report_error" => TRUE,
- ),
- "weight" => 10,
- );
-
-
- $items["advise/popup-substitute-selected"] = array(
- "title" => "Substitute",
- "page_callback" => "advise_display_popup_substitute_selected",
- "access_arguments" => array("can_substitute"),
- "page_settings" => array(
- "page_is_popup" => TRUE,
- "page_hide_report_error" => TRUE,
- ),
- "weight" => 10,
- );
-
-
- $items["advise/popup-group-select"] = array(
- "title" => "Select",
- "page_callback" => "advise_display_popup_group_select",
- "access_callback" => TRUE,
- "page_settings" => array(
- "page_is_popup" => TRUE,
- "page_hide_report_error" => TRUE,
- ),
- "weight" => 10,
- );
-
-
- // Toolbox...
-
- $items["advise/popup-toolbox/transfers"] = array(
- "title" => "Transfers",
- "page_callback" => "advise_display_popup_toolbox_transfers",
- "access_arguments" => array("can_substitute"),
- "page_settings" => array(
- "page_is_popup" => TRUE,
- "page_hide_report_error" => TRUE,
- ),
- "weight" => 10,
- "type" => MENU_TYPE_TAB,
- "tab_family" => "advise-toolbox",
- "file" => menu_get_module_path("advise") . "/advise.toolbox.inc",
- );
-
- $items["advise/popup-toolbox/substitutions"] = array(
- "title" => "Substitutions",
- "page_callback" => "advise_display_popup_toolbox_substitutions",
- "access_arguments" => array("can_substitute"),
- "page_settings" => array(
- "page_is_popup" => TRUE,
- "page_hide_report_error" => TRUE,
- ),
- "weight" => 20,
- "type" => MENU_TYPE_TAB,
- "tab_family" => "advise-toolbox",
- "file" => menu_get_module_path("advise") . "/advise.toolbox.inc",
- );
-
- $items["advise/popup-toolbox/moved"] = array(
- "title" => "Moved",
- "page_callback" => "advise_display_popup_toolbox_moved",
- "access_arguments" => array("can_substitute"),
- "page_settings" => array(
- "page_is_popup" => TRUE,
- "page_hide_report_error" => TRUE,
- ),
- "weight" => 30,
- "type" => MENU_TYPE_TAB,
- "tab_family" => "advise-toolbox",
- "file" => menu_get_module_path("advise") . "/advise.toolbox.inc",
- );
-
- $items["advise/popup-toolbox/courses"] = array(
- "title" => "Courses",
- "page_callback" => "advise_display_popup_toolbox_courses",
- "access_arguments" => array("can_substitute"),
- "page_settings" => array(
- "page_is_popup" => TRUE,
- "page_hide_report_error" => TRUE,
- ),
- "weight" => 40,
- "type" => MENU_TYPE_TAB,
- "tab_family" => "advise-toolbox",
- "file" => menu_get_module_path("advise") . "/advise.toolbox.inc",
- );
-
-
-
- return $items;
- }
-
-
- /**
- * Used by the menu to determine if the user can see the View tab for the current student.
- */
- function advise_can_access_view($student_id = "") {
- global $current_student_id, $user;
-
- if ($student_id == "") $student_id = $current_student_id;
-
-
- // must be logged in first...
- if (!user_has_permission("access_logged_in_content")) return FALSE;
-
- if ($student_id == "" || $student_id === 0) return FALSE;
-
- if ($user->id == 1) return TRUE; // the admin user.
-
- // Can the user view ANY advising session?
- if (user_has_permission("view_any_advising_session")) return TRUE;
-
- // can the user only see their own advisees, and is this student one of their advisees?
- if (user_has_permission("view_advisee_advising_session")) {
- // Is the student_id in their list of advisees?
- $advisees = advise_get_advisees();
-
- if (in_array($student_id, $advisees)) return TRUE;
- }
-
- // Is this user viewing THEIR OWN advising session?
- if (user_has_permission("view_own_advising_session")) {
-
- if ($student_id == $user->cwid && ($student_id != "" && $student_id !== 0)) return TRUE;
- }
-
-
- // All else fails, return FALSE
- return FALSE;
-
- }
-
- function advise_get_advisees($faculty_id = "") {
- global $user;
- if ($faculty_id == "") $faculty_id = $user->cwid;
-
- $rtn = array();
-
- $res = db_query("SELECT * FROM advisor_student WHERE faculty_id = ?", $faculty_id);
- foreach ($res as $cur) {
- $rtn[] = $cur["student_id"];
- }
-
-
- return $rtn;
- }
-
-
- function advise_toggle_draft_form() {
- $form = array();
-
- $form["mark" . $m++] = array(
- "value" => "<p>" . t("By turning Draft Mode on, you will be able
- to view degree plans which are still in 'Draft' mode
- in both the regular View tab, as well as the Blank Degrees module,
- if enabled.") . "</p>",
- );
-
- $form["draft"] = array(
- "type" => "radios",
- "label" => t("Enable Draft Mode?"),
- "options" => array("yes" => t("Yes"), "no" => t("No")),
- "value" => $_SESSION["fp_draft_mode"],
- );
-
- $form["submit"] = array(
- "type" => "submit",
- "value" => t("Submit"),
- "prefix" => "<hr>",
- );
-
- $form["#redirect"] = array(
- "path" => "main",
- "query" => "",
- );
-
- return $form;
- }
-
-
- function advise_toggle_draft_form_submit($form, $form_state) {
- fp_add_message(t("Draft mode successfully updated."));
- $_SESSION["fp_draft_mode"] = $form_state["values"]["draft"];
- }
-
-
- /**
- * Lets the user change the track for this degree.
- */
-
- function z__old__advise_display_popup_change_track() {
- global $degree_plan, $student;
- $rtn = "";
-
- advise_init_screen();
-
- fp_add_js(fp_get_module_path("advise") . "/js/advise.js");
-
-
-
- $degree_plan->load_descriptive_data();
- $rtn .= fp_render_curved_line(t("Select a Degree Option"));
- $rtn .= "<div class='tenpt'>
- " . t("The student's degree has one or more degree options, which affects which courses are required.
- Please select a degree option (or track) from the list below.") . "
- <br><br>
- " . t("If you are unsure of what to do, simply close this window.");
-
-
- $rtn .= "<br><br><b>" . $degree_plan->title . "</b> " . t("degree options:") . "</div><!--DEFAULT-->
- <ul>";
-
- // Get the list of available tracks for this student.
- if (!$tracks = $degree_plan->get_available_tracks())
- {
- $rtn .= "<li>" . t("This major has no degree options.") . "</li>";
- }
-
- // Is there a "default" message for all tracks, which will override
- // any other track descriptions?
- // We need to look through all the tracks for the
- // characters: "DEFAULT:"
- // If we find this, then this is the default description
- // which applies to all the tracks, and it should be displayed
- // at the top.
- $bool_default_description = false;
- for ($t = 0; $t < count($tracks); $t++)
- {
- $temp = explode(" ~~ ", $tracks[$t]);
- $track_code = trim($temp[0]);
- $track_title = trim($temp[1]);
- $track_description = trim($temp[2]);
-
- if (strstr($track_description, "DEFAULT:")) {
- // Yes! We found a default message.
- $bool_default_description = true;
- $track_description = filter_markup(trim(str_replace("DEFAULT:", "", $track_description)));
- $track_description = "<div style='padding-top: 10px;' class='tenpt'>$track_description</div>";
- $rtn = str_replace("<!--DEFAULT-->",$track_description, $rtn);
- break;
- }
-
- }
-
-
- for ($t = 0; $t < count($tracks); $t++)
- {
- $temp = explode(" ~~ ", $tracks[$t]);
- $track_code = trim($temp[0]);
- $track_title = trim($temp[1]);
- $track_description = "";
-
- // If this is the current track_code, mark it as such.
- if ($student->array_settings["track_code"] == $track_code
- && $student->array_settings["major_code"] == $degree_plan->major_code)
- {
- $track_title .= " <b>(" . t("current") . ")</b>";
- }
-
- if ($bool_default_description == false)
- {
- $track_description = filter_markup(trim($temp[2]));
- if ($track_description != "")
- {
- $track_description = " - $track_description";
- }
- }
-
- $temp_tc = $track_code;
- if ($temp_tc == "")
- {
- $temp_tc = "none";
- }
-
-
- $link = fp_get_js_confirm_link(t("Are you sure you wish to change degree options?"), "opener.changeTrack(\"$temp_tc\"); window.close(); ", $track_title);
-
- if ($GLOBALS["fp_advising"]["advising_what_if"] == "yes") {
- $link = "<a href='javascript: popupChangeWhatIfTrack(\"$temp_tc\", \"" . t("Are you sure you wish to change degree options?") . "\");'>$track_title</a>";
- }
-
- $rtn .= "<li class='tenpt' style='padding:3px;'>
- $link $track_description</li>";
-
- }
-
- $rtn .= "</ul>";
-
-
-
- return $rtn;
- }
-
-
-
-
-
- /**
- * This is the "change track" popup we will display if the degree cannot be combined with anything else (non-dynamic).
- *
- * We will basically treat it similarly to how FlightPath 4x did things.
- */
- function advise_display_popup_change_track_non_dynamic_degree() {
- global $degree_plan, $student;
- $rtn = "";
-
- $db = get_global_database_handler();
-
-
- // Find out what track the user is already on.
-
- // From What If mode...
- if (@$GLOBALS["fp_advising"]["advising_what_if"] == "yes") {
- $student_majors_array = @csv_to_array($_SESSION["what_if_major_code" . $student->student_id]);
- }
- else {
- // Not in what if mode-- get the data from the normal student_majors table.
- $student_majors_array = fp_get_student_majors($student->student_id, FALSE, FALSE);
- } //else
-
-
-
-
- $degree_plan->load_descriptive_data();
-
- $major_code = $degree_plan->major_code;
- $catalog_year = $degree_plan->catalog_year;
- $bare_degree_plan = $degree_plan;
- // Are we already on a track? If so, find out what the original degree was.
- if (strstr($major_code, "_")) {
-
- $temp = explode("_", $major_code);
- $m = trim($temp[0]);
- // Remove trailing | if its there.
- $m = rtrim($m, "|");
- $bare_degree_plan = $db->get_degree_plan($m, $catalog_year); // the original degree plan (bare, no tracks)
- $major_code = $m;
- }
-
- $just_major_code = $major_code;
- $temp = explode("_" , $just_major_code);
- $just_major_code = $temp[0];
- $just_major_code = rtrim($just_major_code, "|");
-
-
-
- $rtn .= fp_render_curved_line(t("Select a Degree Option"));
- $rtn .= "<div class='tenpt'>
- " . t("The student's degree has one or more degree options, which affects which courses are required.
- Please select a degree option (or track) from the list below.") . "
- <br><br>
- " . t("If you are unsure of what to do, simply close this window.") . "
- </div>
- ";
-
- $rtn .= "<br><br><b>" . $bare_degree_plan->title . "</b> " . t("degree options:") . "<!--DEFAULT-->
- <ul>";
-
- // Get the list of available tracks for this degree.
- if (!$tracks = $bare_degree_plan->get_available_tracks())
- {
- $rtn .= "<li>" . t("This major has no degree options.") . "</li>";
- }
-
- // Is there a "default" message for all tracks, which will override
- // any other track descriptions?
- // We need to look through all the tracks for the
- // characters: "DEFAULT:"
- // If we find this, then this is the default description
- // which applies to all the tracks, and it should be displayed
- // at the top.
- $bool_default_description = false;
- for ($t = 0; $t < count($tracks); $t++)
- {
- $temp = explode(" ~~ ", $tracks[$t]);
- $track_code = trim($temp[0]);
- $track_title = trim($temp[1]);
- $track_description = trim($temp[2]);
-
- if (strstr($track_description, "DEFAULT:")) {
- // Yes! We found a default message.
- $bool_default_description = true;
- $track_description = filter_markup(trim(str_replace("DEFAULT:", "", $track_description)));
- $track_description = "<div style='padding-top: 10px;' class='tenpt'>$track_description</div>";
- $rtn = str_replace("<!--DEFAULT-->",$track_description, $rtn);
- break;
- }
-
- }
-
-
- for ($t = 0; $t < count($tracks); $t++)
- {
- $temp = explode(" ~~ ", $tracks[$t]);
- $track_code = trim($temp[0]);
- $track_title = trim($temp[1]);
- $track_description = "";
-
- $temp_tc = $track_code;
- if ($temp_tc == "")
- {
- $temp_tc = "none";
- }
-
-
- $major_and_track_code = $just_major_code;
-
- if ($temp_tc != "none") {
- if (!strstr($major_and_track_code, "|")) {
- $major_and_track_code .= "|";
- }
- $major_and_track_code .= "_" . $temp_tc;
- }
-
-
-
- // If this is the current track_code, mark it as such.
- if (in_array($major_and_track_code, $student_majors_array)) {
- $track_title .= " <b>(" . t("current") . ")</b>";
- }
-
-
- if ($bool_default_description == false)
- {
- $track_description = filter_markup(trim($temp[2]));
- if ($track_description != "")
- {
- $track_description = " - $track_description";
- }
- }
-
-
- // We need the track's degree id.
- $trid = $db->get_degree_id($major_and_track_code, $catalog_year);
-
-
- if ($trid == $bare_degree_plan->degree_id) $trid = ""; // don't use anything for the "none" option (the "orignal" degree plan)
-
-
- $link = fp_get_js_confirm_link(t("Are you sure you wish to change degree options?"), "opener.changeTrackNonDynamicDegree(\"$trid\"); window.close(); ", $track_title);
-
- if ($GLOBALS["fp_advising"]["advising_what_if"] == "yes") {
- $link = "<a href='javascript: popupChangeWhatIfTrackNonDynamicDegree(\"$major_and_track_code\", \"" . t("Are you sure you wish to change degree options?") . "\");'>$track_title</a>";
- }
-
- $rtn .= "<li class='tenpt' style='padding:3px;'>
- $link $track_description</li>";
-
- }
-
- $rtn .= "</ul>";
-
-
-
- return $rtn;
- } // popup_change_track_non_dynamic_degree
-
-
-
-
-
-
- function advise_display_popup_change_track() {
- global $degree_plan, $student;
- $rtn = "";
-
- advise_init_screen();
-
- fp_add_js(fp_get_module_path("advise") . "/js/advise.js");
- fp_add_css(fp_get_module_path("advise") . "/css/advise.css");
-
-
- if ($degree_plan->db_allow_dynamic == 0) {
-
- // Since this is NOT a degree plan which can be combined with others, we
- // want to display this popup like in FlightPath 4.x.
- return advise_display_popup_change_track_non_dynamic_degree();
-
- }
-
-
- $top_level_majors_csv = "";
-
- $degree_plan_array = array();
- if ($degree_plan->is_combined_dynamic_degree_plan == FALSE) {
- // NOT a combined degree plan. Just use the 1 degree plan we gots.
- $degree_plan_array[$degree_plan->degree_id] = $degree_plan;
-
- }
- else {
- // It IS a combined degree plan, so we need to get all the plans out of there.
- foreach ($degree_plan->combined_degree_ids_array as $t_degree_id) {
- $t_degree_plan = fp_load_degree($t_degree_id);
- $t_degree_plan->load_descriptive_data();
-
- if ($t_degree_plan->get_available_tracks()) {
- }
-
- $degree_plan_array[$t_degree_plan->degree_id] = $t_degree_plan;
-
- }
- }
-
-
-
- $locked_array = array(); // keep track of any degree classes which are "locked".
-
- // From What If mode...
- if (@$GLOBALS["fp_advising"]["advising_what_if"] == "yes") {
- $student_majors_array = @csv_to_array($_SESSION["what_if_major_code" . $student->student_id]);
- }
- else {
- // Not in what if mode-- get the data from the normal student_majors table.
- $student_majors_array = fp_get_student_majors($student->student_id, FALSE, TRUE);
-
- // Also see if any degree classes should be "locked" for this student.
- $db = get_global_database_handler();
- $temp = $db->get_student_majors_from_db($student->student_id, FALSE, FALSE, FALSE);
- foreach ($temp as $line) {
- $t = explode("~", $line);
- if (trim(strtoupper($t[0])) == "LOCKED") {
- $locked_array[] = trim($t[1]);
- }
- }
-
- } //else
-
-
-
-
- $rtn .= fp_render_curved_line(t("Select a Degree Option"));
- $rtn .= "<div class='tenpt'>
- " . t("The student's degree has one or more degree options, which affects which courses are required.
- Please select a degree option (or track) from the list below.") . "
- <br><br>
- " . t("If you are unsure of what to do, simply close this window.") . "
- </div>
- ";
-
- // Loop through available degrees here
- foreach ($degree_plan_array as $t_degree_plan) {
-
- $t_degree_plan->load_descriptive_data();
-
- // Skip any degree plan that isn't level 1 or level 2. In other words,
- // if this is already a track, then skip it.
- $details = fp_get_degree_classification_details($t_degree_plan->degree_class);
-
- if ($details["level_num"] == 3) continue;
-
-
- // Go through each type of classification in this degree's track_selection_config_array.
- //foreach ($t_degree_plan->track_selection_config_array as $machine_name => $tdetails) {
- $degree_classes = fp_get_degree_classifications();
-
- foreach ($degree_classes["levels"][3] as $machine_name => $class_title) {
-
- $extra_css_class = "";
- $class_is_empty = TRUE;
- $is_locked = FALSE;
- if (in_array($machine_name, $locked_array)) {
- $is_locked = TRUE;
- $extra_css_class = "degree-class-is-locked";
- }
-
- $html = "";
-
- $min_max_options = "";
- // Check to see what we have in this degree's track_selection_config_array
- $min_tracks = @intval($t_degree_plan->track_selection_config_array[$machine_name]["min_tracks"]);
- $max_tracks = @intval($t_degree_plan->track_selection_config_array[$machine_name]["max_tracks"]);
- $default_tracks = @trim($t_degree_plan->track_selection_config_array[$machine_name]["default_tracks"]);
- $default_tracks_array = csv_to_array($default_tracks);
-
-
- $degree_id = $t_degree_plan->degree_id;
-
-
-
- // Add this information to our javascript settings...
- $js = array(
- "degree_min_max_tracks_" . $degree_id . "_split_" . $machine_name => $min_tracks . "~" . $max_tracks,
- "degree_name_" . $degree_id => $t_degree_plan->get_title2(FALSE, FALSE, FALSE),
- "class_title_" . $machine_name => $class_title,
- );
-
- fp_add_js($js, "setting");
-
- $min_max_options = "<div class='advise-select-track-min-max advise-select-track-between'>Please select between $min_tracks and $max_tracks $class_title options.</div>";
- if ($min_tracks == $max_tracks && $max_tracks == 1) {
- $min_max_options = "<div class='advise-select-track-min-max advise-select-track-exactly-one'>Please select 1 $class_title option.</div>";
- }
-
- if ($min_tracks > 0 && $max_tracks == 0) {
- // Meaning, there is no maximum. It's infinite.
- $min_max_options = "<div class='advise-select-track-min-max advise-select-track-at-least-one'>Please select at least $min_tracks $class_title option(s) for this degree.</div>";
- }
-
- if ($min_tracks == $max_tracks && $max_tracks == 0) {
- $min_max_options = "<div class='advise-select-track-min-max advise-select-track-optional'>Optional: You are not required to select any additional $class_title options.</div>";
- }
-
-
-
- // Let's look to see what "tracks" this degree has.
-
- $html .= "<br>
- <div class='advise-track-selection-tracks $extra_css_class'>
- <div class='tenpt'><span class='advise-select-degree-title'>" . $t_degree_plan->title . "</span> <span class='advise-select-class-title'>$class_title</span> options:</div>
- <div class='advise-track-min-max-options advise-track-min-$min_tracks advise-track-max-$max_tracks'>$min_max_options</div>
- <!--DEFAULT_$machine_name-->
- <div class='advise-track-options-region'>
- ";
-
- $major_code = $t_degree_plan->major_code;
-
- $top_level_majors_csv .= $major_code . ",";
-
- // Get the list of available tracks for this student.
- if (!$tracks = $t_degree_plan->get_available_tracks())
- {
- $html .= "<div class='advise-select-track-none'> • " . t("This degree has no degree options.") . "</div>";
- }
-
- // Is there a "default" message for all tracks, which will override
- // any other track descriptions?
- // We need to look through all the tracks for the
- // characters: "DEFAULT:"
- // If we find this, then this is the default description
- // which applies to all the tracks, and it should be displayed
- // at the top.
- $bool_default_description = false;
- for ($t = 0; $t < count($tracks); $t++)
- {
- $temp = explode(" ~~ ", $tracks[$t]);
- $track_code = trim(@$temp[0]);
- $track_title = trim(@$temp[1]);
- $track_description = trim(@$temp[2]);
-
- // if this track is NOT of the same classification as the current machine_code, we skip it.
- $track_machine_name = trim(@$temp[4]);
-
- if ($track_machine_name != $machine_name) continue; // not the right degree_class
-
- if (strstr($track_description, "DEFAULT:")) {
- // Yes! We found a default message.
- $bool_default_description = true;
- $track_description = filter_markup(trim(str_replace("DEFAULT:", "", $track_description)));
- $track_description = "<div style='padding-top: 10px;' class='tenpt advise-select-track-description'>$track_description</div>";
- $html = str_replace("<!--DEFAULT_$machine_name-->",$track_description, $rtn);
- break;
- }
-
- }
-
- ///////////////////
- // Okay, go through the tracks,
-
- for ($t = 0; $t < count($tracks); $t++)
- {
- $temp = explode(" ~~ ", $tracks[$t]);
- $track_code = trim(@$temp[0]);
- $track_title = trim(@$temp[1]);
- $track_degree_id = intval(trim(@$temp[3]));
- $track_description = "";
-
- // if this track is NOT of the same classification as the current machine_code, we skip it.
- $track_machine_name = trim(@$temp[4]);
- if ($track_machine_name != $machine_name) continue; // not the right degree_class
-
-
- $selected = $disabled = "";
-
- // If this track has been selected already, mark it as such
- if (isset($degree_plan_array[$track_degree_id])) {
- // Meaning yes, this was already selected for this student.
- $selected = "checked=checked";
- }
-
- // Is this track marked as NOT is_editable?
- $is_editable = 1;
- if (isset($student_majors_array[$t_degree_plan->major_code . "|_" . $track_code])) {
- $is_editable = intval(@$student_majors_array[$t_degree_plan->major_code . "|_" . $track_code]["is_editable"]);
- }
-
- if ($is_editable != 1 || $is_locked == TRUE) {
- $disabled = "disabled=disabled";
- }
-
-
- if ($bool_default_description == false) {
- $track_description = filter_markup(trim(@$temp[2]));
- }
-
- $temp_tc = $track_code;
- if ($temp_tc == "") {
- $temp_tc = "none";
- }
-
-
- $link = fp_get_js_confirm_link(t("Are you sure you wish to change degree options?"), "opener.changeTrack(\"$temp_tc\"); window.close(); ", $track_title);
-
-
-
- // We actually don't need to do anything special for what_if, I think. When
- // we save, it should automatically detect it and set the appropriate values.
- $is_whatif = 0;
- if ($GLOBALS["fp_advising"]["advising_what_if"] == "yes") {
- $is_whatif = 1;
- }
-
-
-
- $track_degree_plan = fp_load_degree($track_degree_id, NULL, TRUE); // load minimally
-
- $input_type = "checkbox";
- $input_name = "track_degree_id_$track_degree_id";
-
- // We are extected to select EXACTLY 1 track...
- if ($min_tracks == $max_tracks && $max_tracks == 1) {
- $input_type = "radio";
- $input_name = "track_degree_id_" . $degree_id; // needs to be the same for all options.
- }
-
-
- if ($track_degree_plan->db_allow_dynamic == 1) {
-
- $extra_class = "";
- $is_default = FALSE;
- if (in_array($t_degree_plan->major_code . "|_" . $track_code, $default_tracks_array)) {
- $extra_class = "advise-select-track-default-track";
- $is_default = TRUE;
- }
-
- $html .= "<div class='track-option $extra_class'>";
- $html .= "
- <label>
- <input type='$input_type' name='$input_name' degree_id_class='{$degree_id}_class_{$machine_name}'
- is_editable='$is_editable'
- value='$track_degree_id' $selected $disabled>
- <span class='track-title'>" . $track_degree_plan->get_title2(TRUE, TRUE) . "
- ";
-
- if ($is_default) {
- $html .= "<span class='track-default-track'>" . t("(Default)") . "</span>";
- }
- $html .= "
- </span>
- </label>";
- if (!$is_editable) {
- $html .= "<div class='track-not-editable'>" . t("You are not allowed to modify this option.") . "</div>";
- }
-
- $html .= "
-
- <div class='track-description'>
- $track_description
- </div>
- </div>";
-
-
- $class_is_empty = FALSE;
-
- }
-
-
- } // for (count(tracks))
-
- if ($is_locked) {
- $html .= "<div class='track-class-is-locked-msg'>" . t("Selections from this degree classification are locked. You may use What If mode to explore
- other options, or ask your advisor about changing these options officially.") . "</div>";
- }
-
-
- $html .= "</div>";
-
-
- $html .= "</div>"; // advise-track-selection-tracks
-
- if (!$class_is_empty) {
- $rtn .= $html;
- }
-
-
- }
-
- } // foreach degree_plan_array
-
- $rtn .= "<input type='button' value='" . t("Apply Selections") . "'
- onClick='if(confirm(\"Are you sure you wish to apply these selections to the degree plan?\")) { popupChangeTrackSelections($is_whatif); }'>";
-
- // Keep track of what our top-level majors were.
- $top_level_majors_csv = rtrim($top_level_majors_csv, ","); // remove trailing comma if exists
- $rtn .= "<input type='hidden' name='top_level_majors_csv' id='top_level_majors_csv' value='$top_level_majors_csv'>";
-
- return $rtn;
- } // display_popup_change_track
-
-
-
-
- /**
- * This popup allows the advisor to change the advising term.
- */
- function advise_display_popup_change_term() {
- $rtn = "";
-
- fp_add_js(fp_get_module_path("advise") . "/js/advise.js");
-
- $current_term_id = $_REQUEST["advising_term_id"];
- $current_term = get_term_description($current_term_id);
-
-
- $rtn .= fp_render_curved_line(t("Select an Advising Term"));
- $rtn .= "<div>
- " . t("You may advise this student for future semesters. Please select which
- advising term you would like to advise for from the list below. If you
- are unsure, simply close this window and continue to advise for the current
- term of %current_term.", array("%current_term" => $current_term)) . "
- </div>";
-
- $rtn .= "<ul>";
-
- $temp = explode(",", variable_get("available_advising_term_ids", "0"));
- for ($t = 0; $t < count($temp); $t++) {
- $term_id = trim($temp[$t]);
-
-
- $term_desc = get_term_description($term_id);
- if ($term_id == $current_term_id) {
- $term_desc = "<b>$term_desc</b> - " . t("current");
- }
-
- $link = fp_get_js_confirm_link(t("Are you sure you wish to change advising terms?"), "opener.changeTerm(\"$term_id\"); window.close(); ", $term_desc);
-
- $rtn .= "<li class='tenpt' style='padding:3px;'>$link</li>";
-
- }
-
- $rtn .= "</ul>";
-
-
- return $rtn;
- }
-
-
-
-
-
- /**
- * This is an access callback. Can the user view the advising session specified
- * in the REQUEST?
- */
- function advise_user_can_view_advising_session_access_callback() {
- global $user;
-
- if (user_has_permission("view_any_advising_session")) {
- return TRUE;
- }
-
-
- if (user_has_permission("view_own_advising_session") || user_has_permission("view_advisee_advising_session")) {
-
- $advising_session_id = $_REQUEST["advising_session_id"];
-
- // First, what was the student's CWID associated with that advising_session_id?
- $res = db_query("SELECT student_id FROM advising_sessions
- WHERE advising_session_id = '?' ", $advising_session_id);
- $cur = db_fetch_array($res);
-
- if (user_has_permission("view_own_advising_session") && $user->cwid == $cur["student_id"]) {
- return TRUE;
- }
-
- if (user_has_permission("view_advisee_advising_session")) {
- $faculty_advisees = advise_get_advisees();
- if (in_array($cur["student_id"], $faculty_advisees)) {
- return TRUE;
- }
- }
-
- }
-
- return FALSE;
- }
-
-
-
- function advise_display_popup_group_select() {
- global $current_student_id, $fp, $screen, $degree_plan;
- $rtn = "";
-
- advise_init_screen();
- fp_add_js(fp_get_module_path("advise") . "/js/advise.js");
- fp_add_css(fp_get_module_path("advise") . "/css/advise.css");
-
-
- $settings = fp_get_system_settings();
-
- $blank_degree_id = trim(@$_GET["blank_degree_id"]);
- $course_id = trim(@$_GET["course_id"]);
- $group_id = trim(addslashes(@$_GET["group_id"]));
- $group_hours_remaining = trim(addslashes(@$_GET["group_hours_remaining"]));
- $semester_num = trim(addslashes(@$_GET["semester_num"]));
- $req_by_degree_id = trim(addslashes(@$_REQUEST["req_by_degree_id"]));
- $perform_action2 = @$_REQUEST["perform_action2"];
-
-
- // If this is a "blank" degree, make sure we set the degree_id correctly.
- if($blank_degree_id != "") {
- // If req_by_degree_id isn't blank or zero, then use it instead.
- if ($req_by_degree_id != '' && intval($req_by_degree_id) != 0) {
- $degree_plan = fp_load_degree($req_by_degree_id);
- }
- else {
- // Default behavior
- $degree_plan = fp_load_degree($blank_degree_id);
- }
- $fp->degree_plan = $degree_plan;
- $screen->degree_plan = $degree_plan;
- $screen->bool_blank = TRUE;
- }
-
- if (!$group = $degree_plan->find_placeholder_group($group_id, $semester_num)) {
- fpm("Could not find group (id: $group_id) in semester (num: $semester_num).");
- fpm($degree_plan);
- return;
- }
-
- if ($group_id == -88) {
- // This is the Add a Course group. We must initialize it, as it
- // does not exist yet.
- // We need to populate this group now.
- $group->list_courses = $fp->get_all_courses_in_catalog_year($settings["current_catalog_year"]);
- $group->title = "Add an Additional Course";
- $group->list_courses->assign_group_id($group_id);
- $group->list_courses->load_course_descriptive_data();
- }
-
-
- if ($course_id != "") {
- // Meaning, a course_id was specified, so make sure
- // it is "selected" inside the group and branches.
-
- $course = new Course();
- $course->course_id = $course_id;
- $course->req_by_degree_id = $req_by_degree_id;
-
- // TODO: Right here, do we need to limit by degree id? Probably...
- $temp_course_list = $group->find_courses($course);
- if (!$temp_course_list) {
- $temp_course_list = $degree_plan->find_courses($course_id, $group_id, $semester_num);
- }
-
- if ($temp_course_list) {
- $temp_course_list->reset_counter();
- while($temp_course_list->has_more()) {
- $temp_course = $temp_course_list->get_next();
- $temp_course->bool_selected = true;
- //$temp_course->assigned_to_semester_num = $semester_num;
- }
- }
- }
-
- if ($perform_action2 == "" || $perform_action2 == "select") {
- if ($group) {
- $rtn .= $screen->display_popup_group_select($group, $group_hours_remaining, $req_by_degree_id);
- }
- // Create the tabs for the page...
- $tab_array = array();
- $tab_array[0]["title"] = "Description";
- $tab_array[0]["on_click"] = "popupDescribeSelected(\"$group_id\",\"$semester_num\",\"0\",\"\",\"req_by_degree_id=$req_by_degree_id&group_hours_remaining=$group_hours_remaining&blank_degree_id=$blank_degree_id\");";
- $tab_array[1]["title"] = "Select";
- $tab_array[1]["active"] = true;
-
- // If we are allowed to substitute....
- if (user_has_permission("can_substitute") && $group_id != -88 && !$screen->bool_blank) {
- $tab_array[2]["title"] = "Substitute";
- $tab_array[2]["on_click"] = "popupSubstituteSelected(\"0\",\"$group_id\",\"$semester_num\",\"$req_by_degree_id\",\"group_hours_remaining=$group_hours_remaining\");";
- }
-
- }
-
- if ($perform_action2 == "describe_course") {
- $rtn .= $screen->display_popup_course_description($course_id,null,$group, true);
- // Create the tabs for the page...
- $tab_array = array();
- $tab_array[0]["title"] = "Description";
- $tab_array[0]["active"] = true;
- $tab_array[1]["title"] = "Select";
- $subject = trim($_GET["selected_subject"]);
-
- $tab_array[1]["on_click"] = "popupBackToGroupSelect(\"$course_id\",\"$group_id\",\"$semester_num\",\"req_by_degree_id=$req_by_degree_id&selected_subject=$subject&group_hours_remaining=$group_hours_remaining&blank_degree_id=$blank_degree_id\");";
-
- // If we are allowed to substitute....
- if (user_has_permission("can_substitute") && $group_id != -88 && !$screen->bool_blank) {
- $tab_array[2]["title"] = "Substitute";
- $tab_array[2]["on_click"] = "popupSubstituteSelected(\"$course_id\",\"$group_id\",\"$semester_num\",\"$req_by_degree_id\",\"group_hours_remaining=$group_hours_remaining\");";
- }
-
-
- }
-
- if ($tab_array) {
- fp_set_page_tabs($tab_array);
- }
-
-
- return $rtn;
- }
-
-
-
-
-
- function advise_display_popup_substitute_selected() {
- global $current_student_id, $fp, $screen;
- $rtn = "";
-
- advise_init_screen();
- fp_add_js(fp_get_module_path("advise") . "/js/advise.js");
-
- $sub_decimals_allowed = variable_get("sub_hours_decimals_allowed", 2);
- // Add our allowed substitution decimals as a js setting for later use.
- fp_add_js(array("subDecimalsAllowed" => $sub_decimals_allowed), "setting");
-
-
- $course_id = trim(@$_GET["course_id"]);
- $group_id = trim(addslashes(@$_GET["group_id"]));
- $semester_num = trim(addslashes(@$_GET["semester_num"]));
- $req_by_degree_id = trim(addslashes(@$_GET["req_by_degree_id"]));
- $hours_avail = trim(addslashes(@$_GET["group_hours_remaining"]));
-
- if (@$_GET["hours_avail"] * 1 > 0) {
- $hours_avail = $_GET["hours_avail"] * 1;
- }
-
-
-
- $rtn .= "<div class='tenpt'><a href='javascript:history.go(-1);' class='nounderline'>« " . t("return to course selection") . "</a></div>";
-
- $rtn .= $screen->display_popup_substitute($course_id, $group_id, $semester_num, $hours_avail, $req_by_degree_id);
-
-
- return $rtn;
- }
-
-
- function advise_display_popup_course_description() {
- global $current_student_id, $screen;
- $rtn = "";
-
- advise_init_screen();
-
- fp_add_js(fp_get_module_path("advise") . "/js/advise.js");
- fp_add_css(fp_get_module_path("advise") . "/css/advise.css");
-
- $data_string = trim($_GET["data_string"]);
- $course = new Course();
- if ($data_string != "")
- {
- $course->load_course_from_data_string($data_string);
- }
-
- $req_by_degree_id = $course->req_by_degree_id;
-
- // Save the max hours from the data string here. This is to fix a bug where we didn't keep track
- // of a course's remainder from a split substitution. Due to pass-by-reference, it gets reset
- // in the display_popup_course_description function.
- $datastring_max_hours = $course->max_hours;
-
- $rtn .= $screen->display_popup_course_description("", $course);
-
- // Create the tabs for the page...
- $tab_array = array();
- $tab_array[0]["title"] = "Description";
- $tab_array[0]["active"] = true;
- if (user_has_permission("can_substitute") && !$screen->bool_blank) {
- if ($course->get_bool_substitution() != TRUE && $course->grade == "") {
-
- // By checking grade, we are making sure this course has NOT already
- // been taken by the student. In other words, verify that this course
- // is an unfulfilled requirement on the degree plan ONLY.
- $extra_vars = "hours_avail=$datastring_max_hours";
- $tab_array[1]["title"] = "Substitute";
- $tab_array[1]["on_click"] = "popupSubstituteSelected(\"$course->course_id\",\"" . $course->get_first_assigned_to_group_id() . "\",\"$course->assigned_to_semester_num\",\"$req_by_degree_id\",\"$extra_vars\");";
-
- }
- }
-
- fp_set_page_tabs($tab_array);
-
- //$screen->page_tabs = $screen->draw_tabs($tab_array);
-
- return $rtn;
- }
-
-
-
- /**
- * Implementation of hook_perm
- */
- function advise_perm() {
- $perms = array();
-
- $perms["view_any_advising_session"] = array(
- "title" => t("View any advising session"),
- "description" => t("The user is allowed to view any advising sessions for any user.
- For example, the user is an advisor."),
- );
-
- $perms["view_advisee_advising_session"] = array(
- "title" => t("View advisee advising sessions"),
- "description" => t("The user is allowed to view their assigned advisee's advising sessions.
- For example, the user is a limited advisor with advisees assigned."),
- );
-
-
- $perms["view_own_advising_session"] = array(
- "title" => t("View own advising session"),
- "description" => t("The user is allowed to view their own advising sessions.
- For example, the user is a student."),
- );
-
-
-
- $perms["can_advise_students"] = array(
- "title" => t("Can advise students"),
- "description" => t("The user is allowed to advise other students,
- by clicking a checkbox next to a course, or by selecting
- a course from an elective group."),
- );
-
- $perms["can_substitute"] = array(
- "title" => t("Can substitute"),
- "description" => t("The user is allowed to substitute courses on a student's
- degree plan."),
- );
-
-
- $perms["toggle_draft"] = array(
- "title" => t("Toggle draft mode"),
- "description" => t("The user toggle 'draft' mode, so they can view draft degree plans
- in FlightPath."),
- );
-
-
-
- return $perms;
- }
-
-
- /**
- * This is the page which actually displays the "view" for the user
- * to see their advising session, or for an advisor to advise them.
- *
- */
- function advise_display_view($view = "view") {
- global $user, $fp, $degree_plan, $screen;
- $rtn = "";
-
- if ($view == "what-if") {
- $GLOBALS["fp_advising"]["advising_what_if"] = "yes";
- $_REQUEST["advising_what_if"] = "yes";
- }
- else {
- $GLOBALS["fp_advising"]["advising_what_if"] = "no";
- $_REQUEST["advising_what_if"] = "no";
- }
-
- // Initialize everything we need to initialize for this advising session.
-
- advise_init_screen();
-
- // Add some body classes to the page for this student.
- $student = $screen->student;
- if (is_object($student)) {
- fp_add_body_class("student-rank-$student->db_rank student-catalog-year-$student->catalog_year");
- }
-
-
- fp_add_js(fp_get_module_path("advise") . "/js/advise.js");
- // Add advise.css to the screen
- fp_add_css(fp_get_module_path("advise") . "/css/advise.css");
-
- // If we are on a print screen, we need to go out of our
- // way to set the screen mode, so we don't display certain things
- // when we go to draw the screen.
- if (strstr($_REQUEST["q"], "/print")) {
- $screen->bool_print = TRUE;
- $screen->screen_mode = "not_advising";
- }
-
- if ($GLOBALS["fp_advising"]["advising_what_if"] == "yes" && $GLOBALS["fp_advising"]["what_if_major_code"] == "") {
- // We are in WhatIf, but we have not selected a major, so give
- // the user a selection screen.
- $screen->screen_mode = "not_advising";
- //$rtn .= advise_display_what_if_selection();
-
- // TODO: If graduate degree selection is allowed for graduate students, then change bool_undergrad_only to FALSE.
- // (if the student is a grad student!)
- $bool_undergrad_only = TRUE;
-
- if ($student->db_rank == 'GR') { // TODO: make it a settings list of graduate ranks?
- // TODO: check setting to see if we should allow graduate students to see what if (?) Maybe?
- $bool_undergrad_only = FALSE;
- }
-
- $rtn .= fp_render_form("advise_what_if_selection_form", "", $bool_undergrad_only);
-
-
- }
- else {
- // This is a normal advising screen. Either View or WhatIf.
-
- //$page_content .= $screen->display_view_options();
- $screen->build_screen_elements();
-
- $form_token = md5("advise_display_view" . fp_token());
-
- $vurl = fp_url($view);
-
- $rtn .= "<form id='mainform' method='POST' action='$vurl'>
- <input type='hidden' name='form_token' value='$form_token'>
- <table class='fp-semester-table'>";
- $rtn .= $screen->display_screen();
-
- $rtn .= "</table>";
- // Add in the required "advising variables"
- $rtn .= $screen->get_hidden_advising_variables("save_draft");
-
- $rtn .= "</form>";
-
- // Figure out what the page's sub-tabs should be, and set them.
- $tab_array = array();
- $tab_array[0]["title"] = "Display by Year";
- $tab_array[0]["active"] = ($screen->view != "type");
- $tab_array[0]["on_click"] = "changeView(\"year\");";
-
- $tab_array[1]["title"] = "Display by Type";
- $tab_array[1]["active"] = ($screen->view == "type");
- $tab_array[1]["on_click"] = "changeView(\"type\");";
-
-
- if (!fp_screen_is_mobile()) {
- $tab_array[2]["title"] = "Print";
- $tab_array[2]["type"] = "link";
- $tab_array[2]["active"] = FALSE;
- $tab_array[2]["on_click"] = "popupPrintWindow(\"" . fp_url("$view/print", "advising_view=$screen->view") . "\");";
- }
-
- fp_set_page_sub_tabs($tab_array);
-
- watchdog("view_by_$screen->view", "", array(), WATCHDOG_DEBUG);
-
-
- }
-
- /* We aren't doing anything with these variables, so I am commenting-out
- *
- // If we are in WhatIf mode, let's write something special to
- // the log.
- if ($GLOBALS["fp_advising"]["advising_what_if"] == "yes" && $GLOBALS["fp_advising"]["what_if_major_code"] != "")
- {
- $log_action .= "_whatif";
- $log_extra = $GLOBALS["fp_advising"]["what_if_major_code"] . " " . $GLOBALS["fp_advising"]["what_if_track_code"];
- }
- */
-
-
- // print_pre($student->list_courses_taken->toString());
- // Should we re-cache the course inventory? If there have been any changes
- // to it, then we will see that in a GLOBALS variable...
- if (@$GLOBALS["cache_course_inventory"] == true)
- {
- $_SESSION["fp_cache_course_inventory"] = serialize(@$GLOBALS["fp_course_inventory"]);
- }
-
- return $rtn;
- }
-
-
-
- function advise_what_if_selection_form($bool_undergrad_only = TRUE) {
- global $screen, $current_student_id;
-
- if ($screen->bool_print) {
- return array();
- }
-
- fp_add_js(fp_get_module_path("advise") . "/js/advise.what-if-selection.js");
- fp_add_css(fp_get_module_path("advise") . "/css/advise.css");
-
-
-
- $form = array();
- $m = 0;
-
- fp_set_title(""); // Remove the default form's title
-
- $db = get_global_database_handler();
-
- $major_codes = array();
-
- $form["mark" . $m++] = array(
- "value" => fp_render_curved_line("What if I change my degree to...") . "<br>",
- );
-
-
- //$settings = fp_get_system_settings();
- $catalog_year = variable_get("current_catalog_year", 0);
- $current_catalog_year = $catalog_year; // keep track of what the current catalog year is.
- $earliest_catalog_year = variable_get("earliest_catalog_year", 2006);
-
-
- // Use the student's catalog year, based on a setting instead?
- if (variable_get("what_if_catalog_year", "current") == "student") {
- $db = get_global_database_handler();
- $catalog_year = $db->get_student_catalog_year($current_student_id);
- }
-
- $form["mark_cat_year"] = array(
- "value" => "<div class='mark-select-from-cat-year'>" . t("Please select from the %cat catalog year:", array("%cat" => $catalog_year . "-" . ($catalog_year+1))) . "</div>",
- );
-
-
-
- // We cannot go beyond the current catalog year, so if the catalog_year is now > than current, we must stop
- // the user.
- if ($catalog_year > $current_catalog_year || $catalog_year < $earliest_catalog_year) {
- $form["mark_cat_year_past_current"] = array(
- "value" => "<p class='cat-year-past-current'>" . t("Sorry, but the catalog year %cat is not available yet within
- FlightPath. Please speak with your adviser about how to proceed
- with advising.", array("%cat" => $catalog_year . "-" . ($catalog_year+1))) . "</p>",
- );
-
- return $form;
-
-
- }
-
-
-
-
- $form["catalog_year"] = array(
- "type" => "hidden",
- "value" => $catalog_year,
- );
-
- $bool_use_draft = FALSE; // leave as false for now. Because you can't select
- // degree options, and if you click submit it really does
- // save it. Better to just use blank degrees.
-
- $c = 100;
-
- /////////////////////
- // Select a major....
-
-
- $options = array();
- if ($degree_array = $db->get_degrees_in_catalog_year($catalog_year, FALSE, $bool_use_draft, $bool_undergrad_only, array(1))) {
- foreach($degree_array as $major_code => $value) {
- if (trim($value["title"]) == ""){continue;}
- $options[$major_code] = $value["title"];
- $major_codes[$major_code] = $major_code;
- }
- }
-
- // Place in a fieldset...
- $e1["select_level_1_degrees"] = array(
- "type" => "checkboxes",
- "label" => "",
- "options" => $options,
- );
-
- $form["cfieldset_level_1"] = array(
- "type" => "cfieldset",
- "label" => "Select Major »",
- "elements" => array($e1),
- "start_closed" => FALSE,
- );
-
-
- /////////////////////////
- // Select a minor....
- $options = array();
- if ($degree_array = $db->get_degrees_in_catalog_year($catalog_year, FALSE, $bool_use_draft, $bool_undergrad_only, array(2))) {
- foreach($degree_array as $major_code => $value) {
- if (trim($value["title"]) == ""){continue;}
- $options[$major_code] = $value["title"];
- $major_codes[$major_code] = $major_code;
- }
- }
-
-
- if (count($options) > 0) {
- $e2["select_level_2_degrees"] = array(
- "type" => "checkboxes",
- "label" => "",
- "options" => $options,
- );
-
- $form["cfieldset_level_2"] = array(
- "type" => "cfieldset",
- "label" => "Select Minor »",
- "elements" => array($e2),
- );
- }
-
-
- /////////////////////
- // All the tracks...
-
- if (variable_get("show_level_3_on_what_if_selection", "yes") == 'yes') {
-
- foreach ($major_codes as $major_code => $temp) {
- // Let's see if this major has any tracks...
- if ($tracks = $db->get_degree_tracks($major_code, $catalog_year)) {
- // Let's load the original degree plan.
- $degree_plan = $db->get_degree_plan($major_code, $catalog_year, TRUE);
- $degree_plan->load_degree_plan_ancillary();
-
- // Yes, there are indeed tracks for THIS major. Let's load them up...
- // First, organize them by degree_class...
- $tracks_by_class = array();
- foreach ($tracks as $track) {
- $t_degree_plan = $db->get_degree_plan($major_code . "|_" . $track, $catalog_year, TRUE);
- $t_degree_plan->load_degree_plan_ancillary();
- $degree_class = trim($t_degree_plan->degree_class);
- if ($degree_class) {
- $tracks_by_class[$degree_class][] = $t_degree_plan;
- }
- }
-
- // Now, create the form element...
- foreach ($tracks_by_class as $degree_class => $c) {
- $options = array();
-
- $temp = fp_get_degree_classification_details($degree_class);
- $class_title = $temp["title"];
-
-
- // Are there any special requirements or defaults for this degree_class selection?
- $tsca = $degree_plan->track_selection_config_array;
- $default_tracks_array = @csv_to_array($tsca[$degree_class]["default_tracks"]);
-
- $min_tracks = @intval($tsca[$degree_class]["min_tracks"]);
- $max_tracks = @intval($tsca[$degree_class]["max_tracks"]);
- $element_type = "checkboxes";
- $element_value = array();
-
- // If we require exactly 1 selection, then make this a radio button, and pre-select either the first element
- // or the first default track.
- if ($min_tracks == 1 && $max_tracks == 1) {
- $element_type = "radios";
- $element_value = array($default_tracks_array[0] => $default_tracks_array[0]);
- }
-
- // Actually build up the options...
- foreach ($tracks_by_class[$degree_class] as $t_degree_plan) {
- //$degree_id = $t_degree_plan->degree_id;
-
- $tmajor_code = "" . trim($t_degree_plan->major_code);
-
- $options[$tmajor_code] = $t_degree_plan->get_title2(FALSE, TRUE);
- if (trim($t_degree_plan->track_description) != "") {
- $options[$tmajor_code] .= "<div class='what-if-selection-track-desc what-if-selection-track-desc-for-" . fp_get_machine_readable($tmajor_code) . "'
- >" . $t_degree_plan->track_description . "</div>";
- }
-
- // Is this a "default" major code?
- if (in_array(trim($tmajor_code), $default_tracks_array)) {
- $element_value[$tmajor_code] = $tmajor_code; // make it be selected
- }
- }
-
- $min_max_options = "<div class='what-if-select-track-min-max what-if-select-track-between'>Please select between $min_tracks and $max_tracks $class_title options.</div>";
- if ($min_tracks == $max_tracks && $max_tracks == 1) {
- $min_max_options = "<div class='what-if-select-track-min-max what-if-select-track-exactly-one'>Please select 1 $class_title option.</div>";
- }
-
- if ($min_tracks > 0 && $max_tracks == 0) {
- // Meaning, there is no maximum. It's infinite.
- $min_max_options = "<div class='what-if-select-track-min-max what-if-select-track-at-least-one'>Please select at least $min_tracks $class_title option(s) for this degree.</div>";
- }
-
- if ($min_tracks == $max_tracks && $max_tracks == 0) {
- $min_max_options = "<div class='what-if-select-track-min-max what-if-select-track-optional'>Optional: You are not required to select any additional $class_title options.</div>";
- }
-
-
-
-
- $form["L3__sel__{$degree_class}__for__{$major_code}__xx"] = array( //ends with xx so we can be sure when the major code ends.
- "type" => $element_type,
- "label" => "Select $class_title for " . $degree_plan->get_title2(),
- "options" => $options,
- "description" => "$min_max_options",
- "value" => $element_value,
- );
-
- // Save min and max options for quick look-up later.
- $form["L3__ops__{$degree_class}__for__{$major_code}__xx"] = array(
- "type" => "hidden",
- "value" => "$min_tracks~$max_tracks",
- );
-
-
- }
-
-
-
-
- } // if tracks
- } // foreach major codes
-
- } // if level-3 selection...
-
-
-
- $form["submit_btn"] = array(
- "value" => "<div align='right'>
- " . fp_render_button("Try It Out!", "showUpdate(true);$(\"#fp-form-advise_what_if_selection_form\").submit(); ") . "
- </div>",
- );
-
-
-
- /*
- $rtn .= "<br><br>
- <div align='right'>
- " . fp_render_button("Try It Out!", "showUpdate(true);submitForm();") . "
-
- </div>
- <br><br>
- <div class='hypo tenpt'>
- <b>Important Notice:</b> What If displays degree plans
- from the most recent catalog year ($current_catalog_year-" . ($current_catalog_year + 1) . "),
- as any major change would place the student into the
- most recent catalog.
- </div>";
-
-
- // Include only certain variables, so we don't overwrite our selection of what_if_major_code.
- $rtn .= "
- <input type='hidden' name='load_from_cache' value='no'>
- <input type='hidden' name='window_mode' value='screen'>
- <input type='hidden' id='scroll_top'>
- <input type='hidden' id='perform_action' name='perform_action'>
- <input type='hidden' id='advising_what_if' name='advising_what_if' value='yes'>
- <input type='hidden' id='current_student_id' name='current_student_id' value='$current_student_id'>
-
- <input type='hidden' id='from_what_if_selection_form' name='from_what_if_selection_form' value='yes'>
-
- ";
-
- $rtn .= "</form>
- ";
- */
-
- $form["current_student_id"] = array(
- "type" => "hidden",
- "value" => $current_student_id,
- );
-
-
- return $form;
- }
-
-
- /**
- * Validate handler for the what_if selection form. This is where we might, for example, make sure
- * that if a non-dynamic degree was selected, that they can't proceed.
- */
- function advise_what_if_selection_form_validate($form, &$form_state) {
- $catalog_year = $form_state['values']['catalog_year'];
- // Make sure they selected at least 1 level 1 degree.
- $selected_degrees = array();
- $temp = FALSE;
- foreach (array(1,2) as $num) {
- if (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 != "") {
- $temp = TRUE;
- $selected_degrees[$k] = $v;
- }
- }
- }
- }
-
- if (!$temp) {
- form_error("select_level_1_degrees", t("Sorry, you must select at least one top-level degree to proceed. Please try again."));
- return;
- }
-
- $db = get_global_database_handler();
-
- // If a non-dynamic degree was selected, along with anything else, the user may not proceed.
- if (count($selected_degrees) > 1) {
- foreach ($selected_degrees as $major_code) {
- $temp = $db->get_degree_plan($major_code, $catalog_year, TRUE);
- if (is_object($temp) && intval($temp->db_allow_dynamic) != 1) {
- $temp->load_descriptive_data();
- // meaning, we have selected more than one degree, and at least THIS degree does NOT allow for dynamic recombination. So, reject it!
- form_error("select_level_1_degrees", t("Sorry, but the degree you selected, %deg, does not allow you to combine it with any other degree.
- It must be selected by itself. Please alter your selection and try again.", array("%deg"=> $temp->get_title2())));
- return;
- }
- }
- }
-
-
- /////////////////////////
- // Make sure they selected appropriate number of required tracks, if any.
-
- // Begin by going through each track which was selected, and keep track of how many we selected.
- $selected_for = array();
-
- foreach ($form_state["values"] as $key => $val) {
- if (strstr($key, "L3__sel__")) {
-
- // L3_sel_{$degree_class}_for_{$major_code}_xx
- $temp = explode("__", $key);
- $degree_class = $temp[2];
- $major_code = $temp[4];
-
- if (!isset($selected_for[$major_code . "__" . $degree_class])) {
- $selected_for[$major_code . "__" . $degree_class] = 0;
- }
-
-
- if (is_array($val)) { // In other words, this was a group of checkboxes.
- foreach ($val as $k => $v) {
- // Did the user select an item? Val's key and value will be identical if so.
- if ($k == $v && $k != "") {
- // YES. It was selected!
- $selected_for[$major_code . "__" . $degree_class]++;
- }
- }
- } // if is_array (val)
- else if (is_string($val) && trim($val) != ""){
- // Not an array-- was a radio list? So, this was a selection.
- $selected_for[$major_code . "__" . $degree_class]++;
- }
-
- }
- }
-
-
- // Okay, now that we know how many were selected, let's make sure that the number falls within
- // our min/max range for those tracks.
- //foreach ($selected_for as $key => $count) {
- foreach ($form_state["values"] as $key => $val) {
- if (!strstr($key, "L3__sel__")) { continue; }
-
- $temp = explode("__", $key);
- $degree_class = $temp[2];
- $major_code = $temp[4];
-
-
- $count = @intval($selected_for[$major_code . "__" . $degree_class]);
-
-
-
- //First, make sure it's top-level degree was even selected. If it wasn't, skip it, it doesn't matter.
- $temp = explode("|_", $major_code);
-
- $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;
- }
- }
-
-
- // Okay, check to see if the count falls within the range for this degree & class.
- $temp = explode("~", $form_state["values"]["L3__ops__{$degree_class}__for__{$major_code}__xx"]);
- $min_tracks = @intval($temp[0]);
- $max_tracks = @intval($temp[1]);
-
-
- if ($count > $max_tracks && $max_tracks != 0) {
- // We picked too many!
- form_error("L3__sel__{$degree_class}__for__{$major_code}__xx", t("Sorry, you did not select the correct number of options for this degree."));
- return;
- }
-
- if ($count < $min_tracks && $min_tracks > 0) {
- // We picked too few!
- form_error("L3__sel__{$degree_class}__for__{$major_code}__xx", t("Sorry, you did not select the correct number of options for this degree."));
- return;
- }
-
-
-
-
- }
-
-
-
-
-
-
-
- } //what_if_selection_form_validate
-
-
- /**
- * 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.
- */
- 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 (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);
-
- }
-
-
-
- /**
- * Displays the pulldown select list for picking a new What If degree.
- * Returns HTML.
- *
- * This function is no longer used...
- *
- * @return string
- */
- function z___advise_display_what_if_selection($bool_undergrad_only = TRUE) {
- global $screen, $current_student_id;
-
- $rtn = "";
-
- if ($screen->bool_print) {
- return "";
- }
-
- $db = get_global_database_handler();
-
- $url = fp_url("what-if");
-
- $rtn .= "<form action='" . $url . "' id='mainform' method='POST'>";
- $rtn .= fp_render_curved_line("What if I change my major to...");
-
-
- $rtn .= "<br>
- Major: <select name='what_if_major_code' class='what-if-selector'>
- <option value=''>Please select a major</option>
- <option value=''>------------------------------</option>\n
- ";
- //$settings = fp_get_system_settings();
- $current_catalog_year = variable_get("current_catalog_year", 0); // get the current catalog year, 0 if not set (which is an error condition)
- //$bool_use_draft = $GLOBALS["fp_advising"]["bool_use_draft"];
- $bool_use_draft = FALSE; // leave as false for now. Because you can't select
- // degree options, and if you click submit it really does
- // save it. Better to just use blank degrees.
- if ($degree_array = $db->get_degrees_in_catalog_year($current_catalog_year, false, $bool_use_draft, $bool_undergrad_only, array(1))) {
- foreach($degree_array as $major_code => $value) {
- if (trim($value["title"]) == ""){continue;}
- $rtn .= "<option value='$major_code'>{$value["title"]}</option> \n";
- }
- }
-
- $rtn .= "</select>
- <br><br>";
-
- $c = 100;
-
- /////////////////////
- // Select a major....
- $content = "";
- if ($degree_array = $db->get_degrees_in_catalog_year($current_catalog_year, false, $bool_use_draft, $bool_undergrad_only, array(1))) {
- foreach($degree_array as $major_code => $value) {
- if (trim($value["title"]) == ""){continue;}
- $content .= "<label style='display:block;'><input type='checkbox' name='cb_$c' value='$major_code'>{$value["title"]} </label> \n";
- $c++;
- }
- }
-
- $rtn .= fp_render_c_fieldset($content, "Select a Major »", FALSE);
-
- /////////////////////////
- // Select a minor....
- $content = "";
- if ($degree_array = $db->get_degrees_in_catalog_year($current_catalog_year, false, $bool_use_draft, $bool_undergrad_only, array(2))) {
- foreach($degree_array as $major_code => $value) {
- if (trim($value["title"]) == ""){continue;}
- $content .= "<label style='display:block;'><input type='checkbox' name='cb_$c' value='$major_code'>{$value["title"]} </label> \n";
- $c++;
- }
- }
-
- $rtn .= "<br><br>" .fp_render_c_fieldset($content, "Select a Minor »", FALSE);
-
-
-
- $rtn .= "<br><br>
- <div align='right'>
- " . fp_render_button("Try It Out!", "showUpdate(true);submitForm();") . "
-
- </div>
- <br><br>
- <div class='hypo tenpt'>
- <b>Important Notice:</b> What If displays degree plans
- from the most recent catalog year ($current_catalog_year-" . ($current_catalog_year + 1) . "),
- as any major change would place the student into the
- most recent catalog.
- </div>";
-
-
- // Include only certain variables, so we don't overwrite our selection of what_if_major_code.
- $rtn .= "
- <input type='hidden' name='load_from_cache' value='no'>
- <input type='hidden' name='window_mode' value='screen'>
- <input type='hidden' id='scroll_top'>
- <input type='hidden' id='perform_action' name='perform_action'>
- <input type='hidden' id='advising_what_if' name='advising_what_if' value='yes'>
- <input type='hidden' id='current_student_id' name='current_student_id' value='$current_student_id'>
-
- <input type='hidden' id='from_what_if_selection_form' name='from_what_if_selection_form' value='yes'>
-
- ";
-
- $rtn .= "</form>
- ";
-
-
- return $rtn;
- }
-
-
-
-
-
- /**
- * Takes various variables from the REQUEST and stores them in our advising_session_variables table for more convenient use later on.
- */
- function advise_init_advising_variables($bool_ignore_what_if_variables = FALSE) {
- global $user;
-
- $vars = array();
-
- $student = null;
-
- // The current student ID is what we append to all session variables
- // dealing with the current student. We do this so that we will
- // keep session variables unique, so that we can have more than one
- // window open at a time, with multiple students.
- // Therefor, this should never go into the session.
- // Annoyingly, we must pass carry this around on each page in the system.
- $vars["current_student_id"] = @$_REQUEST["current_student_id"];
- if ($vars["current_student_id"] == "")
- {
- $vars["current_student_id"] = @$_REQUEST["advising_student_id"];
- }
-
- $csid = $vars["current_student_id"];
-
- // Get the student ID.
- $vars["advising_student_id"] = @$_REQUEST["advising_student_id"];
- if ($vars["advising_student_id"] == "")
- {
- $vars["advising_student_id"] = @$_SESSION["advising_student_id$csid"];
- if ($vars["advising_student_id"] == "")
- { // Default value...
- $vars["advising_student_id"] = $csid;
- }
- }
-
-
- // Should we load from the Draft advising session? or the active?
- $vars["advising_load_active"] = @$_REQUEST["advising_load_active"];
- if ($vars["advising_load_active"] == "")
- { // values will either be "yes" or "" (any other value than "yes" is
- // considered to be negative.
- // Default value...
- $vars["advising_load_active"] = "";
-
- }
-
- // Are we currently in WhatIf mode?
- @$vars["advising_what_if"] = $_REQUEST["advising_what_if"]; // Get it from the GET or POST.
- if ($vars["advising_what_if"] == "")
- {
- // Will equal "yes" if we ARE in whatIf mode.
- @$vars["advising_what_if"] = $_SESSION["advising_what_if$csid"];
- if ($vars["advising_what_if"] == "")
- {
- // Default value:
- $vars["advising_what_if"] = "no";
- }
- }
-
- // Go ahead and set our GLOBALS variable for advising_what_if. It's needed when we load
- // the $student variable.
- $GLOBALS["fp_advising"]["advising_what_if"] = $vars["advising_what_if"];
-
-
-
- // Get the major_code(s).
- $vars["advising_major_code"] = @$_REQUEST["advising_major_code"];
-
- if ($vars["advising_major_code"] == "")
- {
-
- $vars["advising_major_code"] = @$_SESSION["advising_major_code$csid"];
-
- if ($vars["advising_major_code"] == "")
- { // Default value...
-
- if (!$student) $student = new Student($csid);
- $vars["advising_major_code"] = $student->major_code_csv;
-
- $_REQUEST["advising_major_code"] = $student->major_code_csv;
- }
- }
-
-
-
- // Get the track_code.
- /*
- $vars["advising_track_code"] = @$_REQUEST["advising_track_code"];
- if ($vars["advising_track_code"] == "")
- {
- $vars["advising_track_code"] = @$_SESSION["advising_track_code$csid"];
- if ($vars["advising_track_code"] == "")
- { // Default value...
- if (!$student) $student = new Student($csid);
- //$vars["advising_track_code"] = $student->track_code;
- // NOTE: Student doesn't have a track_code property... This code would have never worked.
- }
- }
- */
-
- $vars["advising_track_degree_ids"] = @$_REQUEST["advising_track_degree_ids"];
- if ($vars["advising_track_degree_ids"] == "")
- {
- $vars["advising_track_degree_ids"] = @$_SESSION["advising_track_degree_ids$csid"];
-
- if ($vars["advising_track_degree_ids"] == "")
- { // Default value...
- if (!$student) $student = new Student($csid);
- // Re-load the major codes, as the tracks might have changed.
- $student->load_student_data();
- $vars["advising_major_code"] = $student->major_code_csv;
- }
- }
-
- // Update the student's settings?
- $vars["advising_update_student_settings_flag"] = @$_REQUEST["advising_update_student_settings_flag"];
- // Make it only come from the POST, for safety.
- if ($vars["advising_update_student_settings_flag"] == "")
- {
- $vars["advising_update_student_settings_flag"] = @$_SESSION["advising_update_student_settings_flag$csid"];
- if ($vars["advising_update_student_settings_flag"] == "")
- { // Default value...
-
- }
- }
-
-
- // Update the logged-in user's settings?
- $vars["fp_update_user_settings_flag"] = @$_REQUEST["fp_update_user_settings_flag"];
- // Make it only come from the POST, for safety.
- if ($vars["fp_update_user_settings_flag"] == "")
- {
- $vars["fp_update_user_settings_flag"] = @$_SESSION["fp_update_user_settings_flag$csid"];
- if ($vars["fp_update_user_settings_flag"] == "")
- { // Default value...
-
- }
- }
-
-
-
- $settings = fp_get_system_settings();
-
-
- @$vars["advising_term_id"] = $_REQUEST["advising_term_id"]; // Get it from the GET or POST.
- if ($vars["advising_term_id"] == "")
- {
- // Set to the default advising term.
- @$vars["advising_term_id"] = $_SESSION["advising_term_id$csid"];
- if ($vars["advising_term_id"] == "")
- {
- // default value:
- $vars["advising_term_id"] = $settings["advising_term_id"];
- if ($vars["advising_term_id"] == "") {
- // It's STILL blank?! Just use 0 then.
- $vars["advising_term_id"] = "0";
- }
- }
- }
-
-
- @$vars["what_if_major_code"] = $_REQUEST["what_if_major_code"]; // Get it from the GET or POST.
- if ($vars["what_if_major_code"] == "")
- {
- // Will equal "yes" if we ARE in whatIf mode.
- @$vars["what_if_major_code"] = $_SESSION["what_if_major_code$csid"];
- if ($vars["what_if_major_code"] == "")
- {
- // Default value:
- $vars["what_if_major_code"] = "";
- }
- }
-
-
- @$vars["what_if_catalog_year"] = $_REQUEST["what_if_catalog_year"]; // Get it from the GET or POST.
- if ($vars["what_if_catalog_year"] == "")
- {
-
- @$vars["what_if_catalog_year"] = $_SESSION["what_if_catalog_year$csid"];
- if ($vars["what_if_catalog_year"] == "")
- {
- // Default value:
- $vars["what_if_catalog_year"] = "";
- }
- }
-
-
-
-
-
- /*
- @$vars["what_if_track_code"] = $_REQUEST["what_if_track_code"]; // Get it from the GET or POST.
- if ($vars["what_if_track_code"] == "")
- {
- // Will equal "yes" if we ARE in whatIf mode.
- @$vars["what_if_track_code"] = $_SESSION["what_if_track_code$csid"];
- if ($vars["what_if_track_code"] == "")
- {
- // Default value:
- $vars["what_if_track_code"] = "";
- }
- }
- */
-
-
-
- @$vars["what_if_track_degree_ids"] = $_REQUEST["what_if_track_degree_ids"]; // Get it from the GET or POST.
- if ($vars["what_if_track_degree_ids"] == "")
- {
- // Will equal "yes" if we ARE in whatIf mode.
- @$vars["what_if_track_degree_ids"] = $_SESSION["what_if_track_degree_ids$csid"];
- if ($vars["what_if_track_degree_ids"] == "")
- {
- // Default value:
- $vars["what_if_track_degree_ids"] = "";
- }
- }
-
-
-
-
- if ($vars["what_if_major_code"] == "none")
- {
- $vars["what_if_major_code"] = "";
- }
-
- if ($vars["what_if_track_degree_ids"] == "none")
- {
- $vars["what_if_track_degree_ids"] = "";
- }
-
- // if ($vars["advising_track_code"] == "none")
- // {
- // $vars["advising_track_code"] = "";
- // }
-
- if ($vars["advising_track_degree_ids"] == "none")
- {
- $vars["advising_track_degree_ids"] = "";
- }
-
-
-
-
- // Settings... (from the database)
- $vars["setting_available_advising_term_ids"] = $settings["available_advising_term_ids"];
- $vars["setting_advising_term_id"] = $settings["advising_term_id"];
- $vars["setting_current_catalog_year"] = $settings["current_catalog_year"];
- $vars["setting_current_draft_catalog_year"] = $settings["current_draft_catalog_year"];
-
- // Are we in Print View?
- @$vars["print_view"] = $_REQUEST["print_view"];
-
- // Should we try to load from the cache?
- @$vars["load_from_cache"] = $_REQUEST["load_from_cache"];
- if ($vars["load_from_cache"] == "")
- {
- // By default, attempt to load from cache.
- $vars["load_from_cache"] = "yes";
- }
-
- // What "view" are we in? View by Year or by Type?
- // Not the same as printView. printView should work regardless
- // of our advising_view.
- @$vars["advising_view"] = $_REQUEST["advising_view"];
- if ($vars["advising_view"] == "")
- {
- @$vars["advising_view"] = $_SESSION["advising_view$csid"];
- }
-
-
- // Place values into session.
- $_SESSION["advising_student_id$csid"] = $vars["advising_student_id"];
- $_SESSION["advising_student_id"] = $vars["advising_student_id"]; // used ONLY in the error report popup!
- $_SESSION["advising_major_code$csid"] = $vars["advising_major_code"];
- //$_SESSION["advising_track_code$csid"] = $vars["advising_track_code"];
- $_SESSION["advising_track_degree_ids$csid"] = $vars["advising_track_degree_ids"];
- $_SESSION["advising_term_id$csid"] = $vars["advising_term_id"];
- $_SESSION["advising_what_if$csid"] = $vars["advising_what_if"];
- $_SESSION["what_if_major_code$csid"] = $vars["what_if_major_code"];
- $_SESSION["what_if_catalog_year$csid"] = $vars["what_if_catalog_year"];
- $_SESSION["what_if_track_degree_ids$csid"] = $vars["what_if_track_degree_ids"];
- $_SESSION["advising_view$csid"] = $vars["advising_view"];
-
-
- if ($bool_ignore_what_if_variables == true)
- {
- $vars["advising_what_if"] = "";
- $vars["what_if_major_code"] = "";
- $vars["what_if_catalog_year"] = "";
- $vars["what_if_track_degree_ids"] = "";
- }
-
-
- // Are we in draft mode?
- if ($_SESSION["fp_draft_mode"] == "yes")
- {
- $vars["bool_use_draft"] = true;
- } else {
- $vars["bool_use_draft"] = false;
- }
-
-
-
- $GLOBALS["fp_advising"] = $vars;
-
- }
-
-
-
- /**
- * Implementation of hook_init
- */
- function advise_init() {
- global $current_student_id, $user, $screen, $student, $degree_plan;
- $current_student_id = @$_REQUEST["current_student_id"];
-
- // Since this user doesn't have permission to view this student's sessions,
- // he can only view his own. This is to stop hackers from experimenting with the URL
- // to see other users' data.
- if (!advise_can_access_view($current_student_id)) {
-
- // Reset our global vars....
- $current_student_id = "";
- if (isset($user->cwid) && $user->is_student) {
- $current_student_id = $user->cwid;
- }
- $_REQUEST["current_student_id"] = $current_student_id;
- $_POST["current_student_id"] = $current_student_id;
- $_GET["current_student_id"] = $current_student_id;
- $_SESSION["current_student_id"] = $current_student_id;
- $_REQUEST["advising_student_id"] = $current_student_id;
- $_POST["advising_student_id"] = $current_student_id;
- $_GET["advising_student_id"] = $current_student_id;
- $_SESSION["advising_student_id"] = $current_student_id;
-
- $GLOBALS["fp_advising"]["advising_student_id"] = $current_student_id;
-
-
- $_REQUEST["advising_load_active"] = "yes";
- }
-
-
- if (!isset($_SESSION["fp_draft_mode"])) $_SESSION["fp_draft_mode"] = "";
-
- // Is draft mode enabled?
- if ($_SESSION["fp_draft_mode"] == "yes") {
- fp_add_message("<b>" . t("Draft mode") . "</b> " . t("is currently enabled, however, substitutions and advisings will
- still be saved normally."), "status", TRUE);
- }
-
-
-
-
- }
-
-
- /**
- * Implementation of hook_clear_cache
- * Called by other modules, this function will take care of clearing
- * anything this module has cached.
- */
- function advise_clear_cache() {
- foreach ($_SESSION as $key => $value) {
- if (strstr($key, "cache_")) {
- $_SESSION[$key] = FALSE;
- unset($_SESSION[$key]); // do this just to make sure our server-side session file gets overwritten
- }
-
- if (strstr($key, "advising_") || strstr($key, "what_if_")) {
- $_SESSION[$key] = FALSE;
- unset($_SESSION[$key]);
- }
-
- }
-
- fp_add_message(t("Advising cache has been cleared."));
-
- }
-
-
-
- /**
- * From menu hook. Clear just the advising cache.
- *
- */
- function advise_perform_clear_advising_cache() {
- advise_clear_cache();
- fp_goto("<front>");
- }
-
-
-
- function advise_init_screen() {
-
- global $degree_plan, $student, $fp, $window_mode, $user, $current_student_id, $screen;
-
- $db = get_global_database_handler();
-
- $faculty_id = $user->cwid;
-
- // Insert our advising vars into the GLOBALS array for easy use later.
- advise_init_advising_variables();
-
-
- $perform_action = trim(addslashes(@$_REQUEST["perform_action"]));
-
- if (@$_REQUEST["clear_session"] == "yes") {
- //advise_save_advising_variables_to_db();
- // reload our advising vars into the GLOBALS array for easy use later.
- //$GLOBALS["fp_advising"] = advise_load_advising_variables_from_db($current_student_id, $user->id);
-
- }
-
- // Insert our advising vars into the GLOBALS array for easy use later.
- //$GLOBALS["fp_advising"] = advise_load_advising_variables_from_db($current_student_id, $user->id);
-
- $bool_what_if = false;
-
- $csid = $current_student_id;
-
- $cache = @$_SESSION["cache_fp$csid"];
-
- if (@$GLOBALS["fp_advising"]["advising_what_if"] == "yes") {
- $major_code = @$GLOBALS["fp_advising"]["what_if_major_code"];
- $track_code = @$GLOBALS["fp_advising"]["what_if_track_code"];
- $bool_what_if = true;
- $cache = @$_SESSION["cache_what_if$csid"];
- }
-
- $bool_draft = true;
-
-
- if (@$GLOBALS["fp_advising"]["advising_load_active"] == "yes") {
- // If we are loading from Active, then rebuild the cache as well.
- $bool_draft = false;
- @$GLOBALS["fp_advising"]["load_from_cache"] = "no";
- }
-
-
- ///////////////////////
- /// Disable student data Caching....
- //$GLOBALS["load_from_cache"] = "no";
-
-
- // Attempt to load the course inventory cache...
-
- if ($course_inventory = unserialize(@$_SESSION["fp_cache_course_inventory"])) {
- $GLOBALS["fp_course_inventory"] = $course_inventory;
- }
-
-
-
- $bool_loaded = FALSE;
- if ($GLOBALS["fp_advising"]["load_from_cache"] == "yes" && $cache != "" && $fp = unserialize($cache)) {
-
- $bool_loaded = TRUE;
- $fp->db = get_global_database_handler();
- $student = $fp->student;
- if ($student->student_id == "") $bool_loaded = FALSE;
- $degree_plan = $fp->degree_plan;
- $student->db = get_global_database_handler();
- $degree_plan->db = get_global_database_handler();
-
- }
-
-
-
- if (!$bool_loaded) {
- $fp = new FlightPath();
- $fp->init();
- $student = $fp->student;
- $degree_plan = $fp->degree_plan;
- $GLOBALS["fp_advising"]["load_from_cache"] = "no";
- $bool_loaded = TRUE;
- }
-
-
-
- // Should we update the USER settings for anything?
- if ($GLOBALS["fp_advising"]["fp_update_user_settings_flag"] != "") {
- if (!$db->update_user_settings_from_post($user->id)) {
- fp_add_message(t("Unable to update user settings. Please try again later."));
- }
- }
-
-
- // If the form has been saved, this token is expected. This protects
- // against XSS attacks.
- $form_token = md5("advise_display_view" . fp_token());
- if ($perform_action == "save_draft") {
- if ($_REQUEST["form_token"] != $form_token) {
- die(t("Sorry, but you have encountered an error. A form submission was flagged
- as possibly being an invalid or forged submission. This may constitute a bug
- in the system. Please report this error to your Systems Administrator."));
- }
-
- // Save, then reload the student.
- $adv_id_array = $fp->save_advising_session_from_post(0,true);
-
- // Look for hook_save_advising_session()...
- invoke_hook("save_advising_session", $adv_id_array);
-
- $bool_draft = TRUE; // load draft, since we just saved it (and changed something)
-
-
- }
- else if ($perform_action == "save_active") {
- if ($_REQUEST["form_token"] != $form_token) {
- die(t("Sorry, but you have encountered an error. A form submission was flagged
- as possibly being an invalid or forged submission. This may constitute a bug
- in the system. Please report this error to your Systems Administrator."));
- }
-
- // Save, then go to the history screen.
- $adv_id_array = $fp->save_advising_session_from_post(0,false);
-
- // Look for hook_save_advising_session()...
- invoke_hook("save_advising_session", $adv_id_array);
-
- // Use an fp_goto command here to go to the History screen
- // Serialize the adv_id_array so we can send it along in our fp_goto command...
- $adv_id_serialized = serialize($adv_id_array);
-
- fp_goto("history", "adv_id_array_serialized=" . urlencode($adv_id_serialized));
- return;
-
- }
-
-
- // Is the user trying to view "by type" or by year?
- if ($GLOBALS["fp_advising"]["advising_view"] == "type") {
- $screen = new AdvisingScreenTypeView("", $fp);
- $screen->view = "type";
-
- }
- else {
- // Default advising view. "View by Year"
- $screen = new AdvisingScreen("", $fp);
- $screen->view = "year";
- }
-
-
- if (@$_REQUEST["bool_blank"] == "true" || @$_REQUEST["blank_degree_id"] != "") {
- $screen->bool_blank = TRUE;
- }
-
-
-
- if ($bool_what_if == true && @$GLOBALS["fp_advising"]["what_if_major_code"] == "") {
- // In other words, we are on the WhatIf tab, but we have not
- // selected a major. So, just exit out. We will give the user
- // a display_screen later.
- return;
- }
-
-
- if (@$GLOBALS["fp_advising"]["load_from_cache"] != "yes") {
- // do not load from cache.... load the student fresh....
-
-
- /*
- $fp = new FlightPath();
- $fp->init();
- $student = $fp->student;
- $degree_plan = $fp->degree_plan;
- $GLOBALS["fp_advising"]["load_from_cache"] = "no";
- */
-
- $student->load_student();
- $student->load_student_substitutions();
- $student->load_unassignments();
-
- // Make sure we assign the freshly-loaded student, and re-establish all of our connections.
- $fp->student = $student;
- $screen->flightpath = $fp;
- $screen->student = $fp->student;
-
- $fp->flag_outdated_substitutions();
- $fp->assign_courses_to_semesters(); // bare degree plan. not groups.
- $fp->assign_courses_to_groups();
-
- ////////////
- /*
- // Good place to output a serialization, in case we need it for testing.
- $student->name = "Test Student2";
- $student->student_id = "123457";
- $temp = serialize($screen);
- file_put_contents(fp_get_files_path() . "/test.txt", $temp);
- /////////////*/
-
-
-
-
- }
- else {
-
-
- }
-
-
-
-
- if (@$GLOBALS["fp_advising"]["save_to_cache"] != "no" && $window_mode != "popup") {
- if ($bool_what_if == false) {
- // NOT in whatIf mode. Normal.
-
- $_SESSION["cache_fp$csid"] = serialize($fp);
-
-
- }
- else {
- // We are in WhatIf mode.
- $_SESSION["cache_what_if$csid"] = serialize($fp);
-
-
-
- }
- }
-
-
- // If we are loading from draft, then load the faculty_id which saved draft last. If we are
- // loading fresh, not from draft, then load *any* faculty that saved last.
- $use_faculty_id = $faculty_id;
- if (!$bool_draft) $use_faculty_id = 0;
-
-
- // We shouldn't supply the advising_term_id, so that it will load all terms available.
- $fp->load_advising_session_from_database($use_faculty_id,"",$bool_what_if,$bool_draft,0,$faculty_id);
-
-
- // Once we have loaded the advising session, we should always try to load
- // from draft from then on out.
- $GLOBALS["fp_advising"]["advising_load_active"] = "";
-
-
-
- }
-
-
-
-
- /**
- * This is a hook which developers may use to add custom blocks (or perform other operations)
- * onto the advising View or What If screen.
- *
- * This is called AFTER the AdvisingScreen class has called it's build_screen_elements()
- * function, which draws the various semester blocks, footnotes, etc, onto the screen.
- *
- * This gives other modules a chance to alter the screen, or to add a custom block to the
- * bottom of the screen. Note that the $screen element is sent by reference. Any changes
- * you make to it will be instant; there is no need to return anything.
- *
- * To see how these blocks are best set up, look at AdvisingScreen->build_excess_credit(), or
- * AdvisingScreen->displaySemester() for inspiration.
- *
- * @param AdvisingScreen &$screen
- */
- function hook_advise_build_screen_elements(&$screen) {
-
- $html = "";
- $html .= $screen->draw_semester_box_top("Sample", TRUE); // pass TRUE to hide the "headers"
- $html .= "<tr><td colspan='8'>"; // required after the top!
-
- ////////////////
- // The content...
- $html .= "<b>Hello World!</b>";
-
- ///////////////////
-
- // All done, time to tidy up...
- $html .= "</td></tr>"; // required before the bottom!
- $html .= $screen->draw_semester_box_bottom();
-
-
-
- // Add to the screen as a "semester block".
- $screen->add_to_screen($html);
-
- }
-
Functions
Name | Description |
---|---|
advise_can_access_view | Used by the menu to determine if the user can see the View tab for the current student. |
advise_clear_cache | Implementation of hook_clear_cache Called by other modules, this function will take care of clearing anything this module has cached. |
advise_display_popup_change_term | This popup allows the advisor to change the advising term. |
advise_display_popup_change_track | |
advise_display_popup_change_track_non_dynamic_degree | This is the "change track" popup we will display if the degree cannot be combined with anything else (non-dynamic). |
advise_display_popup_course_description | |
advise_display_popup_group_select | |
advise_display_popup_substitute_selected | |
advise_display_view | This is the page which actually displays the "view" for the user to see their advising session, or for an advisor to advise them. |
advise_get_advisees | |
advise_init | Implementation of hook_init |
advise_init_advising_variables | Takes various variables from the REQUEST and stores them in our advising_session_variables table for more convenient use later on. |
advise_init_screen | |
advise_menu | |
advise_perform_clear_advising_cache | From menu hook. Clear just the advising cache. |
advise_perm | Implementation of hook_perm |
advise_toggle_draft_form | |
advise_toggle_draft_form_submit | |
advise_user_can_view_advising_session_access_callback | This is an access callback. Can the user view the advising session specified in the REQUEST? |
advise_what_if_selection_form | |
advise_what_if_selection_form_submit | 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. |
advise_what_if_selection_form_validate | Validate handler for the what_if selection form. This is where we might, for example, make sure that if a non-dynamic degree was selected, that they can't proceed. |
hook_advise_build_screen_elements | This is a hook which developers may use to add custom blocks (or perform other operations) onto the advising View or What If screen. |
z__old__advise_display_popup_change_track | |
z___advise_display_what_if_selection | Displays the pulldown select list for picking a new What If degree. Returns HTML. |