From f4d2d636d8f9080ef378ef1ae7423831c6211c4b Mon Sep 17 00:00:00 2001 From: james Date: Mon, 22 Feb 2010 20:26:23 +0000 Subject: [PATCH] By default, turn ON all eligibility in divs/cats for downloaded awards.. so fairs don't wonder why they can't assign any winners to these awards. In other words, make it "just work". :p --- admin/award_download.php | 9 +++++++++ common.inc.php | 19 +++++++++++++++++++ 2 files changed, 28 insertions(+) diff --git a/admin/award_download.php b/admin/award_download.php index f61a011..6161903 100644 --- a/admin/award_download.php +++ b/admin/award_download.php @@ -27,6 +27,7 @@ require_once('curl.inc.php'); + switch($_GET['action']) { case 'check': $fairs_id = intval($_GET['fairs_id']); @@ -88,6 +89,9 @@ case 'check': return; } + $divs = projectdivisions_load(); + $cats = projectcategories_load(); + foreach($awards as $award) { $identifier=$award['identifier']; $year=$award['year']; @@ -114,6 +118,11 @@ case 'check': '".mysql_escape_string($identifier)."', '$fairs_id')"); $award_id=mysql_insert_id(); + /* By default make all divs/cats eligible */ + foreach($divs as $id=>$d) + mysql_query("INSERT INTO award_awards_projectdivisions(award_awards_id,projectdivisions_id,year) VALUES ('$award_id','$id','{$config['FAIRYEAR']}')"); + foreach($cats as $id=>$c) + mysql_query("INSERT INTO award_awards_projectcategories(award_awards_id,projectcategories_id,year) VALUES ('$award_id','$id','{$config['FAIRYEAR']}')"); } else { echo i18n("Award already exists, updating info")."
"; $awardrecord=mysql_fetch_object($tq); diff --git a/common.inc.php b/common.inc.php index 9b2c5bb..d00a2f1 100644 --- a/common.inc.php +++ b/common.inc.php @@ -1325,5 +1325,24 @@ function getUserForSponsor($sponsor_id) { return user_load_by_uid($r->uid); } +function projectdivisions_load($year = false) +{ + global $config; + if($year == false) $year = $config['FAIRYEAR']; + $divs = array(); + $q = mysql_query("SELECT * FROM projectdivisions WHERE year='$year'"); + while(($d = mysql_fetch_assoc($q))) $divs[$d['id']] = $d; + return $divs; +} +function projectcategories_load($year = false) +{ + global $config; + if($year == false) $year = $config['FAIRYEAR']; + $cats = array(); + $q = mysql_query("SELECT * FROM projectcategories WHERE year='$year'"); + while(($c = mysql_fetch_assoc($q))) $cats[$c['id']] = $d; + return $cats; +} + ?>