From 38638140b9866fba2c1c533ebb39a8e6678d5cce Mon Sep 17 00:00:00 2001 From: james Date: Mon, 20 Dec 2004 16:35:15 +0000 Subject: [PATCH] separate cat/div into categories and divisions fully implement the age categories configuration add "back to configuration" links to each sub-config --- config/catdiv.php | 10 ---- config/categories.php | 122 ++++++++++++++++++++++++++++++++++++++++++ config/divisions.php | 43 +++++++++++++++ config/index.php | 3 +- config/variables.php | 2 +- 5 files changed, 168 insertions(+), 12 deletions(-) delete mode 100644 config/catdiv.php create mode 100644 config/categories.php create mode 100644 config/divisions.php diff --git a/config/catdiv.php b/config/catdiv.php deleted file mode 100644 index 0e188e5..0000000 --- a/config/catdiv.php +++ /dev/null @@ -1,10 +0,0 @@ - diff --git a/config/categories.php b/config/categories.php new file mode 100644 index 0000000..18aed08 --- /dev/null +++ b/config/categories.php @@ -0,0 +1,122 @@ +<< ".i18n("Back to Configuration")."
"; + + if($_POST['action']=="edit") + { + if($_POST['id'] && $_POST['category'] && $_POST['mingrade'] && $_POST['maxgrade']) + { + $q=mysql_query("SELECT id FROM projectcategories WHERE id='".$_POST['id']."'"); + if(mysql_num_rows($q) && $_POST['saveid']!=$_POST['id']) + { + echo error(i18n("Category ID %1 already exists",array($_POST['id']))); + } + else + { + mysql_query("UPDATE projectcategories SET ". + "id='".$_POST['id']."', ". + "category='".mysql_escape_string(stripslashes($_POST['category']))."', ". + "mingrade='".$_POST['mingrade']."', ". + "maxgrade='".$_POST['maxgrade']."' ". + "WHERE id='".$_POST['saveid']."'"); + echo happy(i18n("Category successfully saved")); + } + } + else + { + echo error(i18n("All fields are required")); + } + } + + if($_POST['action']=="new") + { + if($_POST['id'] && $_POST['category'] && $_POST['mingrade'] && $_POST['maxgrade']) + { + $q=mysql_query("SELECT id FROM projectcategories WHERE id='".$_POST['id']."'"); + 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 ( ". + "'".$_POST['id']."', ". + "'".mysql_escape_string(stripslashes($_POST['category']))."', ". + "'".$_POST['mingrade']."', ". + "'".$_POST['maxgrade']."')"); + echo happy(i18n("Category successfully added")); + } + } + else + { + echo error(i18n("All fields are required")); + } + } + + if($_GET['action']=="remove" && $_GET['remove']) + { + mysql_query("DELETE FROM projectcategories WHERE id='".$_GET['remove']."'"); + echo happy(i18n("Category successfully removed")); + } + + echo "
"; + echo "

".i18n("Age Categories")."

"; + + if(! ($_GET['action']=="edit" || $_GET['action']=="new") ) + echo "".i18n("Add new age category")."\n"; + + echo ""; + echo ""; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo ""; + + if($_GET['action']=="edit" || $_GET['action']=="new") + { + echo "\n"; + if($_GET['action']=="edit") + { + echo "\n"; + $q=mysql_query("SELECT * FROM projectcategories WHERE id='".$_GET['edit']."'"); + $categoryr=mysql_fetch_object($q); + $buttontext="Save"; + } + else if($_GET['action']=="new") + { + $buttontext="Add"; + } + echo ""; + echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + echo ""; + } + else + { + $q=mysql_query("SELECT * FROM projectcategories ORDER BY mingrade"); + while($r=mysql_fetch_object($q)) + { + echo ""; + echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + echo ""; + } + } + echo "
".i18n("Category ID")."".i18n("Category Name")."".i18n("Minimum Grade")."".i18n("Maximum Grade")."".i18n("Actions")."
id\">category\">mingrade\">maxgrade\">
$r->id$r->category$r->mingrade$r->maxgrade"; + echo "id\">"; + echo "   "; + echo "id\">"; + echo "
"; + echo "
"; + + send_footer(); +?> diff --git a/config/divisions.php b/config/divisions.php new file mode 100644 index 0000000..820c981 --- /dev/null +++ b/config/divisions.php @@ -0,0 +1,43 @@ +<< ".i18n("Back to Configuration")."
"; + + if($_POST['action']=="save") + { + } + + echo "
"; + echo "

".i18n("Age Categories")."

"; + $q=mysql_query("SELECT * FROM projectcategories ORDER BY mingrade"); + echo ""; + echo ""; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo ""; + while($r=mysql_fetch_object($q)) + { + echo ""; + echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + echo ""; + } + echo "
".i18n("Category ID")."".i18n("Category Name")."".i18n("Minimum Grade")."".i18n("Maximum Grade")."".i18n("Actions")."
$r->id$r->category$r->mingrade$r->maxgrade"; + echo "id\">"; + echo "   "; + echo "id\">"; + echo "
"; + echo "
"; + + echo "

".i18n("Divisions")."

"; + $q=mysql_query("SELECT * FROM projectdivisions ORDER BY division"); + + + send_footer(); +?> diff --git a/config/index.php b/config/index.php index 03561f4..4307b57 100644 --- a/config/index.php +++ b/config/index.php @@ -4,7 +4,8 @@ echo error(i18n("Note: this section will normally be password protected. It is left open for now for debugging and testing purposes")); echo "Configuration Variables
"; - echo "Categories and Divisions
"; + echo "Project Age Categories
"; + echo "Project Divisons
"; send_footer(); ?> diff --git a/config/variables.php b/config/variables.php index c5fb62c..ceb1873 100644 --- a/config/variables.php +++ b/config/variables.php @@ -1,7 +1,7 @@ << ".i18n("Back to Configuration")."
"; if($_POST['action']=="save") {