Changeset - 446c8b9555f4
[Not reviewed]
default
0 1 0
Nathan Brink (binki) - 14 years ago 2012-02-16 10:08:05
ohnobinki@ohnopublishing.net
Automatically determine a workable student_address value (<college name> student).
1 file changed with 5 insertions and 2 deletions:
0 comments (0 inline, 0 general)
inc/school.inc
Show inline comments
 
@@ -58,50 +58,53 @@ function school_load($school_id, $load_a
 
{
 
  $school = array('id' => $school_id);
 

	
 
  /* guard against cracking attempts (protects against '../' and friends) */
 
  if (!preg_match('/^[0-9a-z]+$/', $school_id))
 
    return NULL;
 
  $school_file_name_base = dirname(dirname(__FILE__)) . DIRECTORY_SEPARATOR . 'school.d' . DIRECTORY_SEPARATOR;
 
  $school_file_name = $school_file_name_base . $school_id . '.inc';
 

	
 
  if (!file_exists($school_file_name))
 
    return NULL;
 

	
 
  require_once($school_file_name);
 
  if ($load_all_inc)
 
    {
 
      $school_crawl_file_name = $school_file_name_base . $school_id . '.crawl.inc';
 
      if (file_exists($school_crawl_file_name))
 
	require_once($school_crawl_file_name);
 
    }
 

	
 
  $school_info = $school_id . '_info';
 
  $school += $school_info();
 

	
 
  /* Overridable defaults: */
 
  $school += array('domains' => array($school_id . '.edu'),
 
		   'url' => 'http://' . $school_id . '.edu/');
 
  $school += array(
 
    'domains' => array($school_id . '.edu'),
 
    'url' => 'http://' . $school_id . '.edu/',
 
    'student_address' => $school['name'] . ' student',
 
  );
 

	
 
  /*
 
   * append small amount of info from the cache entry for this school:
 
   * whether or not it was crawled.
 
   *
 
   * Perhaps this stuff should be just moved into the _info function
 
   * for efficiency.
 
   */
 
  $cache = _school_cache_load();
 
  if ($cache && count($cache['list']) && isset($cache['list'][$school['id']]))
 
    {
 
      $school['crawled'] = $cache['list'][$school['id']]['crawled'];
 

	
 
      $school_semesters_filename = dirname(dirname(__FILE__)) . DIRECTORY_SEPARATOR . 'cache'
 
	. DIRECTORY_SEPARATOR . 'auto' . DIRECTORY_SEPARATOR . $school['id']
 
	. DIRECTORY_SEPARATOR . '-semesters';
 
      if (file_exists($school_semesters_filename))
 
	$school['semesters'] = unserialize(file_get_contents($school_semesters_filename));
 
      else
 
	$school['semesters'] = array();
 
    }
 

	
 
  return $school;
 
}
0 comments (0 inline, 0 general)