Changeset - 1d32948ffcdb
[Not reviewed]
default
0 1 0
Nathan Brink (binki) - 15 years ago 2010-10-16 13:44:00
ohnobinki@ohnopublishing.net
Fix department auto-complete.
1 file changed with 5 insertions and 7 deletions:
0 comments (0 inline, 0 general)
auto.php
Show inline comments
 
@@ -65,32 +65,30 @@ if (!$school['crawled'])
 
 * entered a valid department name _and_ delimitted it, however, go on
 
 * to the next autocompletion step.
 
 */
 
$term_strlen = strlen($term);
 
$dept_strlen = strlen($term_parts['department']);
 
$dept = $term_parts['department'];
 
if (!$getsections && count($term_parts) == 1 && $term_strlen == strlen($dept))
 
  {
 
    $dept_file = $cache_dir . '-depts';
 
    if (!file_exists($dept_file))
 
      clean_empty_exit();
 
    $departments = unserialize(file_get_contents($dept_file));
 
    $json_depts = array();
 
    foreach ($departments as $key => $department)
 
      {
 
	if (!strncmp($department, $dept, $dept_strlen))
 
	  $departments[$key] = $department;
 
	else
 
	  unset($departments[$key]);
 
      }
 
    echo json_encode($departments);
 
      if (!strncmp($department, $dept, $dept_strlen))
 
	$json_depts[] = $department;
 

	
 
    echo json_encode($json_depts);
 
    exit(0);
 
  }
 

	
 
if ($getsections)
 
  {
 
    $section_file = $cache_dir . $dept . DIRECTORY_SEPARATOR . $term_parts['course'];
 
    if (file_exists($section_file))
 
      {
 
	readfile($section_file);
 
	exit(0);
 
      }
 
    /* section not found! */
0 comments (0 inline, 0 general)