function _DegreePlan::find_placeholder_group

4.x _DegreePlan.php _DegreePlan::find_placeholder_group($group_id, $semester_num)
5.x _DegreePlan.php _DegreePlan::find_placeholder_group($group_id, $semester_num)

File

classes/_DegreePlan.php, line 631

Class

_DegreePlan

Code

function find_placeholder_group($group_id, $semester_num) 
 {
  // Locate the group within the semesters that matches
  // this group_id and semesterNum.  The assumption here
  // is that no one semester will list the same
  // group twice.  In other words, Core Fine Arts
  // can only have 1 entry for Freshman Year.

  // Create a dummy semester with the correct semesterNum...
  $new_semester = new Semester($semester_num);
  // Create dummy group as well... don't use the constructor, just
  // set the group_id manually to same time. (no DB calls)
  $new_group = new Group();
  $new_group->group_id = $group_id;

  //print_pre($this->list_semesters->to_string());
  // Find the semester in the list of semesters with this same semesterNum...
  if (!$semester = $this->list_semesters->find_match($new_semester)) 
   {
    // The semester wasn't found!
    return false;
  }


  // Okay, now go through $semester and find the group_id...
  if (!$group = $semester->list_groups->find_match($new_group)) 
   {
    // It wasn't found in the top-level groups.  Look one deeper...
    if (!$semester->list_groups->is_empty) 
     {
      $semester->list_groups->reset_counter();
      while ($semester->list_groups->has_more()) 
       {
        $group = $semester->list_groups->get_next();
        if ($g = $group->list_groups->find_match($new_group)) 
         {
          //$g->assign_to_semester($semester_num);
          return $g;
        }
      }
    }
  }
  else {
    // Meaning, we found it!
    //$group->assign_to_semester($semester_num);
    return $group;
  }

  return false;

}