From cf05b063c18274c6857c5414e6256fb21656e2be Mon Sep 17 00:00:00 2001 From: james Date: Fri, 4 Jun 2010 17:09:35 +0000 Subject: [PATCH] A few more tweaks to the date config - if we have a conference year should be 0, if we dont have a conference, conference should be 0 and year should be set. --- config/dates.php | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/config/dates.php b/config/dates.php index c5fec3e..818527a 100644 --- a/config/dates.php +++ b/config/dates.php @@ -54,7 +54,7 @@ $error_ids = array(); $d = mysql_escape_string(stripslashes($val)); $t =mysql_escape_string(stripslashes($_POST['savetimes'][$key])); $v="$d $t"; - mysql_query("UPDATE dates SET date='$v' WHERE year='".$config['FAIRYEAR']."' AND conferences_id='".$conference['id']."' AND id='$key'"); + mysql_query("UPDATE dates SET date='$v' WHERE id='$key'"); } } echo happy(i18n("Dates successfully saved")); @@ -142,13 +142,25 @@ foreach($dates as $dn=>$d) { if(!$d['id']) { $def=$defaultdates[$dn]; //hmm if we dont have a record for this date this year, INSERT the sql from the default - 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']."', - '".$conference['id']."' - )"); + if($conference['id']>0) { + 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)."', + 0, + '".$conference['id']."' + )"); + 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['description']=$def->description; $d['date']=$def->date;