function course_search_get_course_rotation_schedule

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)
4 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.
prereqs_content_alter in modules/prereqs/prereqs.module
Implememnt hook_content_alter
prereqs_get_prereq_warnings_for_course in modules/prereqs/prereqs.module
This is meant to be a general function to find all relavent prereq warnings for the supplied course.

File

modules/course_search/course_search.module, line 822
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) 
 {

  // Has this already been saved to our globals cache?  If so, just return that.          
  if (isset($GLOBALS ['cache_course_search_rotation_schedule'][$course_id][$year][$limit][intval($bool_include_next_five_years)])) {
    return $GLOBALS ['cache_course_search_rotation_schedule'][$course_id][$year][$limit][intval($bool_include_next_five_years)];
  }


  $year = intval($year);
  $limit = intval($limit);


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


  //////////////////////////////////////
  // Okay, now we invoke a hook, to see if any other modules
  // would like to add or alter our rotation schedule (notice $rtn_array is passed by reference)
  invoke_hook("course_search_get_course_rotation_schedule", array(&$rtn_array, $course_id, $year, $limit, $bool_include_next_five_years));


  // Save to globals cache to make it faster lookup
  $GLOBALS ['cache_course_search_rotation_schedule'][$course_id][$year][$limit][intval($bool_include_next_five_years)] = $rtn_array;


  return $rtn_array;
}