From 2179f3f709e02ae073884c224fa126b6fe564486 Mon Sep 17 00:00:00 2001 From: james Date: Thu, 8 Dec 2005 14:56:30 +0000 Subject: [PATCH] Add safety question configuration --- config/index.php | 2 +- config/safetyquestions.php | 151 +++++++++++++++++++++++++++++++++++++ 2 files changed, 152 insertions(+), 1 deletion(-) create mode 100644 config/safetyquestions.php diff --git a/config/index.php b/config/index.php index caaef9c..b282fd3 100644 --- a/config/index.php +++ b/config/index.php @@ -32,8 +32,8 @@ echo "Project Age Categories
"; echo "Project Divisons
"; echo "Project Sub-Divisons
"; - echo "Page Texts
"; + echo "Project Safety Questions
"; echo "Images (Fair Logo)
"; echo "
"; echo "Rollover Fair Year
"; diff --git a/config/safetyquestions.php b/config/safetyquestions.php new file mode 100644 index 0000000..7181034 --- /dev/null +++ b/config/safetyquestions.php @@ -0,0 +1,151 @@ + + Copyright (C) 2005 James Grant + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public + License as published by the Free Software Foundation, version 2. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; see the file COPYING. If not, write to + the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. +*/ +?> +<< ".i18n("Back to Configuration")."
"; + + if($_POST['action']=="save" && $_POST['save']) + { + mysql_query("UPDATE safetyquestions SET + question='".mysql_escape_string(stripslashes($_POST['question']))."', + `type`='".mysql_escape_string(stripslashes($_POST['type']))."', + `required`='".mysql_escape_string(stripslashes($_POST['required']))."', + ord='".mysql_escape_string(stripslashes($_POST['ord']))."' + WHERE id='".$_POST['save']."' AND year='".$config['FAIRYEAR']."'"); + echo mysql_error(); + + echo happy(i18n("Safety question successfully saved")); + + } + if($_POST['action']=="new") + { + mysql_query("INSERT INTO safetyquestions (question,type,required,ord,year) VALUES ( + '".mysql_escape_string(stripslashes($_POST['question']))."', + '".mysql_escape_string(stripslashes($_POST['type']))."', + '".mysql_escape_string(stripslashes($_POST['required']))."', + '".mysql_escape_string(stripslashes($_POST['ord']))."', + '".$config['FAIRYEAR']."' + )"); + echo mysql_error(); + + echo happy(i18n("Safety question successfully added")); + + + } + + if($_GET['action']=="remove" && $_GET['remove']) + { + mysql_query("DELETE FROM safetyquestions WHERE id='".$_GET['remove']."' AND year='".$config['FAIRYEAR']."'"); + echo happy(i18n("Safety question successfully removed")); + + } + + if(($_GET['action']=="edit" && $_GET['edit']) || $_GET['action']=="new") + { + $showform=true; + echo "
"; + if($_GET['action']=="new") + { + $buttontext="Add safety question"; + echo "\n"; + $r=null; + } + else if($_GET['action']=="edit") + { + $buttontext="Save safety question"; + echo "\n"; + echo "id\">\n"; + $q=mysql_query("SELECT * FROM safetyquestions WHERE id='".$_GET['edit']."' AND year='".$config['FAIRYEAR']."'"); + if(!$r=mysql_fetch_object($q)) + { + $showform=false; + echo error(i18n("Invalid safety question")); + } + + + } + if($showform) + { + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo "
".i18n("Question").""; + echo "question)."\">\n"; + echo "
".i18n("Type").""; + echo ""; + echo "
".i18n("Required?").""; + echo ""; + echo "
".i18n("Display Order").""; + echo "ord)."\">\n"; + echo "
"; + echo "\n"; + echo "
"; + echo "
"; + echo "
"; + echo "
"; + } + else + { + } + } + echo "
"; + echo "Add new safety question"; + + echo ""; + $q=mysql_query("SELECT * FROM safetyquestions WHERE year='".$config['FAIRYEAR']."' ORDER BY ord"); + echo ""; + while($r=mysql_fetch_object($q)) + { + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + + + } + echo "
".i18n("Question")."".i18n("Type")."".i18n("Required")."".i18n("Actions")."
$r->question$r->type$r->required"; + echo "id\">"; + echo "   "; + echo "id\">"; + + echo "
"; + + send_footer(); +?>