function Group::replace_missing_course
Search API
7.x Group.php | Group::replace_missing_course($course_id, $db_group_requirement_id = "") |
6.x Group.php | Group::replace_missing_course($course_id, $db_group_requirement_id = "") |
File
- classes/
Group.php, line 434
Class
Code
function replace_missing_course($course_id, $db_group_requirement_id = "")
{
// replace course_id in this group, if it is missing.
$table_name = "group_requirements";
if ($this->bool_use_draft) {
$table_name = "draft_$table_name";
}
// Look for all instances of this course in the group's base list...
$res = db_query("SELECT `id`, course_repeats FROM `$table_name`
WHERE group_id = ?
AND course_id = ? ", $this->get_db_group_id(), $course_id);
while ($cur = db_fetch_array($res))
{
$id = $cur ["id"];
for ($t = 0; $t <= $cur ["course_repeats"]; $t++)
{
$course = new Course($course_id, false, $this->db, false, "", $this->bool_use_draft);
$use_id = $id . "_rep_$t";
// Make sure the group does not already have this requirementID...
if ($this->list_courses->contains_group_requirement_id($use_id))
{
continue;
}
$course->assigned_to_group_id = $this->group_id;
$course->requirement_type = $this->requirement_type;
$course->db_group_requirement_id = $use_id;
$course->db_group_attributes = $cur ['attributes'];
$course->specified_repeats = $cur ["course_repeats"];
if ($cur ["course_repeats"] > 0)
{
$course->bool_specified_repeat = true;
}
$this->list_courses->add($course);
}
}
// Now, go through all of the group's branches and
// do the same thing.
$this->list_groups->reset_counter();
while ($this->list_groups->has_more())
{
$g = $this->list_groups->get_next();
$g->replace_missing_course($course_id);
}
}