forked from science-ation/science-ation
Migrate all dates to use conferences ONLY, instead of dual conference/FAIRYEAR setup
This commit is contained in:
parent
24c80b1654
commit
4faa4b8dc4
@ -103,7 +103,7 @@ if(!mysql_select_db($DBNAME))
|
|||||||
@mysql_query("SET NAMES utf8");
|
@mysql_query("SET NAMES utf8");
|
||||||
|
|
||||||
//find out the fair year and any other 'year=0' configuration parameters (things that dont change as the years go on)
|
//find out the fair year and any other 'year=0' configuration parameters (things that dont change as the years go on)
|
||||||
$q=@mysql_query("SELECT * FROM config WHERE year='0'");
|
$q=@mysql_query("SELECT * FROM config WHERE conferences_id=0 OR year=0");
|
||||||
|
|
||||||
//we might get an error if installation step 2 is not done (ie, the config table doesnt even exist)
|
//we might get an error if installation step 2 is not done (ie, the config table doesnt even exist)
|
||||||
if(mysql_error())
|
if(mysql_error())
|
||||||
@ -242,7 +242,7 @@ if(intval($_SESSION['conferenceid'])>0) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//now pull the rest of the configuration
|
//now pull the rest of the configuration
|
||||||
$q=mysql_query("SELECT * FROM config WHERE year='".$config['FAIRYEAR']."'");
|
$q=mysql_query("SELECT * FROM config WHERE conferences_id='".$conference['id']."'");
|
||||||
while($r=mysql_fetch_object($q)) {
|
while($r=mysql_fetch_object($q)) {
|
||||||
$config[$r->var]=$r->val;
|
$config[$r->var]=$r->val;
|
||||||
}
|
}
|
||||||
@ -251,7 +251,7 @@ while($r=mysql_fetch_object($q)) {
|
|||||||
if($conference['id'])
|
if($conference['id'])
|
||||||
$q=mysql_query("SELECT * FROM dates WHERE conferences_id='".$conference['id']."'");
|
$q=mysql_query("SELECT * FROM dates WHERE conferences_id='".$conference['id']."'");
|
||||||
else
|
else
|
||||||
$q=mysql_query("SELECT * FROM dates WHERE year='".$config['FAIRYEAR']."'");
|
$config['dates']=array();
|
||||||
|
|
||||||
while($r=mysql_fetch_object($q)) {
|
while($r=mysql_fetch_object($q)) {
|
||||||
$config['dates'][$r->name]=$r->date;
|
$config['dates'][$r->name]=$r->date;
|
||||||
|
@ -31,7 +31,7 @@
|
|||||||
,"important_dates"
|
,"important_dates"
|
||||||
);
|
);
|
||||||
|
|
||||||
$q=mysql_query("SELECT * FROM dates WHERE year='-1'");
|
$q=mysql_query("SELECT * FROM dates WHERE conferences_id='-1'");
|
||||||
while($r=mysql_fetch_object($q)) {
|
while($r=mysql_fetch_object($q)) {
|
||||||
$defaultdates[$r->name]=$r;
|
$defaultdates[$r->name]=$r;
|
||||||
}
|
}
|
||||||
@ -87,12 +87,7 @@ $possibledates['scienceolympics'] = array('fairdate' => array() ,
|
|||||||
$dates=$possibledates[$conference['type']];
|
$dates=$possibledates[$conference['type']];
|
||||||
|
|
||||||
/* Now copy the SQL data into the above array */
|
/* Now copy the SQL data into the above array */
|
||||||
if($conference['id']>0) {
|
$q=mysql_query("SELECT * FROM dates WHERE conferences_id='".$conference['id']."' ORDER BY date");
|
||||||
$q=mysql_query("SELECT * FROM dates WHERE conferences_id='".$conference['id']."' ORDER BY date");
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
$q=mysql_query("SELECT * FROM dates WHERE year='".$config['FAIRYEAR']."' ORDER BY date");
|
|
||||||
}
|
|
||||||
while($r=mysql_fetch_object($q)) {
|
while($r=mysql_fetch_object($q)) {
|
||||||
//check if its a date we dont care about
|
//check if its a date we dont care about
|
||||||
if(!is_array($dates[$r->name]))
|
if(!is_array($dates[$r->name]))
|
||||||
@ -142,25 +137,14 @@ foreach($dates as $dn=>$d) {
|
|||||||
if(!$d['id']) {
|
if(!$d['id']) {
|
||||||
$def=$defaultdates[$dn];
|
$def=$defaultdates[$dn];
|
||||||
//hmm if we dont have a record for this date this year, INSERT the sql from the default
|
//hmm if we dont have a record for this date this year, INSERT the sql from the default
|
||||||
if($conference['id']>0) {
|
mysql_query("INSERT INTO dates (date,name,description,year,conferences_id) VALUES (
|
||||||
mysql_query("INSERT INTO dates (date,name,description,year,conferences_id) VALUES (
|
'".mysql_real_escape_string($def->date)."',
|
||||||
'".mysql_real_escape_string($def->date)."',
|
'".mysql_real_escape_string($dn)."',
|
||||||
'".mysql_real_escape_string($dn)."',
|
'".mysql_real_escape_string($def->description)."',
|
||||||
'".mysql_real_escape_string($def->description)."',
|
0,
|
||||||
0,
|
'".$conference['id']."'
|
||||||
'".$conference['id']."'
|
)");
|
||||||
)");
|
echo mysql_error();
|
||||||
echo mysql_error();
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
mysql_query("INSERT INTO dates (date,name,description,year,conferences_id) VALUES (
|
|
||||||
'".mysql_real_escape_string($def->date)."',
|
|
||||||
'".mysql_real_escape_string($dn)."',
|
|
||||||
'".mysql_real_escape_string($def->description)."',
|
|
||||||
'".$config['FAIRYEAR']."',
|
|
||||||
0
|
|
||||||
)");
|
|
||||||
}
|
|
||||||
$d['id']=mysql_insert_id();
|
$d['id']=mysql_insert_id();
|
||||||
$d['description']=$def->description;
|
$d['description']=$def->description;
|
||||||
$d['date']=$def->date;
|
$d['date']=$def->date;
|
||||||
|
@ -1 +1 @@
|
|||||||
190
|
191
|
||||||
|
16
db/db.update.191.php
Normal file
16
db/db.update.191.php
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
<?
|
||||||
|
function db_update_191_pre()
|
||||||
|
{
|
||||||
|
//before we do this, make sure we set the configuration variables based on the conferences.
|
||||||
|
$q=mysql_query("SELECT * FROM conferences WHERE type='sciencefair' AND year>0");
|
||||||
|
while($r=mysql_fetch_object($q)) {
|
||||||
|
echo " Updating dates for year={$r->year} to conferences_id={$r->id}\n";
|
||||||
|
mysql_query("UPDATE dates SET conferences_id='$r->id' WHERE year='$r->year'");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function db_update_191_post()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
1
db/db.update.191.sql
Normal file
1
db/db.update.191.sql
Normal file
@ -0,0 +1 @@
|
|||||||
|
UPDATE dates SET conferences_id=-1 WHERE year=-1;
|
Loading…
x
Reference in New Issue
Block a user