admin_get_course_array_from_definition_data

4.x admin.groups.inc admin_get_course_array_from_definition_data($subject_data, $course_numData, $catalog_year = "")
1 call to admin_get_course_array_from_definition_data()

File

modules/admin/admin.groups.inc, line 658

Code

function admin_get_course_array_from_definition_data($subject_data, $course_numData, $catalog_year = "") {

  // Looks at the subjectData and course_numData fields, and constructs
  // a query to pull our every course which matches it.

  $rtn_array = array();

  $si = str_replace("*", "%", $subject_data);
  $cn = str_replace("*", "%", $course_numData);

  $catalog_line = "";
  if ($catalog_year != "") {
    $catalog_line = "AND catalog_year = '$catalog_year'";
  }


  $query = "SELECT * FROM draft_courses
        WHERE 
          subject_id LIKE '?'
        AND course_num LIKE '?'
        AND course_id > 0
        $catalog_line
        GROUP BY subject_id, course_num
        ";
  $res = db_query($query, $si, $cn);
  while ($cur = db_fetch_array($res)) {
    $course_id = $cur["course_id"];

    if (in_array($course_id, $rtn_array)) {
      continue;
    }
    $rtn_array[] = $course_id;

  }

  return $rtn_array;
}