- the rest of the user invite system, should all be working now. Can be used

to invite Volunteers and Judges, or add the volunteer/judge role to an
  account, or send a reminder email to a specific volutneer/judge that
  registration is now open and they should login.
This commit is contained in:
dave 2008-11-08 08:35:08 +00:00
parent e4ed9f8772
commit bfb2b63a68
2 changed files with 67 additions and 14 deletions

View File

@ -23,3 +23,18 @@ ALTER TABLE `users_volunteer` DROP `tmp`;
DROP TABLE users_years;
-- Add new judge emails, delete old
INSERT INTO `emails` ( `id` , `val` , `name` , `description` , `from` , `subject` , `body` , `type` ) VALUES
('', 'judge_recover_password', 'Judges - Recover Password', 'Recover the password for a judge if they submit a ''forgot password'' request', '', 'Password Recovery for [FAIRNAME]', 'We have received a request for the recovery of your password from this email address. Please find your new password below:\n\nJudge Email Address: [EMAIL]\nJudge Password: [PASSWORD] ', 'system'),
('', 'judge_welcome', 'Judges - Welcome', 'Welcome email sent to a judge after they have registered for the first time. This email includes their temporary password.', '', 'Judge Registration for [FAIRNAME]', 'Thank you for registering as a judge at our fair. Please find your temporary password below. After logging in for the first time you will be prompted to change your password.\n\nJudge Email Address: [EMAIL]\nJudge Password: [PASSWORD]', 'system'),
('', 'judge_new_invite', 'Judges - New Judge Invitation', 'This is sent to a new judge when they are invited using the invite users administration option.', '', '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:\n\nEmail Address: [EMAIL]\nPassword: [PASSWORD]\nYou can change your password once you login.', 'system'),
('', 'judge_add_invite', 'Judges - Add Judge Invitation', 'This is sent to existing users when they are invited using the invite users administration option.', '', 'Judge Registration for [FAIRNAME]', 'The role of judge for the [FAIRNAME] has been added to your account by a committee member. When you login again, there will be a [Switch Roles] link in the upper right hand area of the page. Clicking on [Switch Roles] will let you switch between being a Judge and your other roles without needing to logout.\n', 'system');
('', 'judge_activate_reminder', 'Judges - Activation Reminder', 'This is sent to existing judges who have not yet activated their account for the current fair year.', '', 'Judge Registration for [FAIRNAME]', 'This message is to let you know that Judge registration for the [FAIRNAME] is now open. If you would like to participate in the fair this year please log in to the registration site using your email address ([EMAIL]) an\n', 'system');
('', 'volunteer_activate_reminder', 'Volunteer Registration - Activation Reminder', 'This is sent to existing volunteers who have not yet activated their account for the current fair year.', '', 'Volunteer Registration for [FAIRNAME]', 'This message is to let you know that Volunteer registration for the [FAIRNAME] is now open. If you would like to participate in the fair this year please log in to the registration site using your email address ([EMAIL]).\n', 'system');
DELETE FROM `emails` WHERE `val`='new_judge_invite';
DELETE FROM `emails` WHERE `val`='register_judges_resend_password';
-- Fix the names of these emails
UPDATE `emails` SET `name` = 'Volunteers - New Volunteer Invitation' WHERE `val`='volunteer_new_invite';
UPDATE `emails` SET `name` = 'Volunteers - Add Volunteer Invitation' WHERE `val`='volunteer_add_invite';

View File

@ -117,26 +117,31 @@
update_status("<?=i18n('Select a role and enter an email address')?>");
document.invite.button.disabled = true;
document.invite.button.value = "<?=i18n('Invite')?>";
document.invite.action.value = "err";
break;
case "notexist":
update_status("<?=i18n('User not found. Choose the \"Invite New User\" button below to create an account for this user and send them an email invite.')?>");
document.invite.button.disabled = false;
document.invite.button.value = "<?=i18n('Invite New User')?>";
document.invite.action.value = "notexist";
break;
case "norole":
update_status("<?=i18n('User found without the selected role. Choose the \"Invite User to Role\" button below add the selected role on this user\'s account and send them email notice of the change.')?>");
document.invite.button.disabled = false;
document.invite.button.value = "<?=i18n('Invite User to Role')?>";
document.invite.action.value = "norole";
break;
case "noyear":
update_status("<?=i18n('This user and role already exist, but the user has not yet activated their account for this year. Choose the \"Send Activation Reminder\" button below to send this user an email reminder to login (which activates their account for this year).')?>");
document.invite.button.disabled = false;
document.invite.button.value = "<?=i18n('Send Activation Reminder')?>";
document.invite.action.value = "noyear";
break;
case "exist":
update_status("<?=i18n('This user and role already exist. They cannot be invited.')?>");
document.invite.button.disabled = true;
document.invite.button.value = "<?=i18n('Invite')?>";
document.invite.action.value = "err";
break;
}
} else {
@ -150,26 +155,59 @@
<?
echo "<br />";
if($_POST['action']=="invite" && $_POST['email'])
{
$q=mysql_query("SELECT id FROM users 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'])));
if($_POST['action']!="" && $_POST['email'])
{
$allowed_actions = array('notexist','norole','noyear');
$email = stripslashes($_POST['email']);
$type = $_POST['type'];
$action = $_POST['action'];
if(!in_array($action, $allowed_actions))
exit;
$q = mysql_query("SELECT id FROM users WHERE email='$email' ORDER BY year DESC");
if(mysql_num_rows($q) > 0) {
$u = mysql_fetch_assoc($q);
$u = user_load($u['id']);
} else {
$u = NULL;
}
switch($action) {
case 'notexist': /* Create the user */
$u = user_create($type);
email_send("{$type}_new_invite",$u['email'],
array("FAIRNAME"=>$config['fairname']),
array("FAIRNAME"=>$config['fairname'],
"EMAIL"=>$u['email'],
"PASSWORD"=>$u['password']));
echo happy(i18n('%1 has been invited to be a %2', array($u['email'], $user_what[$type])));
echo happy(i18n('An email has been sent to %1', array($u['email'])));
break;
case 'norole': /* Add role to the existing user */
user_create($type, $u);
email_send("{$type}_add_invite",$u['email'],
array("FAIRNAME"=>$config['fairname']),
array("FAIRNAME"=>$config['fairname']));
echo happy(i18n('%1 is now also a %2', array($u['email'], $user_what[$type])));
echo happy(i18n('An email has been sent to %1', array($u['email'])));
break;
case 'noyear': /* Send a reminder email */
email_send("{$type}_activate_reminder",$u['email'],
array("FAIRNAME"=>$config['fairname']),
array("FAIRNAME"=>$config['fairname'],
"EMAIL"=>$u['email']));
echo happy(i18n('An email has been sent to %1', array($u['email'])));
break;
}
}
echo "<br />\n";
echo "<form method=\"post\" name=\"invite\" action=\"judges_invite.php\">\n";
echo "<form method=\"post\" name=\"invite\" action=\"user_invite.php\">\n";
echo "<input type=\"hidden\" name=\"action\" value=\"invite\" />\n";
echo "<table><tr><td>";
echo i18n("Select a Role: ");