Changeset - 89bb2a4a5235
[Not reviewed]
default
0 1 0
Nathan Brink (binki) - 15 years ago 2010-10-24 01:55:19
ohnobinki@ohnopublishing.net
Don't display ``<location unknown>'' and ``unknown prof'' for schedules saved by old versions of slate_permutate.
1 file changed with 4 insertions and 1 deletions:
0 comments (0 inline, 0 general)
class.section.php
Show inline comments
 
@@ -206,34 +206,37 @@ class Section
 
  }
 

	
 

	
 
  /* for legacy unserialization */
 
  private $start;
 
  private $tend;
 
  private $bdays;
 

	
 
  /**
 
   * \brief
 
   *   A magic function which tries to upgrade old serialized sections
 
   *   to the new format.
 
   */
 
  public function __wakeup()
 
  {
 
    /* upgrade to SectionMeeting stuffage */
 
    if (!empty($this->start))
 
      {
 
	$days = '';
 
	$daymap = array(0 => 'm', 1 => 't', 2 => 'w', 3 => 'h', 4 => 'f');
 
	foreach ($this->bdays as $day => $have_day)
 
	  if ($have_day)
 
	    $days .= $daymap[$day];
 

	
 
	/* the old format had a ->prof but initialied it to ``unknown prof'' */
 
	$this->prof = '';
 

	
 
	$this->meetings = array();
 
	$this->meeting_add(new SectionMeeting($days, $this->start, $this->tend, '<location unknown>', 'lecture'));
 
	$this->meeting_add(new SectionMeeting($days, $this->start, $this->tend, '', 'lecture'));
 

	
 
	/*
 
	 * if we're reserialized in the future, make sure we don't do this same upgrade procedure again ;-).
 
	 */
 
	unset($this->start);
 
      }
 
  }
 
}
0 comments (0 inline, 0 general)