function admin_get_course_array_from_definition_data

7.x admin.groups.inc admin_get_course_array_from_definition_data($subject_data, $course_numData, $catalog_year = "", $school_id = 0, $bool_check_allow_default_school = FALSE)
6.x admin.groups.inc admin_get_course_array_from_definition_data($subject_data, $course_numData, $catalog_year = "", $school_id = 0, $bool_check_allow_default_school = FALSE)
4.x admin.groups.inc admin_get_course_array_from_definition_data($subject_data, $course_numData, $catalog_year = "")
5.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 1060

Code

function admin_get_course_array_from_definition_data($subject_data, $course_numData, $catalog_year = "", $school_id = 0, $bool_check_allow_default_school = FALSE) {

  // 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);

  $params = array();


  $catalog_line = "";
  if ($catalog_year != "") {
    $catalog_line = "AND catalog_year = :catalog_year";
    $params [":catalog_year"] = $catalog_year;
  }

  $school_line = " AND school_id = :school_id ";
  // Should we ALSO check the default school, in addition to whatever we specified?  Don't bother if what we specified was the default school.
  if ($bool_check_allow_default_school && module_enabled('schools') && variable_get('schools_allow_courses_from_default_school', 'yes') === 'yes' && $school_id != 0) {
    $school_line = " AND (school_id = :school_id OR school_id = 0) ";
  }

  $params [':subject_id'] = $si;
  $params [':course_num'] = $cn;
  $params [':school_id'] = $school_id;


  $query = "SELECT * FROM draft_courses
              WHERE subject_id LIKE :subject_id
              AND course_num LIKE :course_num
              AND course_id > 0
              $school_line
              $catalog_line
              GROUP BY subject_id, course_num
        ";
  $res = db_query($query, $params);
  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;
}