Commit all work from the weekend:

- judges registration
 - small changes to participant registraiton
This commit is contained in:
james 2004-12-19 23:16:46 +00:00
parent dbdb15273f
commit 1b393c1bb0
8 changed files with 535 additions and 28 deletions

3
TODO
View File

@ -1 +1,2 @@
- Make auto-logout on email address change work properly on the FIRST submit, not after the submit - Make auto-logout on email address change work properly on the FIRST submit, not on first action after the submit
- same for judges changing email address

View File

@ -288,6 +288,34 @@ function emit_year_selector($name,$selected="",$min=0,$max=0)
function outputStatus($status)
{
$ret="";
switch($status)
{
case 'incomplete':
$ret.="<div class=\"incomplete\">";
$ret.= i18n("Incomplete");
$ret.= "</div>";
break;
case 'complete':
$ret.= "<div class=\"complete\">";
$ret.= i18n("Complete");
$ret.= "</div>";
break;
case 'empty':
$ret.="<div class=\"incomplete\">";
$ret.= i18n("Empty");
$ret.= "</div>";
break;
default:
$ret.=i18n("Unknown");
break;
}
return $ret;
}
?> ?>

48
register_judges.inc.php Normal file
View File

@ -0,0 +1,48 @@
<?
function personalStatus()
{
global $config;
$required_fields=array("firstname","lastname","address","city","postalcode","phone","email","dateofbirth");
$q=mysql_query("SELECT * FROM judges WHERE id='".$_SESSION['judges_id']."'");
while($r=mysql_fetch_object($q))
{
foreach ($required_fields AS $req)
{
if(!$r->$req)
{
return "incomplete";
}
}
}
//if it made it through without returning incomplete, then we must be complete
return "complete";
}
function expertiseStatus()
{
global $config;
//easiest check here is to check the number of divisions, then check the number of entries
//that they have in the judges_expertise table. If they are the same, then we're good to go
//if they are different, they forgot to fill one out (because it only gets inserted if a value)
//is choosen, and they are always ALL removed before each update
$q=mysql_query("SELECT COUNT(id) AS num FROM projectdivisions WHERE year='".$config['FAIRYEAR']."'");
$r=mysql_fetch_object($q);
$numdivisions=$r->num;
$q=mysql_query("SELECT COUNT(id) AS num FROM judges_expertise WHERE judges_id='".$_SESSION['judges_id']."' AND year='".$config['FAIRYEAR']."'");
$r=mysql_fetch_object($q);
$numjudgesexpertise=$r->num;
if($numdivisions == $numjudgesexpertise)
return "complete";
else
return "incomplete";
}
?>

View File

@ -1,7 +1,137 @@
<? <?
require("common.inc.php"); require("common.inc.php");
if($_POST['action']=="new")
{
//first make sure their password is good
if(!$_POST['pass1'])
{
send_header("Judges Registration");
echo error(i18n("Password is required"));
$_POST['action']="login";
}
else if($_POST['pass1'] != $_POST['pass2'])
{
send_header("Judges Registration");
echo error(i18n("Passwords do not match"));
$_POST['action']="login";
}
else
{
mysql_query("INSERT INTO judges (email,password) VALUES ('".$_SESSION['email']."','".$_POST['pass1']."')");
$id=mysql_insert_id();
$_SESSION['judges_id']=$id;
//obviously if they are signing up right now they would like to particapte in the current years fair, so setup the year for them
mysql_query("INSERT INTO judges_years (judges_id,year) VALUES ('$id','".$config['FAIRYEAR']."')");
//now redirect to jduges main
header("Location: register_judges_main.php");
}
}
else if($_POST['action']=="continue")
{
if($_POST['pass'])
{
$q=mysql_query("SELECT * FROM judges WHERE email='".$_SESSION['email']."' AND password='".$_POST['pass']."'");
if(mysql_num_rows($q)==1)
{
$r=mysql_fetch_object($q);
$_SESSION['judges_id']=$r->id;
header("Location: register_judges_main.php");
}
else
{
send_header("Judges Registration");
echo error(i18n("Invalid Password"));
$_POST['action']="login";
}
}
else
{
send_header("Judges Registration");
echo error(i18n("Password missing"));
$_POST['action']="login";
}
}
else if($_GET['action']=="logout")
{
unset($_SESSION['email']);
unset($_SESSION['judges_id']);
send_header("Judges Registration");
echo notice(i18n("You have been successfully logged out"));
}
send_header("Judges Registration"); send_header("Judges Registration");
if($_POST['action']=="login" && ( $_POST['email'] || $_SESSION['email']) )
{
if($_POST['email'])
$_SESSION['email']=$_POST['email'];
echo "<form method=\"post\" action=\"register_judges.php\">";
$allownew=true;
//first, check if they have any registrations waiting to be opened
$q=mysql_query("SELECT * FROM judges WHERE email='".$_SESSION['email']."'");
if(mysql_num_rows($q)>0)
{
echo i18n("Please enter your password to login");
echo "<br />";
echo "<br />";
echo i18n("Password:")." ";
echo "<input type=\"password\" size=\"10\" name=\"pass\">";
echo "<input type=\"hidden\" name=\"action\" value=\"continue\">";
echo "<input type=\"submit\" value=\"".i18n("Login")."\">";
echo "<br />";
echo "<br />";
echo i18n("If you have lost or forgotten your <b>password</b>, pleaes <a href=\"register_judges.php?action=resend\">click here to resend</a> it to your email address");
}
else
{
echo i18n("Please choose a password in order to create your judges account");
echo "<br />";
echo "<br />";
echo "<input type=\"hidden\" name=\"action\" value=\"new\">";
echo "<table>";
echo "<tr><td>";
echo i18n("Enter Password:");
echo "</td><td>";
echo "<input type=\"password\" size=\"10\" name=\"pass1\">";
echo "</td></tr>";
echo "<tr><td>";
echo i18n("Confirm Password:");
echo "</td><td>";
echo "<input type=\"password\" size=\"10\" name=\"pass2\">";
echo "</td></tr>";
echo "</table>";
echo "<br />";
echo "<input type=\"submit\" value=\"".i18n("Create Account")."\">";
}
echo "</form>";
}
else
{
echo i18n("Please enter your email address to :");
echo "<ul>";
echo "<li>".i18n("Begin a new registration")."</li>";
echo "<li>".i18n("Login to your account")."</li>";
echo "</ul>";
?>
<form method="post" action="register_judges.php">
<input type="hidden" name="action" value="login" />
<?=i18n("Email")?>: <input type="text" name="email" size="30" />
<input type="submit" value="Begin" />
</form>
<?
}
send_footer(); send_footer();
?> ?>

View File

@ -0,0 +1,90 @@
<?
require("common.inc.php");
include "register_judges.inc.php";
//authenticate based on email address and registration number from the SESSION
if(! ($_SESSION['email'] && $_SESSION['judges_id']) )
{
header("Location: register_judges.php");
exit;
}
$q=mysql_query("SELECT id FROM judges WHERE email='".$_SESSION['email']."' AND id='".$_SESSION['judges_id']."'");
echo mysql_error();
if(mysql_num_rows($q)==0)
{
header("Location: register_judges.php?action=logout");
exit;
}
//send the header
send_header("Judges Registration - Areas of Expertise Information");
echo "<a href=\"register_judges_main.php\">&lt;&lt; ".i18n("Back to Judges Registration Summary")."</a><br />";
echo "<br />";
if($_POST['action']=="save")
{
//first delete all their old associations for this year..
mysql_query("DELETE FROM judges_expertise WHERE judges_id='".$_SESSION['judges_id']."' AND year='".$config['FAIRYEAR']."'");
foreach($_POST['division'] AS $key=>$val)
{
mysql_query("INSERT INTO judges_expertise (judges_id, projectdivisions_id, val, year) VALUES ('".$_SESSION['judges_id']."','$key','$val','".$config['FAIRYEAR']."')");
}
echo notice(i18n("Areas of Expertise successfully saved"));
}
$q=mysql_query("SELECT * FROM judges WHERE email='".$_SESSION['email']."' AND id='".$_SESSION['judges_id']."'");
$judgeinfo=mysql_fetch_object($q);
//output the current status
$newstatus=expertiseStatus();
if($newstatus!="complete")
{
echo error(i18n("Areas of Expertise Information Incomplete"));
}
else
{
echo happy(i18n("Areas of Expertise Information Complete"));
}
echo "<form name=\"expertiseform\" method=\"post\" action=\"register_judges_expertise.php\">\n";
echo "<input type=\"hidden\" name=\"action\" value=\"save\">\n";
echo i18n("Please rank the following divisions according to the amount of knowledge you have of each subject. A '1' indicates very little knowledge, and a '5' indicates you are very knowledgeable of the subject");
echo "<br />";
echo "<br />";
$q=mysql_query("SELECT * FROM judges_expertise WHERE judges_id='".$_SESSION['judges_id']."' AND year='".$config['FAIRYEAR']."'");
while($r=mysql_fetch_object($q))
{
$expertise[$r->projectdivisions_id]=$r->val;
}
echo "<table>\n";
echo "<tr><th>Division</th>";
for($x=1;$x<=5;$x++)
echo "<th>$x</th>";
echo "</tr>";
//query all of the categories
$q=mysql_query("SELECT * FROM projectdivisions WHERE year='".$config['FAIRYEAR']."' ORDER BY division");
while($r=mysql_fetch_object($q))
{
echo "<tr><td>".i18n($r->division)."</td>";
for($x=1;$x<=5;$x++)
{
if($expertise[$r->id]==$x) $sel="checked=\"checked\""; else $sel="";
echo "<td><input $sel type=\"radio\" name=\"division[$r->id]\" value=\"$x\" /></td>";
}
echo "</tr>";
}
echo "</table>";
echo "<br />";
echo "<input type=\"submit\" value=\"".i18n("Save Areas of Expertise Information")."\" />\n";
echo "</form>";
send_footer();
?>

124
register_judges_main.php Normal file
View File

@ -0,0 +1,124 @@
<?
require("common.inc.php");
include "register_judges.inc.php";
//authenticate based on email address and registration number from the SESSION
if(! ($_SESSION['email'] && $_SESSION['judges_id']) )
{
header("Location: register_judges.php");
exit;
}
$q=mysql_query("SELECT * FROM judges WHERE email='".$_SESSION['email']."' AND id='".$_SESSION['judges_id']."'");
echo mysql_error();
if(mysql_num_rows($q)==0)
{
header("Location: register_judges.php?action=logout");
exit;
}
$judgeinfo=mysql_fetch_object($q);
send_header("Judges Registration");
if($_GET['action']=="activate")
{
mysql_query("INSERT INTO judges_years (judges_id,year) VALUES ('".$_SESSION['judges_id']."','".$config['FAIRYEAR']."')");
echo happy(i18n("Judge profile for %1 successfully activated",array($config['FAIRYEAR'])));
}
if($_GET['action']=="deactivate")
{
mysql_query("DELETE FROM judges_years WHERE judges_id='".$_SESSION['judges_id']."' AND year='".$config['FAIRYEAR']."'");
echo happy(i18n("Judge profile for %1 successfully deactivated",array($config['FAIRYEAR'])));
}
//only display the named greeting if we have their name
if($judgeinfo->firstname)
{
echo i18n("Hello <b>%1</b>",array($judgeinfo->firstname));
echo "<br />";
}
echo "<br />";
//first, we need to see if they havec the current FAIRYEAR activated, if not, we'll keep their acocunt 'dormant' and it wont
//be used for anything, but will still be available for them to login in the following years.
$q=mysql_query("SELECT * FROM judges_years WHERE judges_id='".$_SESSION['judges_id']."' AND year='".$config['FAIRYEAR']."'");
if(!mysql_num_rows($q))
{
echo i18n("If you would like to participate as a judge in the %1 %2 please click the activate button below to activate your judges account for the fair",array($config['FAIRYEAR'],$config['fairname']));
echo "<br />";
echo "<br />";
echo "<form method=\"get\" action=\"".$_SERVER['PHP_SELF']."\">";
echo "<input type=\"hidden\" name=\"action\" value=\"activate\">\n";
echo "<input type=\"submit\" value=\"".i18n("Activate %1 Judge Profile",array($config['FAIRYEAR']))."\">";
echo "</form>";
}
else
{
echo i18n("Please use the checklist below to complete your registration. Click on an item in the table to edit that information. When you have entered all information, the <b>Status</b> field will change to <b>Complete</b>");
echo "<br />";
echo "<br />";
echo "<table class=\"summarytable\">";
echo "<tr><th>".i18n("Registration Item")."</th><th>".i18n("Status")."</th></tr>";
//judges personal information
echo "<tr><td>";
echo "<a href=\"register_judges_personal.php\">";
echo i18n("Personal Information");
echo "</a>";
echo "</td><td>";
//check to see if its complete
$statuspersonal=personalStatus();
echo outputStatus($statuspersonal);
echo "</td></tr>";
/*
//organization information
echo "<tr><td>";
echo "<a href=\"register_judges_organization.php\">";
echo i18n("Organization Information");
echo "</a>";
echo "</td><td>";
//check to see if its complete
$statusorganization=organizationStatus();
echo outputStatus($statusorganization);
echo "</td></tr>";
*/
//area of expertise
echo "<tr><td>";
echo "<a href=\"register_judges_expertise.php\">";
echo i18n("Areas of Expertise");
echo "</a>";
echo "</td><td>";
//check to see if its complete
$statusexpertise=expertiseStatus();
echo outputStatus($statusexpertise);
echo "</td></tr>";
echo "</table>";
echo "<br />";
echo "<br />";
echo i18n("If you are unable to participate as a judge in the %1 %2 please click the deactivate button below to deactivate your judges account for the fair",array($config['FAIRYEAR'],$config['fairname']));
echo "<br />";
echo "<br />";
echo "<form method=\"get\" action=\"".$_SERVER['PHP_SELF']."\">";
echo "<input type=\"hidden\" name=\"action\" value=\"deactivate\">\n";
echo "<input onclick=\"return confirmClick('".i18n("Are you sure you want to deactivate your judges profile for %1?",array($config['FAIRYEAR']))."')\" type=\"submit\" value=\"".i18n("Deactivate %1 Judge Profile",array($config['FAIRYEAR']))."\">";
echo "</form>";
}
echo "<br />";
echo "<a href=\"register_judges.php?action=logout\">".i18n("Logout")."</a>";
send_footer();
?>

View File

@ -0,0 +1,113 @@
<?
require("common.inc.php");
include "register_judges.inc.php";
//authenticate based on email address and registration number from the SESSION
if(! ($_SESSION['email'] && $_SESSION['judges_id']) )
{
header("Location: register_judges.php");
exit;
}
$q=mysql_query("SELECT id FROM judges WHERE email='".$_SESSION['email']."' AND id='".$_SESSION['judges_id']."'");
echo mysql_error();
if(mysql_num_rows($q)==0)
{
header("Location: register_judges.php?action=logout");
exit;
}
//send the header
send_header("Judges Registration - Personal Information");
echo "<a href=\"register_judges_main.php\">&lt;&lt; ".i18n("Back to Judges Registration Summary")."</a><br />";
echo "<br />";
if($_POST['action']=="save")
{
$dob=$_POST['year']."-".$_POST['month']."-".$_POST['day'];
mysql_query("UPDATE judges SET ".
"firstname='".mysql_escape_string(stripslashes($_POST['firstname']))."', ".
"lastname='".mysql_escape_string(stripslashes($_POST['lastname']))."', ".
"email='".mysql_escape_string(stripslashes($_POST['email']))."', ".
"address='".mysql_escape_string(stripslashes($_POST['address']))."', ".
"city='".mysql_escape_string(stripslashes($_POST['city']))."', ".
"province='".mysql_escape_string(stripslashes($_POST['province']))."', ".
"postalcode='".mysql_escape_string(stripslashes($_POST['postalcode']))."', ".
"phone='".mysql_escape_string(stripslashes($_POST['phone']))."', ".
"organization='".mysql_escape_string(stripslashes($_POST['organization']))."', ".
"years_school='".mysql_escape_string(stripslashes($_POST['years_school']))."', ".
"years_regional='".mysql_escape_string(stripslashes($_POST['years_regional']))."', ".
"years_national='".mysql_escape_string(stripslashes($_POST['years_national']))."', ".
"dateofbirth='$dob' ".
"WHERE id='".$_SESSION['judges_id']."'");
echo mysql_error();
echo notice(i18n("%1 %2 successfully updated",array($_POST['firstname'],$_POST['lastname'])));
}
$q=mysql_query("SELECT * FROM judges WHERE email='".$_SESSION['email']."' AND id='".$_SESSION['judges_id']."'");
$judgeinfo=mysql_fetch_object($q);
//output the current status
$newstatus=personalStatus();
if($newstatus!="complete")
{
echo error(i18n("Personal Information Incomplete"));
}
else
{
echo happy(i18n("Personal Information Complete"));
}
echo "<form name=\"personalform\" method=\"post\" action=\"register_judges_personal.php\">\n";
echo "<input type=\"hidden\" name=\"action\" value=\"save\">\n";
echo "<table>\n";
echo "<tr>\n";
echo " <td>".i18n("First Name")."</td><td><input type=\"text\" name=\"firstname\" value=\"$judgeinfo->firstname\" /></td>\n";
echo " <td>".i18n("Last Name")."</td><td><input type=\"text\" name=\"lastname\" value=\"$judgeinfo->lastname\" /></td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo " <td>".i18n("Email Address")."</td><td><input type=\"text\" name=\"email\" value=\"$judgeinfo->email\" /></td>\n";
echo " <td>".i18n("City")."</td><td><input type=\"text\" name=\"city\" value=\"$judgeinfo->city\" /></td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo " <td>".i18n("Address")."</td><td><input type=\"text\" name=\"address\" value=\"$judgeinfo->address\" /></td>\n";
echo " <td>".i18n("Province")."</td><td><input type=\"text\" name=\"province\" value=\"$judgeinfo->province\" /></td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo " <td>".i18n("Postal Code")."</td><td><input type=\"text\" name=\"postalcode\" value=\"$judgeinfo->postalcode\" /></td>\n";
echo " <td>".i18n("Phone")."</td><td><input type=\"text\" name=\"phone\" value=\"$judgeinfo->phone\" /></td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo " <td>".i18n("Date of Birth")."</td><td>\n";
list($year,$month,$day)=split("-",$judgeinfo->dateofbirth);
echo "<table><tr><td>";
emit_day_selector("day",$day);
echo "</td><td>\n";
emit_month_selector("month",$month);
echo "</td><td>\n";
emit_year_selector("year",$year,date("Y")-$config['maxjudgeage'],date("Y")-$config['minjudgeage']);
echo "</td></tr></table>\n";
echo " </td>\n";
echo " <td>".i18n("Organization")."</td><td><input type=\"text\" name=\"organization\" value=\"$judgeinfo->organization\" /></td>\n";
echo "</tr>";
echo "<tr><td colspan=\"4\"><hr /></td></tr>";
echo "<tr>\n";
echo " <td colspan=\"3\">".i18n("Years of judging experience at school/local level")."</td><td><input type=\"text\" name=\"years_school\" value=\"$judgeinfo->years_school\" size=\"3\" ></td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo " <td colspan=\"3\">".i18n("Years of judging experience at regional level")."</td><td><input type=\"text\" name=\"years_regional\" value=\"$judgeinfo->years_regional\" size=\"3\" ></td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo " <td colspan=\"3\">".i18n("Years of judging experience at national level")."</td><td><input type=\"text\" name=\"years_national\" value=\"$judgeinfo->years_national\" size=\"3\" ></td>\n";
echo "</tr>\n";
echo "</table>";
echo "<input type=\"submit\" value=\"".i18n("Save Personal Information")."\" />\n";
echo "</form>";
send_footer();
?>

View File

@ -1,31 +1,4 @@
<? <?
function outputStatus($status)
{
$ret="";
switch($status)
{
case 'incomplete':
$ret.="<div class=\"incomplete\">";
$ret.= i18n("Incomplete");
$ret.= "</div>";
break;
case 'complete':
$ret.= "<div class=\"complete\">";
$ret.= i18n("Complete");
$ret.= "</div>";
break;
case 'empty':
$ret.="<div class=\"incomplete\">";
$ret.= i18n("Empty");
$ret.= "</div>";
break;
default:
$ret.=i18n("Unknown");
break;
}
return $ret;
}
function studentStatus() function studentStatus()
{ {