forked from science-ation/science-ation
migrate categories/divisions/subdivisions from FAIRYEAR to conferences_id
rename API call /config to /config/variables update API with /config members for divisions/subdivisions/categories
This commit is contained in:
parent
d2afb6a94e
commit
4f42407073
49
api.php
49
api.php
@ -37,18 +37,47 @@ $request=explode("/",$_GET['request']);
|
|||||||
$ret=array();
|
$ret=array();
|
||||||
|
|
||||||
switch($request[0]) {
|
switch($request[0]) {
|
||||||
/* APIDOC: config
|
|
||||||
description(retreives the entire configuration variables, minus ones that cant be included (like passwords)
|
|
||||||
return(config array)
|
|
||||||
*/
|
|
||||||
case 'config':
|
case 'config':
|
||||||
$exclude=array("judge_registration_singlepassword","volunteer_registration_singlepassword","participant_registration_singlepassword","fairmanageremail");
|
switch($request[1]){
|
||||||
$configapi=$config;
|
/* APIDOC: config/variables
|
||||||
foreach($exclude AS $e) {
|
description(retreives the entire configuration variables, minus ones that cant be included (like passwords)
|
||||||
unset($configapi[$e]);
|
return(config array)
|
||||||
|
*/
|
||||||
|
case 'variables':
|
||||||
|
$exclude=array("judge_registration_singlepassword","volunteer_registration_singlepassword","participant_registration_singlepassword","fairmanageremail");
|
||||||
|
$configapi=$config;
|
||||||
|
foreach($exclude AS $e) {
|
||||||
|
unset($configapi[$e]);
|
||||||
|
}
|
||||||
|
$ret['status']="ok";
|
||||||
|
$ret['config']=$configapi;
|
||||||
|
break;
|
||||||
|
|
||||||
|
/* APIDOC: config/divisions
|
||||||
|
description(retreives the list of divisions)
|
||||||
|
return(divisions array)
|
||||||
|
*/
|
||||||
|
case 'divisions':
|
||||||
|
|
||||||
|
break;
|
||||||
|
|
||||||
|
/* APIDOC: config/subdivisions
|
||||||
|
description(retreives the list of subdivisions)
|
||||||
|
return(subdivisions array)
|
||||||
|
*/
|
||||||
|
case 'subdivisions':
|
||||||
|
|
||||||
|
break;
|
||||||
|
|
||||||
|
/* APIDOC: config/categories
|
||||||
|
description(retreives the list of age categories)
|
||||||
|
return(categories array)
|
||||||
|
*/
|
||||||
|
case 'categories':
|
||||||
|
|
||||||
|
break;
|
||||||
|
|
||||||
}
|
}
|
||||||
$ret['status']="ok";
|
|
||||||
$ret['config']=$configapi;
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'locations':
|
case 'locations':
|
||||||
|
@ -751,20 +751,29 @@ function getUserForSponsor($sponsor_id) {
|
|||||||
return user_load_by_uid($r->uid);
|
return user_load_by_uid($r->uid);
|
||||||
}
|
}
|
||||||
|
|
||||||
function projectdivisions_load($year = false) {
|
function projectdivisions_load($conferences_id = false) {
|
||||||
global $config;
|
global $conference;
|
||||||
if($year == false) $year = $config['FAIRYEAR'];
|
if($conferences_id == false) $conferences_id = $conference['id'];
|
||||||
$divs = array();
|
$divs = array();
|
||||||
$q = mysql_query("SELECT * FROM projectdivisions WHERE year='$year'");
|
$q = mysql_query("SELECT * FROM projectdivisions WHERE conferences_id='$conferences_id'");
|
||||||
while(($d = mysql_fetch_assoc($q))) $divs[$d['id']] = $d;
|
while(($d = mysql_fetch_assoc($q))) $divs[$d['id']] = $d;
|
||||||
return $divs;
|
return $divs;
|
||||||
}
|
}
|
||||||
|
|
||||||
function projectcategories_load($year = false) {
|
function projectsubdivisions_load($conferences_id = false) {
|
||||||
global $config;
|
global $conference;
|
||||||
if($year == false) $year = $config['FAIRYEAR'];
|
if($conferences_id == false) $conferences_id = $conference['id'];
|
||||||
|
$subdivs = array();
|
||||||
|
$q = mysql_query("SELECT * FROM projectsubdivisions WHERE conferences_id='$conferences_id'");
|
||||||
|
while(($d = mysql_fetch_assoc($q))) $subdivs[$d['id']] = $d;
|
||||||
|
return $subdivs;
|
||||||
|
}
|
||||||
|
|
||||||
|
function projectcategories_load($conferences_id = false) {
|
||||||
|
global $conference;
|
||||||
|
if($conferences_id == false) $conferences_id = $conference['id'];
|
||||||
$cats = array();
|
$cats = array();
|
||||||
$q = mysql_query("SELECT * FROM projectcategories WHERE year='$year'");
|
$q = mysql_query("SELECT * FROM projectcategories WHERE conferences_id='$conferences_id'");
|
||||||
while(($c = mysql_fetch_assoc($q))) $cats[$c['id']] = $d;
|
while(($c = mysql_fetch_assoc($q))) $cats[$c['id']] = $d;
|
||||||
return $cats;
|
return $cats;
|
||||||
}
|
}
|
||||||
|
@ -37,70 +37,59 @@
|
|||||||
'SFIAB Configuration' => 'config/index.php'),"project_age_categories");
|
'SFIAB Configuration' => 'config/index.php'),"project_age_categories");
|
||||||
}
|
}
|
||||||
|
|
||||||
if($_POST['action']=="edit")
|
if($_POST['action']=="edit") {
|
||||||
{
|
|
||||||
//ues isset($_POST['mingrade']) instead of just $_POST['mingrade'] to allow entering 0 for kindergarden
|
//ues isset($_POST['mingrade']) instead of just $_POST['mingrade'] to allow entering 0 for kindergarden
|
||||||
if($_POST['id'] && $_POST['category'] && isset($_POST['mingrade']) && $_POST['maxgrade'])
|
if($_POST['id'] && $_POST['category'] && isset($_POST['mingrade']) && $_POST['maxgrade']) {
|
||||||
{
|
$q=mysql_query("SELECT id FROM projectcategories WHERE id='".intval($_POST['id'])."' AND conferences_id='".$conference['id']."'");
|
||||||
$q=mysql_query("SELECT id FROM projectcategories WHERE id='".$_POST['id']."' AND year='".$config['FAIRYEAR']."'");
|
|
||||||
echo mysql_error();
|
echo mysql_error();
|
||||||
if(mysql_num_rows($q) && $_POST['saveid']!=$_POST['id'])
|
if(mysql_num_rows($q) && $_POST['saveid']!=$_POST['id']) {
|
||||||
{
|
|
||||||
echo error(i18n("Category ID %1 already exists",array($_POST['id']),array("category ID")));
|
echo error(i18n("Category ID %1 already exists",array($_POST['id']),array("category ID")));
|
||||||
}
|
}
|
||||||
else
|
else {
|
||||||
{
|
|
||||||
mysql_query("UPDATE projectcategories SET ".
|
mysql_query("UPDATE projectcategories SET ".
|
||||||
"id='".$_POST['id']."', ".
|
"id='".intval($_POST['id'])."', ".
|
||||||
"category='".mysql_escape_string(stripslashes($_POST['category']))."', ".
|
"category='".mysql_real_escape_string($_POST['category'])."', ".
|
||||||
"category_shortform='".mysql_escape_string(stripslashes($_POST['category_shortform']))."', ".
|
"category_shortform='".mysql_real_escape_string(($_POST['category_shortform'])."', ".
|
||||||
"mingrade='".$_POST['mingrade']."', ".
|
"mingrade='".intval($_POST['mingrade'])."', ".
|
||||||
"maxgrade='".$_POST['maxgrade']."' ".
|
"maxgrade='".intval($_POST['maxgrade'])."' ".
|
||||||
"WHERE id='".$_POST['saveid']."'");
|
"WHERE id='".intval($_POST['saveid'])."'");
|
||||||
echo happy(i18n("Category successfully saved"));
|
echo happy(i18n("Category successfully saved"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else {
|
||||||
{
|
|
||||||
echo error(i18n("All fields are required"));
|
echo error(i18n("All fields are required"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if($_POST['action']=="new")
|
if($_POST['action']=="new") {
|
||||||
{
|
|
||||||
//ues isset($_POST['mingrade']) instead of just $_POST['mingrade'] to allow entering 0 for kindergarden
|
//ues isset($_POST['mingrade']) instead of just $_POST['mingrade'] to allow entering 0 for kindergarden
|
||||||
if($_POST['id'] && $_POST['category'] && isset($_POST['mingrade']) && $_POST['maxgrade'])
|
if($_POST['id'] && $_POST['category'] && isset($_POST['mingrade']) && $_POST['maxgrade']) {
|
||||||
{
|
$q=mysql_query("SELECT id FROM projectcategories WHERE id='".intval($_POST['id'])."' AND conferences_id='".$conference['id']."'");
|
||||||
$q=mysql_query("SELECT id FROM projectcategories WHERE id='".$_POST['id']."' AND year='".$config['FAIRYEAR']."'");
|
if(mysql_num_rows($q)) {
|
||||||
if(mysql_num_rows($q))
|
|
||||||
{
|
|
||||||
echo error(i18n("Category ID %1 already exists",array($_POST['id']),array("category ID")));
|
echo error(i18n("Category ID %1 already exists",array($_POST['id']),array("category ID")));
|
||||||
}
|
}
|
||||||
else
|
else {
|
||||||
{
|
mysql_query("INSERT INTO projectcategories (id,category,category_shortform,mingrade,maxgrade,conferences_id) VALUES ( ".
|
||||||
mysql_query("INSERT INTO projectcategories (id,category,category_shortform,mingrade,maxgrade,year) VALUES ( ".
|
"'".intval($_POST['id']."', ".
|
||||||
"'".$_POST['id']."', ".
|
"'".mysql_real_escape_string($_POST['category'])."', ".
|
||||||
"'".mysql_escape_string(stripslashes($_POST['category']))."', ".
|
"'".mysql_real_escape_string($_POST['category_shortform'])."', ".
|
||||||
"'".mysql_escape_string(stripslashes($_POST['category_shortform']))."', ".
|
"'".intval($_POST['mingrade'])."', ".
|
||||||
"'".$_POST['mingrade']."', ".
|
"'".intval($_POST['maxgrade'])."', ".
|
||||||
"'".$_POST['maxgrade']."', ".
|
"'".$conference['id']."')");
|
||||||
"'".$config['FAIRYEAR']."')");
|
|
||||||
echo happy(i18n("Category successfully added"));
|
echo happy(i18n("Category successfully added"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else {
|
||||||
{
|
|
||||||
echo error(i18n("All fields are required"));
|
echo error(i18n("All fields are required"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if($_GET['action']=="remove" && $_GET['remove'])
|
if($_GET['action']=="remove" && $_GET['remove']) {
|
||||||
{
|
|
||||||
//###### Feature Specific - filtering divisions by category - not conditional, cause even if they have the filtering turned off..if any links
|
//###### Feature Specific - filtering divisions by category - not conditional, cause even if they have the filtering turned off..if any links
|
||||||
//for this division exist they should be deleted
|
//for this division exist they should be deleted
|
||||||
mysql_query("DELETE FROM projectcategoriesdivisions_link where projectcategories_id='".$_GET['remove']."' AND year='".$config['FAIRYEAR']."'");
|
mysql_query("DELETE FROM projectcategoriesdivisions_link where projectcategories_id='".intval($_GET['remove'])."' AND conferences_id='".$conference['id']."'");
|
||||||
//####
|
//####
|
||||||
mysql_query("DELETE FROM projectcategories WHERE id='".$_GET['remove']."' AND year='".$config['FAIRYEAR']."'");
|
mysql_query("DELETE FROM projectcategories WHERE id='".intval($_GET['remove'])."' AND conferences_id='".$conference['id']."'");
|
||||||
echo happy(i18n("Category successfully removed"));
|
echo happy(i18n("Category successfully removed"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -119,18 +108,15 @@
|
|||||||
echo "<th>".i18n("Actions")."</th>\n";
|
echo "<th>".i18n("Actions")."</th>\n";
|
||||||
echo "</tr>";
|
echo "</tr>";
|
||||||
|
|
||||||
if($_GET['action']=="edit" || $_GET['action']=="new")
|
if($_GET['action']=="edit" || $_GET['action']=="new") {
|
||||||
{
|
|
||||||
echo "<input type=\"hidden\" name=\"action\" value=\"".$_GET['action']."\">\n";
|
echo "<input type=\"hidden\" name=\"action\" value=\"".$_GET['action']."\">\n";
|
||||||
if($_GET['action']=="edit")
|
if($_GET['action']=="edit") {
|
||||||
{
|
|
||||||
echo "<input type=\"hidden\" name=\"saveid\" value=\"".$_GET['edit']."\">\n";
|
echo "<input type=\"hidden\" name=\"saveid\" value=\"".$_GET['edit']."\">\n";
|
||||||
$q=mysql_query("SELECT * FROM projectcategories WHERE id='".$_GET['edit']."' AND year='".$config['FAIRYEAR']."'");
|
$q=mysql_query("SELECT * FROM projectcategories WHERE id='".$_GET['edit']."' AND conferences_id='".$conference['id']."'");
|
||||||
$categoryr=mysql_fetch_object($q);
|
$categoryr=mysql_fetch_object($q);
|
||||||
$buttontext="Save";
|
$buttontext="Save";
|
||||||
}
|
}
|
||||||
else if($_GET['action']=="new")
|
else if($_GET['action']=="new") {
|
||||||
{
|
|
||||||
$buttontext="Add";
|
$buttontext="Add";
|
||||||
}
|
}
|
||||||
echo "<tr>";
|
echo "<tr>";
|
||||||
@ -142,11 +128,9 @@
|
|||||||
echo " <td><input type=\"submit\" value=\"".i18n($buttontext)."\"></td>";
|
echo " <td><input type=\"submit\" value=\"".i18n($buttontext)."\"></td>";
|
||||||
echo "</tr>";
|
echo "</tr>";
|
||||||
}
|
}
|
||||||
else
|
else {
|
||||||
{
|
$q=mysql_query("SELECT * FROM projectcategories WHERE conferences_id='".$conference['id']."' ORDER BY mingrade");
|
||||||
$q=mysql_query("SELECT * FROM projectcategories WHERE year='".$config['FAIRYEAR']."' ORDER BY mingrade");
|
while($r=mysql_fetch_object($q)) {
|
||||||
while($r=mysql_fetch_object($q))
|
|
||||||
{
|
|
||||||
echo "<tr>";
|
echo "<tr>";
|
||||||
echo " <td align=\"center\">$r->id</td>";
|
echo " <td align=\"center\">$r->id</td>";
|
||||||
echo " <td>".i18n($r->category)."</td>";
|
echo " <td>".i18n($r->category)."</td>";
|
||||||
|
@ -40,35 +40,29 @@ if($_GET['action']=="edit" || $_GET['action']=="new") {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if($_POST['action']=="edit")
|
if($_POST['action']=="edit") {
|
||||||
{
|
if($_POST['id'] && $_POST['division'] ) {
|
||||||
if($_POST['id'] && $_POST['division'] )
|
$q=mysql_query("SELECT id FROM projectdivisions WHERE id='".$_POST['id']."' AND conferences_id='".$conference['id']."'");
|
||||||
{
|
if(mysql_num_rows($q) && $_POST['saveid']!=$_POST['id']) {
|
||||||
$q=mysql_query("SELECT id FROM projectdivisions WHERE id='".$_POST['id']."' AND year='".$config['FAIRYEAR']."'");
|
|
||||||
if(mysql_num_rows($q) && $_POST['saveid']!=$_POST['id'])
|
|
||||||
{
|
|
||||||
echo error(i18n("Division ID %1 already exists",array($_POST['id']),array("division ID")));
|
echo error(i18n("Division ID %1 already exists",array($_POST['id']),array("division ID")));
|
||||||
}
|
}
|
||||||
else
|
else {
|
||||||
{
|
|
||||||
mysql_query("UPDATE projectdivisions SET ".
|
mysql_query("UPDATE projectdivisions SET ".
|
||||||
"id='".$_POST['id']."', ".
|
"id='".intval($_POST['id'])."', ".
|
||||||
"division='".mysql_escape_string(stripslashes($_POST['division']))."', ".
|
"division='".mysql_real_escape_string($_POST['division'])."', ".
|
||||||
"division_shortform='".mysql_escape_string(stripslashes($_POST['division_shortform']))."' ".
|
"division_shortform='".mysql_real_escape_string($_POST['division_shortform'])."' ".
|
||||||
"WHERE id='".$_POST['saveid']."' AND year='{$config['FAIRYEAR']}'");
|
"WHERE id='".intval($_POST['saveid'])."' AND conferences_id='{$conference['id']}'");
|
||||||
|
|
||||||
//###### Feature Specific - filtering divisions by category
|
//###### Feature Specific - filtering divisions by category
|
||||||
if($config['filterdivisionbycategory']=="yes"){
|
if($config['filterdivisionbycategory']=="yes"){
|
||||||
mysql_query("DELETE FROM projectcategoriesdivisions_link WHERE projectdivisions_id='".$_POST['saveid']."' AND year='".$config['FAIRYEAR']."'");
|
mysql_query("DELETE FROM projectcategoriesdivisions_link WHERE projectdivisions_id='".intval($_POST['saveid'])."' AND conferences_id='".$conference['id']."'");
|
||||||
|
|
||||||
if(is_array($_POST['divcat']))
|
if(is_array($_POST['divcat'])) {
|
||||||
{
|
foreach($_POST['divcat'] as $tempcat) {
|
||||||
foreach($_POST['divcat'] as $tempcat)
|
mysql_query("INSERT INTO projectcategoriesdivisions_link (projectdivisions_id,projectcategories_id,conferences_id) VALUES ( ".
|
||||||
{
|
|
||||||
mysql_query("INSERT INTO projectcategoriesdivisions_link (projectdivisions_id,projectcategories_id,year) VALUES ( ".
|
|
||||||
"'".$_POST['id']."', ".
|
"'".$_POST['id']."', ".
|
||||||
"'".$tempcat."', ".
|
"'".$tempcat."', ".
|
||||||
"'".$config['FAIRYEAR']."') ");
|
"'".$conference['id']."') ");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -77,54 +71,48 @@ if($_GET['action']=="edit" || $_GET['action']=="new") {
|
|||||||
echo happy(i18n("Division successfully saved"));
|
echo happy(i18n("Division successfully saved"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else {
|
||||||
{
|
|
||||||
echo error(i18n("All fields are required"));
|
echo error(i18n("All fields are required"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if($_POST['action']=="new")
|
if($_POST['action']=="new") {
|
||||||
{
|
|
||||||
if($_POST['id'] && $_POST['division'])
|
if($_POST['id'] && $_POST['division'])
|
||||||
{
|
{
|
||||||
$q=mysql_query("SELECT id FROM projectdivisions WHERE id='".$_POST['id']."' AND year='".$config['FAIRYEAR']."'");
|
$q=mysql_query("SELECT id FROM projectdivisions WHERE id='".$_POST['id']."' AND conferences_i='".$conference['id']."'");
|
||||||
if(mysql_num_rows($q))
|
if(mysql_num_rows($q)) {
|
||||||
{
|
|
||||||
echo error(i18n("Division ID %1 already exists",array($_POST['id']),array("division ID")));
|
echo error(i18n("Division ID %1 already exists",array($_POST['id']),array("division ID")));
|
||||||
}
|
}
|
||||||
else
|
else {
|
||||||
{
|
mysql_query("INSERT INTO projectdivisions (id,division,division_shortform,conferences_id) VALUES ( ".
|
||||||
mysql_query("INSERT INTO projectdivisions (id,division,division_shortform,year) VALUES ( ".
|
"'".intval($_POST['id'])."', ".
|
||||||
"'".$_POST['id']."', ".
|
"'".mysql_real_escape_string($_POST['division'])."', ".
|
||||||
"'".mysql_escape_string(stripslashes($_POST['division']))."', ".
|
"'".mysql_real_escape_string($_POST['division_shortform'])."', ".
|
||||||
"'".mysql_escape_string(stripslashes($_POST['division_shortform']))."', ".
|
"'".$conference['id']."') ");
|
||||||
"'".$config['FAIRYEAR']."') ");
|
|
||||||
|
|
||||||
|
|
||||||
//###### Feature Specific - filtering divisions by category
|
//###### Feature Specific - filtering divisions by category
|
||||||
if($config['filterdivisionbycategory']=="yes"){
|
if($config['filterdivisionbycategory']=="yes"){
|
||||||
foreach($_POST['divcat'] as $tempcat){
|
foreach($_POST['divcat'] as $tempcat){
|
||||||
mysql_query("INSERT INTO projectcategoriesdivisions_link (projectdivisions_id,projectcategories_id,year) VALUES ( ".
|
mysql_query("INSERT INTO projectcategoriesdivisions_link (projectdivisions_id,projectcategories_id,conferences_id) VALUES ( ".
|
||||||
"'".$tempcat."', ".
|
"'".intval($tempcat)."', ".
|
||||||
"'".$config['FAIRYEAR']."') ");
|
"'".$conference['id']."') ");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//#######
|
//#######
|
||||||
echo happy(i18n("Division successfully added"));
|
echo happy(i18n("Division successfully added"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else {
|
||||||
{
|
|
||||||
echo error(i18n("All fields are required"));
|
echo error(i18n("All fields are required"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if($_GET['action']=="remove" && $_GET['remove'])
|
if($_GET['action']=="remove" && $_GET['remove']) {
|
||||||
{
|
|
||||||
//###### Feature Specific - filtering divisions by category - not conditional, cause even if they have the filtering turned off..if any links
|
//###### Feature Specific - filtering divisions by category - not conditional, cause even if they have the filtering turned off..if any links
|
||||||
//for this division exist they should be deleted
|
//for this division exist they should be deleted
|
||||||
mysql_query("DELETE FROM projectcategoriesdivisions_link where projectdivisions_id='".$_GET['remove']."' AND year='".$config['FAIRYEAR']."'");
|
mysql_query("DELETE FROM projectcategoriesdivisions_link WHERE projectdivisions_id='".intval($_GET['remove'])."' AND conferences_id='".$conference['id']."'");
|
||||||
mysql_query("DELETE FROM projectdivisions WHERE id='".$_GET['remove']."' AND year='".$config['FAIRYEAR']."'");
|
mysql_query("DELETE FROM projectdivisions WHERE id='".intval($_GET['remove'])."' AND conferences_id='".$conference['id']."'");
|
||||||
echo happy(i18n("Division successfully removed"));
|
echo happy(i18n("Division successfully removed"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -145,18 +133,15 @@ if($_GET['action']=="edit" || $_GET['action']=="new") {
|
|||||||
echo "<th>".i18n("Actions")."</th>\n";
|
echo "<th>".i18n("Actions")."</th>\n";
|
||||||
echo "</tr>";
|
echo "</tr>";
|
||||||
|
|
||||||
if($_GET['action']=="edit" || $_GET['action']=="new")
|
if($_GET['action']=="edit" || $_GET['action']=="new") {
|
||||||
{
|
|
||||||
echo "<input type=\"hidden\" name=\"action\" value=\"".$_GET['action']."\">\n";
|
echo "<input type=\"hidden\" name=\"action\" value=\"".$_GET['action']."\">\n";
|
||||||
if($_GET['action']=="edit")
|
if($_GET['action']=="edit") {
|
||||||
{
|
|
||||||
echo "<input type=\"hidden\" name=\"saveid\" value=\"".$_GET['edit']."\">\n";
|
echo "<input type=\"hidden\" name=\"saveid\" value=\"".$_GET['edit']."\">\n";
|
||||||
$q=mysql_query("SELECT * FROM projectdivisions WHERE id='".$_GET['edit']."' AND year='".$config['FAIRYEAR']."'");
|
$q=mysql_query("SELECT * FROM projectdivisions WHERE id='".$_GET['edit']."' AND conferences_id='".$conference['id']."'");
|
||||||
$divisionr=mysql_fetch_object($q);
|
$divisionr=mysql_fetch_object($q);
|
||||||
$buttontext="Save";
|
$buttontext="Save";
|
||||||
}
|
}
|
||||||
else if($_GET['action']=="new")
|
else if($_GET['action']=="new") {
|
||||||
{
|
|
||||||
$buttontext="Add";
|
$buttontext="Add";
|
||||||
}
|
}
|
||||||
echo "<tr>";
|
echo "<tr>";
|
||||||
@ -167,9 +152,9 @@ if($_GET['action']=="edit" || $_GET['action']=="new") {
|
|||||||
//###### Feature Specific - filtering divisions by category
|
//###### Feature Specific - filtering divisions by category
|
||||||
if($config['filterdivisionbycategory']=="yes"){
|
if($config['filterdivisionbycategory']=="yes"){
|
||||||
echo " <td>";
|
echo " <td>";
|
||||||
$q=mysql_query("SELECT * FROM projectcategories WHERE year='".$config['FAIRYEAR']."' ORDER BY mingrade");
|
$q=mysql_query("SELECT * FROM projectcategories WHERE conferences_id='".$conference['id']."' ORDER BY mingrade");
|
||||||
while($categoryr=mysql_fetch_object($q)){
|
while($categoryr=mysql_fetch_object($q)){
|
||||||
$query="SELECT * FROM projectcategoriesdivisions_link WHERE projectdivisions_id=".$divisionr->id." AND projectcategories_id=".$categoryr->id." AND year='".$config['FAIRYEAR']."'";
|
$query="SELECT * FROM projectcategoriesdivisions_link WHERE projectdivisions_id=".$divisionr->id." AND projectcategories_id=".$categoryr->id." AND conferences_id='".$conference['id']."'";
|
||||||
$t=mysql_query($query);
|
$t=mysql_query($query);
|
||||||
if($t && mysql_num_rows($t)>0)
|
if($t && mysql_num_rows($t)>0)
|
||||||
echo "<nobr><input type=\"checkbox\" name=\"divcat[]\" value=\"$categoryr->id\" checked=\"checked\" /> $categoryr->category</nobr><br/>";
|
echo "<nobr><input type=\"checkbox\" name=\"divcat[]\" value=\"$categoryr->id\" checked=\"checked\" /> $categoryr->category</nobr><br/>";
|
||||||
@ -183,9 +168,8 @@ if($_GET['action']=="edit" || $_GET['action']=="new") {
|
|||||||
echo " <td><input type=\"submit\" value=\"".i18n($buttontext)."\" /></td>";
|
echo " <td><input type=\"submit\" value=\"".i18n($buttontext)."\" /></td>";
|
||||||
echo "</tr>";
|
echo "</tr>";
|
||||||
}
|
}
|
||||||
else
|
else {
|
||||||
{
|
$q=mysql_query("SELECT * FROM projectdivisions WHERE conferences_id='".$conference['id']."' ORDER BY id");
|
||||||
$q=mysql_query("SELECT * FROM projectdivisions WHERE year='".$config['FAIRYEAR']."' ORDER BY id");
|
|
||||||
while($r=mysql_fetch_object($q))
|
while($r=mysql_fetch_object($q))
|
||||||
{
|
{
|
||||||
echo "<tr>";
|
echo "<tr>";
|
||||||
@ -198,8 +182,8 @@ if($_GET['action']=="edit" || $_GET['action']=="new") {
|
|||||||
$c=mysql_query("SELECT category FROM projectcategoriesdivisions_link, projectcategories
|
$c=mysql_query("SELECT category FROM projectcategoriesdivisions_link, projectcategories
|
||||||
WHERE projectcategoriesdivisions_link.projectcategories_id = projectcategories.id
|
WHERE projectcategoriesdivisions_link.projectcategories_id = projectcategories.id
|
||||||
AND projectdivisions_id='$r->id'
|
AND projectdivisions_id='$r->id'
|
||||||
AND projectcategoriesdivisions_link.year='".$config['FAIRYEAR']."'
|
AND projectcategoriesdivisions_link.conferences_id='".$conference['id']."'
|
||||||
AND projectcategories.year='".$config['FAIRYEAR']."'
|
AND projectcategories.conferences_id='".$conference['id']."'
|
||||||
ORDER BY projectcategories.mingrade");
|
ORDER BY projectcategories.mingrade");
|
||||||
echo mysql_error();
|
echo mysql_error();
|
||||||
if(!$c){
|
if(!$c){
|
||||||
|
@ -38,69 +38,56 @@
|
|||||||
"project_sub_divisions");
|
"project_sub_divisions");
|
||||||
}
|
}
|
||||||
|
|
||||||
if($_POST['action']=="edit")
|
if($_POST['action']=="edit") {
|
||||||
{
|
if($_POST['id'] && $_POST['projectdivisions_id'] && $_POST['subdivision'] ) {
|
||||||
if($_POST['id'] && $_POST['projectdivisions_id'] && $_POST['subdivision'] )
|
$q=mysql_query("SELECT id FROM projectsubdivisions WHERE id='".intval($_POST['id'])."' AND conferences_id='".$conference['id']."'");
|
||||||
{
|
if(mysql_num_rows($q) && $_POST['saveid']!=$_POST['id']) {
|
||||||
$q=mysql_query("SELECT id FROM projectsubdivisions WHERE id='".$_POST['id']."' AND year='".$config['FAIRYEAR']."'");
|
|
||||||
if(mysql_num_rows($q) && $_POST['saveid']!=$_POST['id'])
|
|
||||||
{
|
|
||||||
echo error(i18n("Sub-Division ID %1 already exists",array($_POST['id'])));
|
echo error(i18n("Sub-Division ID %1 already exists",array($_POST['id'])));
|
||||||
}
|
}
|
||||||
else
|
else {
|
||||||
{
|
|
||||||
mysql_query("UPDATE projectsubdivisions SET ".
|
mysql_query("UPDATE projectsubdivisions SET ".
|
||||||
"id='".$_POST['id']."', ".
|
"id='".intval($_POST['id'])."', ".
|
||||||
"projectdivisions_id='".$_POST['projectdivisions_id']."', ".
|
"projectdivisions_id='".$_POST['projectdivisions_id']."', ".
|
||||||
"subdivision='".mysql_escape_string(stripslashes($_POST['subdivision']))."' ".
|
"subdivision='".mysql_real_escape_string($_POST['subdivision'])."' ".
|
||||||
"WHERE id='".$_POST['saveid']."'");
|
"WHERE id='".intval($_POST['saveid'])."'");
|
||||||
echo happy(i18n("Sub-Division successfully saved"));
|
echo happy(i18n("Sub-Division successfully saved"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else {
|
||||||
{
|
|
||||||
echo error(i18n("All fields are required"));
|
echo error(i18n("All fields are required"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if($_POST['action']=="new")
|
if($_POST['action']=="new") {
|
||||||
{
|
if($_POST['projectdivisions_id'] && $_POST['subdivision']) {
|
||||||
if($_POST['projectdivisions_id'] && $_POST['subdivision'])
|
if(!$_POST['id']) {
|
||||||
{
|
|
||||||
if(!$_POST['id'])
|
|
||||||
{
|
|
||||||
$idq=mysql_query("SELECT MAX(id) AS id FROM projectsubdivisions");
|
$idq=mysql_query("SELECT MAX(id) AS id FROM projectsubdivisions");
|
||||||
$idr=mysql_fetch_object($idq);
|
$idr=mysql_fetch_object($idq);
|
||||||
$newid=$idr->id+1;
|
$newid=$idr->id+1;
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
$newid=$_POST['id'];
|
$newid=$_POST['id'];
|
||||||
|
|
||||||
$q=mysql_query("SELECT id FROM projectsubdivisions WHERE id='$newid' AND year='".$config['FAIRYEAR']."'");
|
$q=mysql_query("SELECT id FROM projectsubdivisions WHERE id='$newid' AND conferences_id='".$conference['id']."'");
|
||||||
if(mysql_num_rows($q))
|
if(mysql_num_rows($q)) {
|
||||||
{
|
|
||||||
echo error(i18n("Sub-Division ID %1 already exists",array($newid)));
|
echo error(i18n("Sub-Division ID %1 already exists",array($newid)));
|
||||||
}
|
}
|
||||||
else
|
else {
|
||||||
{
|
mysql_query("INSERT INTO projectsubdivisions (id,projectdivisions_id,subdivision,conferences_id) VALUES ( ".
|
||||||
mysql_query("INSERT INTO projectsubdivisions (id,projectdivisions_id,subdivision,year) VALUES ( ".
|
|
||||||
"'$newid', ".
|
"'$newid', ".
|
||||||
"'".$_POST['projectdivisions_id']."', ".
|
"'".intval($_POST['projectdivisions_id'])."', ".
|
||||||
"'".mysql_escape_string(stripslashes($_POST['subdivision']))."', ".
|
"'".mysql_real_escape_string($_POST['subdivision'])."', ".
|
||||||
"'".$config['FAIRYEAR']."') ");
|
"'".$conference['id']."') ");
|
||||||
echo happy(i18n("Sub-Division successfully added"));
|
echo happy(i18n("Sub-Division successfully added"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else {
|
||||||
{
|
|
||||||
echo error(i18n("All fields except ID are required"));
|
echo error(i18n("All fields except ID are required"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if($_GET['action']=="remove" && $_GET['remove'])
|
if($_GET['action']=="remove" && $_GET['remove']) {
|
||||||
{
|
mysql_query("DELETE FROM projectsubdivisions WHERE id='".intval($_GET['remove'])."'");
|
||||||
mysql_query("DELETE FROM projectsubdivisions WHERE id='".$_GET['remove']."'");
|
|
||||||
echo happy(i18n("Sub-Division successfully removed"));
|
echo happy(i18n("Sub-Division successfully removed"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -117,26 +104,22 @@
|
|||||||
echo "<th>".i18n("Actions")."</th>\n";
|
echo "<th>".i18n("Actions")."</th>\n";
|
||||||
echo "</tr>";
|
echo "</tr>";
|
||||||
|
|
||||||
if($_GET['action']=="edit" || $_GET['action']=="new")
|
if($_GET['action']=="edit" || $_GET['action']=="new") {
|
||||||
{
|
|
||||||
echo "<input type=\"hidden\" name=\"action\" value=\"".$_GET['action']."\">\n";
|
echo "<input type=\"hidden\" name=\"action\" value=\"".$_GET['action']."\">\n";
|
||||||
if($_GET['action']=="edit")
|
if($_GET['action']=="edit") {
|
||||||
{
|
|
||||||
echo "<input type=\"hidden\" name=\"saveid\" value=\"".$_GET['edit']."\">\n";
|
echo "<input type=\"hidden\" name=\"saveid\" value=\"".$_GET['edit']."\">\n";
|
||||||
$q=mysql_query("SELECT * FROM projectsubdivisions WHERE id='".$_GET['edit']."' AND year='".$config['FAIRYEAR']."'");
|
$q=mysql_query("SELECT * FROM projectsubdivisions WHERE id='".$_GET['edit']."' AND conferences_id='".$conference['id']."'");
|
||||||
$divisionr=mysql_fetch_object($q);
|
$divisionr=mysql_fetch_object($q);
|
||||||
$buttontext="Save";
|
$buttontext="Save";
|
||||||
}
|
}
|
||||||
else if($_GET['action']=="new")
|
else if($_GET['action']=="new") {
|
||||||
{
|
|
||||||
$buttontext="Add";
|
$buttontext="Add";
|
||||||
}
|
}
|
||||||
echo "<tr>";
|
echo "<tr>";
|
||||||
echo " <td>";
|
echo " <td>";
|
||||||
echo "<select name=\"projectdivisions_id\">";
|
echo "<select name=\"projectdivisions_id\">";
|
||||||
$dq=mysql_query("SELECT * FROM projectdivisions WHERE year='".$config['FAIRYEAR']."' ORDER BY division");
|
$dq=mysql_query("SELECT * FROM projectdivisions WHERE conferences_id='".$conference['id']."' ORDER BY division");
|
||||||
while($dr=mysql_fetch_object($dq))
|
while($dr=mysql_fetch_object($dq)) {
|
||||||
{
|
|
||||||
if($dr->id==$divisionr->projectdivisions_id) $sel="selected=\"selected\""; else $sel="";
|
if($dr->id==$divisionr->projectdivisions_id) $sel="selected=\"selected\""; else $sel="";
|
||||||
echo "<option $sel value=\"$dr->id\">$dr->division</option>\n";
|
echo "<option $sel value=\"$dr->id\">$dr->division</option>\n";
|
||||||
}
|
}
|
||||||
@ -157,14 +140,13 @@
|
|||||||
projectsubdivisions,
|
projectsubdivisions,
|
||||||
projectdivisions
|
projectdivisions
|
||||||
WHERE
|
WHERE
|
||||||
projectsubdivisions.year='".$config['FAIRYEAR']."'
|
projectsubdivisions.conferences_id='".$conference['id']."'
|
||||||
AND projectdivisions.year='".$config['FAIRYEAR']."'
|
AND projectdivisions.conferences_id='".$conference['id']."'
|
||||||
AND projectsubdivisions.projectdivisions_id=projectdivisions.id
|
AND projectsubdivisions.projectdivisions_id=projectdivisions.id
|
||||||
ORDER BY
|
ORDER BY
|
||||||
division,subdivision");
|
division,subdivision");
|
||||||
echo mysql_error();
|
echo mysql_error();
|
||||||
while($r=mysql_fetch_object($q))
|
while($r=mysql_fetch_object($q)) {
|
||||||
{
|
|
||||||
echo "<tr>";
|
echo "<tr>";
|
||||||
echo " <td>$r->division</td>";
|
echo " <td>$r->division</td>";
|
||||||
echo " <td>$r->id</td>";
|
echo " <td>$r->id</td>";
|
||||||
|
21
db/db.update.209.php
Normal file
21
db/db.update.209.php
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
<?
|
||||||
|
function db_update_209_pre()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
function db_update_209_post()
|
||||||
|
{
|
||||||
|
// get the year => conference_id links
|
||||||
|
$q1 = mysql_query("SELECT year, id FROM conferences WHERE year>0");
|
||||||
|
$tables=array("projectdivisions","projectsubdivisions","projectcategories","projectcategoriesdivisions_link");
|
||||||
|
|
||||||
|
//update the tables
|
||||||
|
while($r = mysql_fetch_assoc($q1)){
|
||||||
|
foreach($tables as $tableName){
|
||||||
|
$query = "UPDATE `$tableName` SET `conferences_id` = {$r['id']} WHERE `year` = {$r['year']}";
|
||||||
|
mysql_query($query);
|
||||||
|
echo $query . ";\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
4
db/db.update.209.sql
Normal file
4
db/db.update.209.sql
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
ALTER TABLE `projectdivisions` ADD `conferences_id` INT NOT NULL;
|
||||||
|
ALTER TABLE `projectcategories` ADD `conferences_id` INT NOT NULL;
|
||||||
|
ALTER TABLE `projectsubdivisions` ADD `conferences_id` INT NOT NULL;
|
||||||
|
ALTER TABLE `projectcategoriesdivisions_link` ADD `conferences_id` INT NOT NULL;
|
Loading…
x
Reference in New Issue
Block a user