function FlightPath::init
Search API
7.x FlightPath.php | FlightPath::init($bool_init_advising_variables = false, $bool_ignore_what_if_advising_variables = false, $bool_load_full = true) |
6.x FlightPath.php | FlightPath::init($bool_init_advising_variables = false, $bool_ignore_what_if_advising_variables = false, $bool_load_full = true) |
3 calls to FlightPath::init()
- FlightPath::process_request_save_draft in classes/
FlightPath.php - This function will check to see if we are trying to save the draft from a tab change. It should be near the top of all of FP's "tab" pages, like Main, Comments, etc.
- FlightPath::save_advising_session_from_post in classes/
FlightPath.php - FlightPath::__construct in classes/
FlightPath.php
File
- classes/
FlightPath.php, line 37
Class
Code
function init($bool_init_advising_variables = false, $bool_ignore_what_if_advising_variables = false, $bool_load_full = true) {
global $current_student_id, $user, $student;
// This will initialize this flightPath object
// based on what is available in the global variables.
// Takes the place of what was going on at the beginning
// of advise.php.
if ($bool_init_advising_variables == true)
{
//$temp_screen = new AdvisingScreen();
//$temp_screen->init_advising_variables($bool_ignore_what_if_advising_variables);
//advise_load_advising_variables_from_db($current_student_id, $user->id);
advise_init_advising_variables();
}
$major_code_csv = $GLOBALS ["fp_advising"]["advising_major_code"];
//$track_code = $GLOBALS["fp_advising"]["advising_track_code"];
$track_degree_ids = $GLOBALS ["fp_advising"]["advising_track_degree_ids"];
$student_id = $GLOBALS ["fp_advising"]["advising_student_id"];
$advising_term_id = $GLOBALS ["fp_advising"]["advising_term_id"];
@$available_terms = $GLOBALS ["fp_advising"]["available_advising_term_ids"];
// Keep in mind-- at this point, major_coe might be a CSV of major codes.
$this->bool_what_if = false;
// Are we in WhatIf mode?
if ($GLOBALS ["fp_advising"]["advising_what_if"] == "yes")
{
$major_code_csv = $GLOBALS ["fp_advising"]["what_if_major_code"];
$track_degree_ids = $GLOBALS ["fp_advising"]["what_if_track_degree_ids"];
$this->bool_what_if = true;
}
if ($bool_load_full == false)
{ // not trying to load anything, so return.
return;
}
$db = $this->db;
if ($bool_load_full == true)
{
$student = new Student($student_id);
}
else {
$student = new Student();
$student->student_id = $student_id;
}
$student_school_id = $db->get_school_id_for_student_id($student_id);
$catalog_year = $student->catalog_year;
if ($this->bool_what_if)
{
// We need to look at a "what_if_catalog_year" value.
$catalog_year = $GLOBALS ["fp_advising"]["what_if_catalog_year"];
if ($catalog_year == "" || $catalog_year == 0) {
// Some problem, default to current cat year.
$catalog_year = variable_get_for_school("current_catalog_year", '', $student_school_id);
}
}
// make sure their catalog year is not past the system's current
// year setting.
if ($catalog_year > variable_get_for_school("current_catalog_year", '', $student_school_id) && variable_get_for_school("current_catalog_year", '', $student_school_id) > intval(variable_get_for_school("earliest_catalog_year", 2006, $student_school_id)))
{ // Make sure degree plan is blank if it is!
$catalog_year = 99999;
}
if ($GLOBALS ["fp_advising"]["advising_update_student_settings_flag"] != "")
{
// TODO: This is used in What If mode. We need to make sure that these track_degree_ids
// actually do match to the selected majors. If not, then we should remove them. This
// is to make sure that when we switch What If settings, these get cleared.
$wi = "";
if ($this->bool_what_if) {
$wi = "what_if_";
}
//$student->array_settings["track_code"] = $track_code;
$student->array_settings [$wi . "track_degree_ids"] = $track_degree_ids;
$student->array_settings [$wi . "major_code_csv"] = $major_code_csv;
}
// Let's add the track_degree_ids to the major_code_csv...
$major_code_csv .= "," . $track_degree_ids;
///////////////////////////////
// Okay folks. So this is basically where we will be iterating through all
// of the student's major_codes (if they have more than one), and squishing them together,
// to create a single DegreePlan object, made out of all the options.
// We need like a loop here.
$degree_plans = array();
$temparr = explode(",", $major_code_csv);
foreach ($temparr as $major_code) {
$t_major_code = $major_code;
if (trim($major_code) == "") {
continue;
}
// If we are dealing with a track, then just get the degree_id directly, else, figure out the
// degree_id from the t_major_code.
if (is_numeric($t_major_code)) {
$degree_id = $t_major_code;
}
else {
$degree_id = $db->get_degree_id($t_major_code, $catalog_year, FALSE, $student_school_id);
}
// If we couldn't find the degree_id, then we should just skip it.
if (!$degree_id || $degree_id == 0) {
if (variable_get("warning_on_view_if_degree_not_found", "yes") == 'yes') {
fp_add_message(t("Could not find degree %maj in catalog year %cat. FlightPath will
skip loading this degree for now. If this message continues to appear,
contact your advisor.", array("%maj" => $t_major_code, "%cat" => $student->catalog_year . "-" . ($student->catalog_year + 1))), "error", TRUE);
}
continue;
}
if ($bool_load_full == true)
{
$this->student = $student;
$degree_plan = fp_load_degree($degree_id, $db, FALSE, $student->array_significant_courses);
//$degree_plan = new DegreePlan($degree_id, $db, FALSE, $student->array_significant_courses);
$degree_plan->add_semester_developmental($student->student_id);
//$this->degree_plan = $degree_plan;
$degree_plans [$degree_plan->degree_id] = $degree_plan;
}
} // foreach temparr as major_code. The foreach loop through all our major codes.
// Okay, coming out of this, we have an array of degree_plans (maybe). If it's just one, then set it to that one.
if (count($degree_plans) == 1) {
$this->degree_plan = $degree_plan;
}
else if (count($degree_plans) > 1) {
// Okay folks, here's the magic. We need to combine the degree plans in this array
// into 1 generated degree plan.
$combined_degree_plan = $this->combine_degree_plans($degree_plans, $student_id, $student_school_id);
$combined_degree_plan->db_allow_dynamic = 1; // since they are combined, we must be allowing dynamic.
$this->degree_plan = $combined_degree_plan;
} // else if count(degree_plans) > 1
else if (count($degree_plans) < 1) {
// Meaning, we couldn't find any degree plans for this student! Let's just load some blank objects.
$this->degree_plan = new DegreePlan();
$this->student = $student;
}
// Invoke a hook which lets other modules act on this student and degree plan we just loaded.
invoke_hook('init_flightpath_degree', array($this->student->student_id, &$this->degree_plan));
$wi = "";
if ($this->bool_what_if) {
$wi = "_what_if";
}
if (isset($this->degree_plan) && $this->degree_plan != null) {
// Add degree_plan to a simple cache to make our lives easier later on.
$_SESSION ["fp_simple_degree_plan_cache_for_student" . $wi] = array(
"cwid" => $student_id,
"degree_id" => $this->degree_plan->degree_id,
"combined_degree_ids_array" => $this->degree_plan->combined_degree_ids_array,
"is_combined_dynamic_degree_plan" => $this->degree_plan->is_combined_dynamic_degree_plan,
);
}
}