Changeset - 7ce16688498d
[Not reviewed]
default
0 1 0
Nathan Brink (binki) - 15 years ago 2010-10-13 17:57:42
ohnobinki@ohnopublishing.net
Sort the college profiles listed on the ``School Selection'' page.
1 file changed with 12 insertions and 0 deletions:
0 comments (0 inline, 0 general)
admin/rehash.php
Show inline comments
 
@@ -83,24 +83,35 @@ function school_list()
 
	continue;
 

	
 
      $school_id_list[] = $matches[1];
 
    }
 

	
 
  closedir($schoold_dir);
 

	
 
  return $school_id_list;
 
}
 

	
 
/**
 
 * \brief
 
 *   Compare the two schools by their names.
 
 *
 
 * \see strcmp()
 
 */
 
function school_cmp($school_a, $school_b)
 
{
 
  return strcmp($school_a['name'], $school_b['name']);
 
}
 

	
 
/**
 
 * \brief
 
 *   Write out the cache file which remembers the list of available
 
 *   schools.
 
 *
 
 * \todo
 
 *   If the list of displayed schools is to be sorted, this is the
 
 *   place to do it.
 
 *
 
 * \param $schools
 
 *   An array of school handles.
 
 */
 
function school_cache($schools)
 
{
 
@@ -124,24 +135,25 @@ function school_cache($schools)
 
		  || !is_array($domain_cache_ptr[$domain_part]))
 
		$domain_cache_ptr[$domain_part] = array();
 
	      $domain_cache_ptr =& $domain_cache_ptr[$domain_part];
 
	    }
 
	  /*
 
	   * get the last part which is unambiguously identifies this
 
	   * school combined with the previous parts
 
	   */
 
	  $domain_part = array_shift($domain_parts);
 
	  $domain_cache_ptr[$domain_part] = $school['id'];
 
	}
 
    }
 
  uasort($list_cache, 'school_cmp');
 

	
 
  $cache = array('list' => $list_cache, 'domains' => $domain_cache);
 

	
 

	
 
  $cache_file_name = dirname(__FILE__) . DIRECTORY_SEPARATOR . '..'
 
    . DIRECTORY_SEPARATOR . 'cache' . DIRECTORY_SEPARATOR . 'schools';
 
  $cache_file = fopen($cache_file_name, 'wb');
 
  if ($cache_file === FALSE)
 
    {
 
      fprintf(STDERR, "Unable to open `%s' for writing\n",
 
	      $cache_file_name);
 
      return 1;
0 comments (0 inline, 0 general)