From e8353f011f17a6898f1b2a0f21cc8682d0f96d4e Mon Sep 17 00:00:00 2001 From: james Date: Fri, 25 Nov 2005 21:15:29 +0000 Subject: [PATCH] Add the judge inviter to the judge administration section Add the new judge invite email --- admin/judges.php | 4 +++ admin/judges_invite.php | 63 +++++++++++++++++++++++++++++++++++++++++ common.inc.php | 16 +++++++++++ db/db.update.9.sql | 2 +- register_judges.php | 1 - 5 files changed, 84 insertions(+), 2 deletions(-) create mode 100644 admin/judges_invite.php diff --git a/admin/judges.php b/admin/judges.php index 2b53dac..26c06ce 100644 --- a/admin/judges.php +++ b/admin/judges.php @@ -30,6 +30,10 @@ echo "
"; echo "
"; + if($config['judge_registration_type']=="invite") + { + echo "".i18n("Invite Judges")."
"; + } echo "".i18n("Manage Judging Teams")."
"; echo "".i18n("Manage Judging Team Members")."
"; echo "".i18n("Manage Judging Timeslots")."
"; diff --git a/admin/judges_invite.php b/admin/judges_invite.php new file mode 100644 index 0000000..01205a7 --- /dev/null +++ b/admin/judges_invite.php @@ -0,0 +1,63 @@ + + 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 Administration")."\n"; + echo "<< ".i18n("Back to Judges")."\n"; + echo "
"; + echo "
"; + if($_POST['action']=="invite" && $_POST['email']) + { + $q=mysql_query("SELECT id FROM judges WHERE email='".$_POST['email']."'"); + if(mysql_num_rows($q)) + { + echo error(i18n("A judge already exists with that email address")); + } + else + { + $pass=generatePassword(); + mysql_query("INSERT INTO judges (email,password) VALUES ('".mysql_escape_string(stripslashes($_POST['email']))."','$pass')"); + email_send("new_judge_invite",stripslashes($_POST['email']),array("FAIRNAME"=>$config['fairname']),array("FAIRNAME"=>$config['fairname'],"EMAIL"=>stripslashes($_POST['email']),"PASSWORD"=>$pass)); + + echo happy(i18n("%1 has been invited to be a judge",array($_POST['email']))); + } + } + + + echo i18n("Enter the judge's email address to invite them to be a judge"); + echo "
\n"; + echo "
\n"; + echo "
\n"; + echo "\n"; + echo i18n("Email").": "; + echo "\n"; + echo "\n"; + echo "
\n"; + + send_footer(); +?> diff --git a/common.inc.php b/common.inc.php index 8063193..8f7ecc9 100644 --- a/common.inc.php +++ b/common.inc.php @@ -757,4 +757,20 @@ function output_page_text($textname) } echo nl2br(i18n($r->text)); } + +function generatePassword() +{ + //these are good characters that are not easily confused with other characters :) + $available="ABCDEFGHJKLMNPQRSTUVWXYZabcdefghjkmnpqrstuvwxyz23456789"; + $len=strlen($available); + + $key=""; + for($x=0;$x<8;$x++) + { + $key.=$available[rand(0,$len)]; + } + return $key; +} + + ?> diff --git a/db/db.update.9.sql b/db/db.update.9.sql index 7131d24..55d82d6 100644 --- a/db/db.update.9.sql +++ b/db/db.update.9.sql @@ -6,4 +6,4 @@ INSERT INTO `config` ( `var` , `val` , `description` , `year` ) VALUES ( 'judge_ ALTER TABLE `schools` ADD `registration_password` VARCHAR( 32 ) NOT NULL; INSERT INTO `emails` VALUES ('', 'register_participants_resend_regnum', 'Participant Registration - Resend Registration Number', 'Resend the password to the participant if they submit a ''forgot regnum'' request', 'website@sfiab.ca', 'Registration for [FAIRNAME]', 'We have received a request for the retrieval if your registration number from this email address. Please find your existing registration number below\r\n\r\nRegistration Number: [REGNUM]\r\n', 'system'); INSERT INTO `emails` VALUES ('', 'new_participant', 'New Participant', 'Email that new participants receive when they are added to the system', 'website@sfiab.ca', 'Registration for [FAIRNAME]', 'A new registration account has been created for you. To access your registration account, please enter enter the following registration number into the registration website:\r\n\r\nRegistration Number: [REGNUM]\r\n', 'system'); - +INSERT INTO `emails` VALUES ('', 'new_judge_invite', 'New Judge Invitation', 'This is sent to a new judge when they are invited using the invite judges administration section, only available when judge_registraiton_type=invite', 'registration@sfiab.ca', 'Judge Registration for [FAIRNAME]', 'You have been invited to be a judge for the [FAIRNAME]. An account has been created for you to login with and complete your information. You can login to the judge registration site with:\r\n\r\nEmail Address: [EMAIL]\r\nPassword: [PASSWORD]\r\n\r\nYou can change your password once you login.', 'system'); diff --git a/register_judges.php b/register_judges.php index c3c0519..30e0993 100644 --- a/register_judges.php +++ b/register_judges.php @@ -102,7 +102,6 @@ if($_SESSION['email'] && $_SESSION['judges_id']) header("Location: register_judges_main.php"); - send_header("Judges Registration"); $_POST['email']=trim($_POST['email']);