From 122248a03c9f78e515c050c74b09890274432e21 Mon Sep 17 00:00:00 2001 From: james Date: Thu, 10 Jun 2010 17:58:27 +0000 Subject: [PATCH] Move the conference block above the configuration/dates loading, so we can load the right dates for the conference (and probably soon, the right configuration variables too!) --- common.inc.php | 65 ++++++++++++++++++++++++++++---------------------- 1 file changed, 36 insertions(+), 29 deletions(-) diff --git a/common.inc.php b/common.inc.php index 06df582..bba0a08 100644 --- a/common.inc.php +++ b/common.inc.php @@ -195,6 +195,36 @@ if(get_magic_quotes_gpc()) { exit; } + +//move the conference stuff before the configuration loading, so we can load the right configuration for the conference :) +if(isset($_GET['switchconference'])) { + //make sure its good + $cid=intval($_GET['switchconference']); +// echo "cid=$cid"; + if($cid==0) { + //default for old science fair system + $_SESSION['conferenceid']=0; + } + else { + $q=mysql_query("SELECT * FROM conferences WHERE id='$cid' AND status='running'"); + if($r=mysql_fetch_object($q)) { + $_SESSION['conferenceid']=$cid; + } + } +} + +if($_SESSION['conferenceid']) { + $q=mysql_query("SELECT * FROM conferences WHERE id='".$_SESSION['conferenceid']."'"); + $conference=mysql_fetch_assoc($q); +} +else { + $conference['id']=0; + $conference['name']=$config['fairname']; + $conference['type']="sciencefair"; +} + + + //now pull the rest of the configuration $q=mysql_query("SELECT * FROM config WHERE year='".$config['FAIRYEAR']."'"); while($r=mysql_fetch_object($q)) @@ -203,9 +233,12 @@ while($r=mysql_fetch_object($q)) } //now pull the dates -$q=mysql_query("SELECT * FROM dates WHERE year='".$config['FAIRYEAR']."'"); -while($r=mysql_fetch_object($q)) -{ +if($conference['id']) + $q=mysql_query("SELECT * FROM dates WHERE conferences_id='".$conference['id']."'"); +else + $q=mysql_query("SELECT * FROM dates WHERE year='".$config['FAIRYEAR']."'"); + +while($r=mysql_fetch_object($q)) { $config['dates'][$r->name]=$r->date; } @@ -251,32 +284,6 @@ if(!$_SESSION['lang']) { $_SESSION['lang']="en"; } -if(isset($_GET['switchconference'])) { - //make sure its good - $cid=intval($_GET['switchconference']); -// echo "cid=$cid"; - if($cid==0) { - //default for old science fair system - $_SESSION['conferenceid']=0; - } - else { - $q=mysql_query("SELECT * FROM conferences WHERE id='$cid' AND status='running'"); - if($r=mysql_fetch_object($q)) { - $_SESSION['conferenceid']=$cid; - } - } -} - -if($_SESSION['conferenceid']) { - $q=mysql_query("SELECT * FROM conferences WHERE id='".$_SESSION['conferenceid']."'"); - $conference=mysql_fetch_assoc($q); -} -else { - $conference['id']=0; - $conference['name']=$config['fairname']; - $conference['type']="sciencefair"; -} - //only allow debug to get set if we're using a development version (odd numbered ending) if(substr($config['version'], -1) % 2 != 0) if($_GET['debug']) $_SESSION['debug']=$_GET['debug'];