create email_send function to pull emails from databaes and send

add ability to delete judge account - soft-delete

make sure when logging in, only non-deleted accounts can be used.
This commit is contained in:
james 2005-02-11 18:25:59 +00:00
parent 0780f33984
commit 42c58426dd
5 changed files with 101 additions and 17 deletions

View File

@ -386,5 +386,56 @@ function outputStatus($status)
}
function email_send($val,$to,$sub_subject=array(),$sub_body=array())
{
$q=mysql_query("SELECT * FROM emails WHERE val='$val'");
if($r=mysql_fetch_object($q))
{
$subject=i18n($r->subject);
$body=i18n($r->body);
if(count($sub_subject))
{
foreach($sub_subject AS $sub_k=>$sub_v)
{
$subject=ereg_replace("\[$sub_k\]",$sub_v,$subject);
}
}
if(count($sub_body))
{
foreach($sub_body AS $sub_k=>$sub_v)
{
$body=ereg_replace("\[$sub_k\]",$sub_v,$body);
}
}
//now word-wrap the body to 79 chars
//hmm forget the wordwrap for now, its not really needed, but could be done later if need be.
//i'll leave in the start of the function, but its not nearly complete
/*
$MAXCHARS=79;
$c=0;
$lastspace=0;
for($x=0;$x<strlen($body);$x++)
{
if($body[$x]==" ")
$lastspace=$x;
$c++;
if($c>$MAXCHARS)
{
}
}
*/
mail($to,$subject,$body,"From: $r->from\r\nReply-To: $r->from");
}
else
{
echo error(i18n("CRITICAL ERROR: email '%1' not found",array($val)));
}
}
?>

View File

@ -59,7 +59,7 @@
{
if($_POST['pass'])
{
$q=mysql_query("SELECT * FROM judges WHERE email='".$_SESSION['email']."' AND password='".$_POST['pass']."'");
$q=mysql_query("SELECT * FROM judges WHERE email='".$_SESSION['email']."' AND password='".$_POST['pass']."' AND deleted='no'");
if(mysql_num_rows($q)==1)
{
$r=mysql_fetch_object($q);
@ -102,7 +102,7 @@
$allownew=true;
//first, check if they have any registrations waiting to be opened
$q=mysql_query("SELECT * FROM judges WHERE email='".$_SESSION['email']."'");
$q=mysql_query("SELECT * FROM judges WHERE email='".$_SESSION['email']."' AND deleted='no'");
if(mysql_num_rows($q)>0)
{
echo i18n("Please enter your password to login");

View File

@ -66,7 +66,15 @@
mysql_query("INSERT INTO judges_expertise (judges_id, projectsubdivisions_id, val, year) VALUES ('".$_SESSION['judges_id']."','$key','$val','".$config['FAIRYEAR']."')");
}
if($_POST['expertise_other'])
{
mysql_query("UPDATE judges SET expertise_other='".mysql_escape_string(stripslashes($_POST['expertise_other']))."' WHERE id='".$_SESSION['judges_id']."'");
}
else
{
mysql_query("UPDATE judges SET expertise_other=NULL WHERE id='".$_SESSION['judges_id']."'");
}
echo notice(i18n("Areas of Expertise successfully saved"));
}
$q=mysql_query("SELECT * FROM judges WHERE email='".$_SESSION['email']."' AND id='".$_SESSION['judges_id']."'");
@ -110,6 +118,7 @@ else
echo "<tr><th></th>";
for($x=1;$x<=5;$x++)
echo "<th>$x</th>";
echo "<th></th>";
echo "</tr>";
echo "<tr><td><b>".i18n($r->division)."</b></td>";
@ -120,6 +129,7 @@ else
echo "<td width=\"30\"><input $sel type=\"radio\" name=\"division[$r->id]\" value=\"$x\" /></td>";
}
echo "<td width=\"100\"></td>";
echo "</tr>";
//only show the sub-divisions if the 'main' division is scored >=3
@ -134,18 +144,25 @@ else
if($subexpertise[$subr->id]) $ch="checked=\"checked\""; else $ch="";
echo "<td><input $ch type=\"checkbox\" name=\"subdivision[$subr->id]\" value=\"1\" /></td>";
echo "<td colspan=\"4\">";
echo "<td colspan=\"5\">";
echo "$subr->subdivision";
echo "</td>";
echo "</tr>";
}
}
echo "<tr><td colspan=\"6\">&nbsp;</td></tr>";
echo "<tr><td colspan=\"7\">&nbsp;</td></tr>";
}
echo "</table>";
echo "<br />";
echo "<h3>Other Areas of Expertise not listed above</h3>";
$q=mysql_query("SELECT expertise_other FROM judges WHERE id='".$_SESSION['judges_id']."'");
$judgeinfo=mysql_fetch_object($q);
echo "<textarea name=\"expertise_other\" rows=\"4\" cols=\"60\">".htmlspecialchars($judgeinfo->expertise_other)."</textarea>";
echo "<br />";
echo "<br />";
echo "<input type=\"submit\" value=\"".i18n("Save Areas of Expertise Information")."\" />\n";
echo "</form>";

View File

@ -32,7 +32,7 @@
exit;
}
$q=mysql_query("SELECT * FROM judges WHERE email='".$_SESSION['email']."' AND id='".$_SESSION['judges_id']."'");
$q=mysql_query("SELECT * FROM judges WHERE email='".$_SESSION['email']."' AND id='".$_SESSION['judges_id']."' AND deleted='no'");
echo mysql_error();
if(mysql_num_rows($q)==0)
@ -54,6 +54,18 @@
echo happy(i18n("Judge profile for %1 successfully deactivated",array($config['FAIRYEAR'])));
}
if($_GET['action']=="delete")
{
//okay here we go, lets get rid of them completely, since this is what theyve asked for
echo happy(i18n("Judge account successfully deactivated. Goodbye!",array($config['FAIRYEAR'])));
mysql_query("UPDATE judges SET deleted='Y', deleteddatetime=NOW() WHERE id='".$_SESSION['judges_id']."'");
unset($_SESSION['judges_id']);
unset($_SESSION['email']);
send_footer();
exit;
}
//only display the named greeting if we have their name
if($judgeinfo->firstname)
{
@ -68,12 +80,18 @@
$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 i18n("If you would like to participate as a judge for the %1 %2 please click the '<b>Activate %3 Judge Profile</b>' button below to activate your judges account for the fair",array($config['FAIRYEAR'],$config['fairname'],$config['FAIRYEAR']));
echo "<br />";
echo "<br />";
echo i18n("If you can not judge this year, but would like to remain on our mailing list for future years, no action is necessary");
echo "<br />";
echo "<br />";
echo i18n("If you would like to be completely removed from our judges mailing list, please click the '<b>Delete Judge Account</b>' button below");
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 "<input style=\"width: 300px;\" type=\"submit\" value=\"".i18n("Activate %1 Judge Profile",array($config['FAIRYEAR']))."\">";
echo "</form>";
}
@ -132,12 +150,17 @@
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 "<input style=\"width: 300px;\" 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 "<form method=\"get\" action=\"".$_SERVER['PHP_SELF']."\">";
echo "<input type=\"hidden\" name=\"action\" value=\"delete\">\n";
echo "<input style=\"width: 300px;\" onclick=\"return confirmClick('".i18n("Are you sure you want to completely delete your judges account? \\n Doing so will remove you from our mailing list for future years and you will never hear from us again")."')\" type=\"submit\" value=\"".i18n("Delete Judge Account")."\">";
echo "</form>";
echo "<br />";
echo "<a href=\"register_judges.php?action=logout\">".i18n("Logout")."</a>";

View File

@ -78,14 +78,7 @@
$q=mysql_query("SELECT registrations.num FROM registrations, students WHERE students.email='".$_SESSION['email']."' AND students.registrations_id=registrations.id");
$r=mysql_fetch_object($q);
$mailbody= "We have received a request for the retrieval\n".
"if your registration number from this email\n".
"address. Please find your existing registration\n".
"number below:\n\n".
"\n".
"Registration Number: $r->num\n".
"\n";
mail($_SESSION['email'],i18n("Registration for %1",array(i18n($config['fairname']))),$mailbody);
email_send("register_participants_resend_regnum",$_SESSION['email'],array("FAIRNAME"=>i18n($config['fairname'])),array("REGNUM"=>$r->num));
send_header("Participant Registration");
echo notice(i18n("Your registration number has been resent to your email addess <b>%1</b>",array($_SESSION['email'])));