Changeset - 34aabb706e18
[Not reviewed]
default
0 2 0
Nathan Brink (binki) - 15 years ago 2011-03-22 00:32:41
ohnobinki@ohnopublishing.net
Fix some php errors by removing empty courses completely.

This case was not caught before because courses may appear to be nonempty during the parsing of POST data. Thus, an additional filtering process was added.
2 files changed with 14 insertions and 1 deletions:
0 comments (0 inline, 0 general)
inc/class.schedule.php
Show inline comments
 
@@ -145,24 +145,37 @@ class Schedule
 
	}
 

	
 
    error_log('Could not find class when parsing schedule from postData: ' . $course_name);
 
    echo 'Could not find class: ' . $course_name . "<br />\n";
 
  }
 

	
 
  //--------------------------------------------------
 
  // Finds all of the possible permutations and stores
 
  // the results in the storage array.
 
  //--------------------------------------------------
 
	function findPossibilities()
 
	{
 
	  /*
 
	   * Clean crud (completely empty courses) out of the
 
	   * schedule. For some crud, it's much easier to detect that
 
	   * it's crud now than during parsing of postData[].
 
	   */
 
	  foreach ($this->courses as $i => $course)
 
	    if (!$course->getnsections())
 
	      {
 
		unset($this->courses[$i]);
 
		$this->courses = array_values($this->courses);
 
		return $this->findPossibilities();
 
	      }
 

	
 
		$this->possiblePermutations = 1;
 
		/* special case: there is nothing entered into the schedule and thus there is one, NULL permutation */
 
		if (!count($this->courses))
 
		{
 
			/* have an empty schedule */
 
			$this->nPermutations = 1;
 
			return;
 
		}
 

	
 
		$position = 0;
 
		$counter = 0;
 

	
process.php
Show inline comments
 
@@ -169,25 +169,25 @@ if(!$DEBUG)
 
		   * section to the class. We know that $class['name']
 
		   * is not a section, so count() needs to be > 1 and
 
		   * we need to skip over 'name' in our loop.
 
		   */
 
			if(is_array($class) && count($class) > 1)
 
			{
 
				$allClasses->addCourse($class['name']);
 
		
 
				foreach($class as $section)
 
				  /* Skip the section name, which isn't a section */
 
					if(is_array($section))
 
					  {
 
					    $error_string = $allClasses->addSection($class['name'], $section['letter'], $section['start'], $section['end'], arrayToDays($section['days'], 'alpha'), $section['synonym'], $section['professor'], $section['location'], $section['type']);
 
					    $error_string = $allClasses->addSection($class['name'], $section['letter'], $section['start'], $section['end'], arrayToDays(empty($section['days']) ? array() : $section['days'], 'alpha'), $section['synonym'], $section['professor'], $section['location'], $section['type']);
 
					    if ($error_string !== NULL)
 
					      $errors[] = $error_string;
 
					  }
 
			}
 
		}
 

	
 
		/*
 
		 * Tell the user that his input is erroneous and
 
		 * require him to fix it.
 
		 */
 
		if (count($errors))
 
		  {
0 comments (0 inline, 0 general)