function _Course::load_course_from_data_string

4.x _Course.php _Course::load_course_from_data_string($str)
5.x _Course.php _Course::load_course_from_data_string($str)

This will take a data string, as created by the function to_data_string(), and make $this object match the original object. It is a poor man's unserialize. See to_data_string()'s description for a fuller picture of what is going on.

To use:

  • $newCourse = new Course();
  • $newCourse->load_course_from_data_string($data);

Parameters

string $str:

File

classes/_Course.php, line 210

Class

_Course

Code

function load_course_from_data_string($str) 
 {

  $temp = explode("~", $str);

  $this->course_id = $temp [0];

  $this->load_course($this->course_id);

  $this->assigned_to_semester_num = $temp [1];
  $this->assigned_to_group_id = $temp [2];
  $this->bool_advised_to_take = (bool) $temp [3];
  $this->specified_repeats = $temp [4];
  $this->bool_specified_repeat = (bool) $temp [5];
  $this->grade = $temp [6];
  $this->hours_awarded = $temp [7] * 1; // *1 to force numeric, and trim extra zeros.
  $this->term_id = $temp [8];
  $this->advised_hours = $temp [9] * 1;

  $this->bool_transfer = (bool) $temp [10];

  // Was this a transfer course?
  if ($this->bool_transfer == true) 
   {
    $t_course = new Course($temp [11], true);
    $t_course->term_id = $this->term_id;
    $this->course_transfer = $t_course;
  }

  $this->bool_added_course = (bool) $temp [12];
  $this->db_advised_courses_id = $temp [13];
  $this->random_id = $temp [14];

  $this->bool_substitution = (bool) $temp [15];

  // Was this a substitution course?
  if ($this->bool_substitution == true) 
   {
    $t_course = new Course($temp [16]); // original course requirement.
    $this->course_substitution = $t_course;
  }

  $this->db_substitution_id = $temp [17];
  $this->min_hours = $temp [18] * 1;
  $this->max_hours = $temp [19] * 1;

  $this->bool_substitution_new_from_split = (bool) $temp [20];
  $this->bool_substitution_split = (bool) $temp [21];
  $this->bool_has_been_assigned = (bool) $temp [22];

  $this->display_status = $temp [23];

  $this->bool_ghost_hour = (bool) $temp [24];



}