function DatabaseHandler::get_degrees_in_catalog_year

7.x DatabaseHandler.php DatabaseHandler::get_degrees_in_catalog_year($catalog_year, $bool_include_tracks = false, $bool_use_draft = false, $bool_undergrad_only = TRUE, $only_level_nums = array(1, 2), $school_id = 0)
6.x DatabaseHandler.php DatabaseHandler::get_degrees_in_catalog_year($catalog_year, $bool_include_tracks = false, $bool_use_draft = false, $bool_undergrad_only = TRUE, $only_level_nums = array(1, 2), $school_id = 0)

File

classes/DatabaseHandler.php, line 1486

Class

DatabaseHandler

Code

function get_degrees_in_catalog_year($catalog_year, $bool_include_tracks = false, $bool_use_draft = false, $bool_undergrad_only = TRUE, $only_level_nums = array(1, 2), $school_id = 0) 
 {
  // Returns an array of all the degrees from a particular year
  // which are entered into FlightPath.

  $undergrad_line = $degree_class_line = "";

  $table_name = "degrees";
  if ($bool_use_draft) {
    $table_name = "draft_$table_name";
  }

  // change this to be whatever the graduate code actually is.
  if ($bool_undergrad_only) {
    $undergrad_line = " AND degree_level <> 'GR' ";
  }

  $degree_class_line = "";
  if (count($only_level_nums) > 0) {
    $classes = fp_get_degree_classifications();
    foreach ($only_level_nums as $num) {
      foreach ($classes ["levels"][$num] as $machine_name => $val) {
        $degree_class_line .= " degree_class = '" . addslashes($machine_name) . "' OR";
      }
    }
    // Remove training "OR" from degree_class_line
    $degree_class_line = substr($degree_class_line, 0, strlen($degree_class_line) - 2);
  }

  if ($degree_class_line != "") {
    $degree_class_line = "AND ($degree_class_line)";
  }

  $rtn_array = array();
  $res = $this->db_query("SELECT `id`, degree_id, major_code, title, degree_class , school_id, catalog_year
                            FROM $table_name
                            WHERE exclude = '0'
                              AND catalog_year = ?                
                              AND school_id = ?
                              $undergrad_line
                              $degree_class_line
                            ORDER BY title, major_code ", $catalog_year, $school_id);
  if ($this->db_num_rows($res) < 1) 
   {
    return false;
  }

  while ($cur = $this->db_fetch_array($res)) 
   {
    $degree_id = $cur ["degree_id"];
    $major = trim($cur ["major_code"]);
    $title = trim($cur ["title"]);
    $track_code = "";
    $major_code = $major;

    // The major may have a track specified.  If so, take out
    // the track and make it seperate.
    if (strstr($major, "_")) 
     {
      $temp = explode("_", $major);
      $major_code = trim($temp [0]);
      $track_code = trim($temp [1]);
      // The major_code might now have a | at the very end.  If so,
      // get rid of it.
      if (substr($major_code, strlen($major_code) -1, 1) == "|") 
       {
        $major_code = str_replace("|", "", $major_code);
      }


    }

    // Leave the track in if requested.
    if ($bool_include_tracks == true) 
     {
      // Set it back to what we got from the db.
      $major_code = $major;
      $temp_degree = $this->get_degree_plan($major, $catalog_year, true);
      if ($temp_degree->track_code != "") 
       {
        $title .= " - " . $temp_degree->track_title;
      }
    }

    $rtn_array [$major_code]["title"] = $title;
    $rtn_array [$major_code]["degree_id"] = $degree_id;
    $rtn_array [$major_code]["degree_class"] = trim(strtoupper($cur ["degree_class"]));
    $rtn_array [$major_code]["school_id"] = intval($cur ['school_id']);
    $rtn_array [$major_code]["catalog_year"] = $cur ['catalog_year'];
    $rtn_array [$major_code]["db_id"] = $cur ['id'];

  }

  return $rtn_array;

}