diff --git a/config/categories.php b/config/categories.php index 18aed08..22f4480 100644 --- a/config/categories.php +++ b/config/categories.php @@ -7,7 +7,8 @@ { if($_POST['id'] && $_POST['category'] && $_POST['mingrade'] && $_POST['maxgrade']) { - $q=mysql_query("SELECT id FROM projectcategories WHERE id='".$_POST['id']."'"); + $q=mysql_query("SELECT id FROM projectcategories WHERE id='".$_POST['id']."' AND year='".$config['FAIRYEAR']."'"); + echo mysql_error(); if(mysql_num_rows($q) && $_POST['saveid']!=$_POST['id']) { echo error(i18n("Category ID %1 already exists",array($_POST['id']))); @@ -33,18 +34,19 @@ { if($_POST['id'] && $_POST['category'] && $_POST['mingrade'] && $_POST['maxgrade']) { - $q=mysql_query("SELECT id FROM projectcategories WHERE id='".$_POST['id']."'"); + $q=mysql_query("SELECT id FROM projectcategories WHERE id='".$_POST['id']."' AND year='".$config['FAIRYEAR']."'"); if(mysql_num_rows($q)) { echo error(i18n("Category ID %1 already exists",array($_POST['id']))); } else { - mysql_query("INSERT INTO projectcategories (id,category,mingrade,maxgrade) VALUES ( ". + mysql_query("INSERT INTO projectcategories (id,category,mingrade,maxgrade,year) VALUES ( ". "'".$_POST['id']."', ". "'".mysql_escape_string(stripslashes($_POST['category']))."', ". "'".$_POST['mingrade']."', ". - "'".$_POST['maxgrade']."')"); + "'".$_POST['maxgrade']."', ". + "'".$config['FAIRYEAR']."')"); echo happy(i18n("Category successfully added")); } } @@ -81,7 +83,7 @@ if($_GET['action']=="edit") { echo "\n"; - $q=mysql_query("SELECT * FROM projectcategories WHERE id='".$_GET['edit']."'"); + $q=mysql_query("SELECT * FROM projectcategories WHERE id='".$_GET['edit']."' AND year='".$config['FAIRYEAR']."'"); $categoryr=mysql_fetch_object($q); $buttontext="Save"; } @@ -99,7 +101,7 @@ } else { - $q=mysql_query("SELECT * FROM projectcategories ORDER BY mingrade"); + $q=mysql_query("SELECT * FROM projectcategories WHERE year='".$config['FAIRYEAR']."' ORDER BY mingrade"); while($r=mysql_fetch_object($q)) { echo ""; diff --git a/config/divisions.php b/config/divisions.php index 820c981..2a9a435 100644 --- a/config/divisions.php +++ b/config/divisions.php @@ -1,43 +1,113 @@ << ".i18n("Back to Configuration")."
"; - if($_POST['action']=="save") + if($_POST['action']=="edit") { + if($_POST['id'] && $_POST['division'] ) + { + $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']))); + } + else + { + mysql_query("UPDATE projectdivisions SET ". + "id='".$_POST['id']."', ". + "division='".mysql_escape_string(stripslashes($_POST['division']))."' ". + "WHERE id='".$_POST['saveid']."'"); + echo happy(i18n("Division successfully saved")); + } + } + else + { + echo error(i18n("All fields are required")); + } + } + + if($_POST['action']=="new") + { + if($_POST['id'] && $_POST['division']) + { + $q=mysql_query("SELECT id FROM projectdivisions WHERE id='".$_POST['id']."' AND year='".$config['FAIRYEAR']."'"); + if(mysql_num_rows($q)) + { + echo error(i18n("Division ID %1 already exists",array($_POST['id']))); + } + else + { + mysql_query("INSERT INTO projectdivisions (id,division,year) VALUES ( ". + "'".$_POST['id']."', ". + "'".mysql_escape_string(stripslashes($_POST['division']))."', ". + "'".$config['FAIRYEAR']."') "); + echo happy(i18n("Division successfully added")); + } + } + else + { + echo error(i18n("All fields are required")); + } + } + + if($_GET['action']=="remove" && $_GET['remove']) + { + mysql_query("DELETE FROM projectdivisions WHERE id='".$_GET['remove']."'"); + echo happy(i18n("Division successfully removed")); } echo "
"; - echo "

".i18n("Age Categories")."

"; - $q=mysql_query("SELECT * FROM projectcategories ORDER BY mingrade"); + echo "

".i18n("Divisions")."

"; + + if(! ($_GET['action']=="edit" || $_GET['action']=="new") ) + echo "".i18n("Add new division")."\n"; + echo ""; echo ""; - echo "\n"; - echo "\n"; - echo "\n"; - echo "\n"; + echo "\n"; + echo "\n"; echo "\n"; echo ""; - while($r=mysql_fetch_object($q)) + + if($_GET['action']=="edit" || $_GET['action']=="new") { - echo ""; - echo " "; - echo " "; - echo " "; - echo " "; - echo " "; + echo "\n"; + if($_GET['action']=="edit") + { + echo "\n"; + $q=mysql_query("SELECT * FROM projectdivisions WHERE id='".$_GET['edit']."' AND year='".$config['FAIRYEAR']."'"); + $divisionr=mysql_fetch_object($q); + $buttontext="Save"; + } + else if($_GET['action']=="new") + { + $buttontext="Add"; + } + echo ""; + echo " "; + echo " "; + echo " "; echo ""; } + else + { + $q=mysql_query("SELECT * FROM projectdivisions WHERE year='".$config['FAIRYEAR']."' ORDER BY division"); + while($r=mysql_fetch_object($q)) + { + echo ""; + echo " "; + echo " "; + echo " "; + echo ""; + } + } echo "
".i18n("Category ID")."".i18n("Category Name")."".i18n("Minimum Grade")."".i18n("Maximum Grade")."".i18n("Division ID")."".i18n("Division Name")."".i18n("Actions")."
$r->id$r->category$r->mingrade$r->maxgrade"; - echo "id\">"; - echo "   "; - echo "id\">"; - echo "
id\">division\">
$r->id$r->division"; + echo "id\">"; + echo "   "; + echo "id\">"; + echo "
"; echo "
"; - echo "

".i18n("Divisions")."

"; - $q=mysql_query("SELECT * FROM projectdivisions ORDER BY division"); - - send_footer(); ?>