function course_search_get_course_rotation_schedule

7.x course_search.module course_search_get_course_rotation_schedule($course_id, $year = "", $limit = 20, $bool_include_next_five_years = FALSE)
6.x course_search.module course_search_get_course_rotation_schedule($course_id, $year = "", $limit = 20, $bool_include_next_five_years = FALSE)
4.x course_search.module course_search_get_course_rotation_schedule($course_id, $year = "", $limit = 20, $bool_include_next_five_years = false)
5.x course_search.module course_search_get_course_rotation_schedule($course_id, $year = "", $limit = 20, $bool_include_next_five_years = false)
2 calls to course_search_get_course_rotation_schedule()
course_search_display_courses in modules/course_search/course_search.module
Show the user their select of courses.
course_search_display_edit_courses in modules/course_search/course_search.edit.inc
Display a plain list of courses, making it easier for admins to edit schedules and details in one spot.

File

modules/course_search/course_search.module, line 824
This module allows users to search for courses, descriptions, and, if supported, rotation schedules and sample syllabi.

Code

function course_search_get_course_rotation_schedule($course_id, $year = "", $limit = 20, $bool_include_next_five_years = false) 
 {
  // return an array containing the terms that this course
  // is going to be offered, if any.
  $rtn_array = array();
  $arr = array();
  $year_line = "";
  if ($year != "") 
   { // if a year is entered, we will get the next few years, and the previous
    // one for good measure.
    $year_line = "and (`term_id` LIKE '$year%' or `term_id` LIKE '" . ($year + 1) . "%') ";
    if ($bool_include_next_five_years) 
     {
      $yearm1 = $year - 1;
      $year2 = $year + 1;
      $year3 = $year + 2;
      $year4 = $year + 3;
      $year5 = $year + 4;
      $year6 = $year + 5;

      $year_line = "and (`term_id` LIKE '$year%'
							or `term_id` LIKE '$yearm1%'
							or `term_id` LIKE '$year2%'
							or `term_id` LIKE '$year3%'
							or `term_id` LIKE '$year4%'
							or `term_id` LIKE '$year5%'
							or `term_id` LIKE '$year6%'
					) ";
    }

  }


  $res = db_query("SELECT * FROM course_rotation_schedule
							WHERE `course_id`= ?
							$year_line
							ORDER BY term_id DESC
							LIMIT $limit", $course_id);
  while ($cur = db_fetch_array($res)) 
   {
    $t = $cur ["term_id"];
    // Get the term from the end.
    $ss = trim(substr($t, 4, 1));
    if ($ss == "m") {
      $ss = "1.5";
    }

    if (is_numeric($ss)) {
      $ss = $ss * 10;
    }

    $year = trim(substr($t, 0, 4));

    // We do all this so we can establish an order to the terms
    // by using a sort() command later.
    $arr [] = $year . "~" . $ss . "~" . $t;
  }

  sort($arr);
  // Now we want to get out JUST the terms...
  foreach ($arr as $line) 
   {
    $temp = explode("~", $line);
    $rtn_array [] = trim($temp [2]);
  }

  return $rtn_array;
}