forked from science-ation/science-ation
57f349b1b1
- Add a designate field to the schools, to indicate an independent, standard, private, etc. school. It's not editable yet, but.. eventually. - Fix generatePassword to use proper string indexing, and remove the possibility of indexing beyond the end of the string. - Add "Invite" and "SinglePassword" modes for volunteer registration. - Update the admin section, add a new volunteers page to contain links to all volunteer options
137 lines
4.5 KiB
PHP
137 lines
4.5 KiB
PHP
<?
|
|
/*
|
|
This file is part of the 'Science Fair In A Box' project
|
|
SFIAB Website: http://www.sfiab.ca
|
|
|
|
Copyright (C) 2005 Sci-Tech Ontario Inc <info@scitechontario.org>
|
|
Copyright (C) 2005 James Grant <james@lightbox.org>
|
|
|
|
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.
|
|
*/
|
|
?>
|
|
<?
|
|
require_once("../common.inc.php");
|
|
require_once("../user.inc.php");
|
|
user_auth_required('committee', 'admin');
|
|
|
|
$email = stripslashes($_POST['email']);
|
|
|
|
$type = $_GET['type'];
|
|
if(!in_array($type, $user_types)) {
|
|
send_header("Registration");
|
|
echo i18n("Invalid new registration\n");
|
|
send_footer();
|
|
exit;
|
|
}
|
|
|
|
switch($type) {
|
|
case 'volunteer':
|
|
$header_data = array('Volunteer Management' => 'admin/volunteer.php');
|
|
break;
|
|
case 'judge':
|
|
$header_data = array('Judges Management' => 'admin/judges.php');
|
|
break;
|
|
}
|
|
|
|
if($_POST['action']=='confirm' && $email != '') {
|
|
$header_data = array_merge($header_data,
|
|
array("{$user_what[$type]} Invitations" => "admin/user_invite.php?type=$type"));
|
|
send_header("{$user_what[$type]} Confirm",
|
|
array_merge(array('Committee Main' => 'committee_main.php',
|
|
'Administration' => 'admin/index.php'),
|
|
$header_data) );
|
|
} else {
|
|
send_header("{$user_what[$type]} Invitations",
|
|
array_merge(array('Committee Main' => 'committee_main.php',
|
|
'Administration' => 'admin/index.php'),
|
|
$header_data) );
|
|
}
|
|
|
|
$id = intval($_POST['id']);
|
|
if($_POST['action']=='confirm' && $id > 0) {
|
|
/* Add $type to their types */
|
|
$id = intval($_POST['id']);
|
|
$u = user_load($id);
|
|
$u = user_create($type, $u);
|
|
echo happy(i18n("%1 has been added as a {$user_what[$type]}",
|
|
array($email)));
|
|
email_send("{$type}_add_invite", $email,
|
|
array("FAIRNAME"=>$config['fairname']),
|
|
array("FAIRNAME"=>$config['fairname'],
|
|
"EMAIL"=>$email));
|
|
}
|
|
|
|
|
|
if($_POST['action']=="invite" && $email != '') {
|
|
$e = mysql_escape_string($email);
|
|
$q = mysql_query("SELECT id,types FROM users WHERE email='$e' OR username='$e'");
|
|
if(mysql_num_rows($q) > 0) {
|
|
/* Check the roles */
|
|
$r = mysql_fetch_object($q);
|
|
$types = split(',', $r->types);
|
|
if(in_array($type, $types)) {
|
|
echo notice(i18n("%1 already exists and is already a {$user_what[$type]}",
|
|
array($email)));
|
|
} else {
|
|
echo i18n("%1 already exists with the following roles:", array($email));
|
|
echo '<br /><ul>';
|
|
foreach($types as $t) {
|
|
echo '<li>'.i18n($user_what[$t]).'</li>';
|
|
}
|
|
echo '</ul>';
|
|
echo i18n("Instead of generating a new password and
|
|
creating a new account, the role of {$user_what[$type]}
|
|
will be added to this account.");
|
|
echo "<form method=\"post\" action=\"user_invite.php?type=$type\">";
|
|
echo "<input type=\"hidden\" name=\"action\" value=\"confirm\" />\n";
|
|
echo "<input type=\"hidden\" name=\"id\" value=\"{$r->id}\" />\n";
|
|
echo "<input type=\"hidden\" name=\"email\" value=\"$e\" />\n";
|
|
echo "<input type=\"submit\" value=\"".i18n("Add Role of {$user_what[$type]}")."\" />\n";
|
|
echo "</form>\n";
|
|
send_footer();
|
|
exit;
|
|
}
|
|
} else {
|
|
/* They don't exist, create a new account */
|
|
$u = user_create($type);
|
|
$u['username'] = $email;
|
|
$u['password'] = generatePassword(12);
|
|
$u['email'] = $email;
|
|
user_save($u);
|
|
|
|
email_send("{$type}_new_invite",$email,
|
|
array("FAIRNAME"=>$config['fairname']),
|
|
array("FAIRNAME"=>$config['fairname'],
|
|
"EMAIL"=>$email,
|
|
"PASSWORD"=>$u['password']));
|
|
|
|
echo happy(i18n("%1 has been invited to be a {$user_what[$type]}",array($email)));
|
|
}
|
|
}
|
|
|
|
|
|
echo i18n("Enter the {$user_what[$type]} email address to invite them to be a {$user_what[$type]}");
|
|
echo "<br />\n";
|
|
echo "<br />\n";
|
|
echo "<form method=\"post\" action=\"user_invite.php?type=$type\">\n";
|
|
echo "<input type=\"hidden\" name=\"action\" value=\"invite\" />\n";
|
|
echo i18n("Email").": ";
|
|
echo "<input type=\"text\" name=\"email\" size=\"40\" />\n";
|
|
echo "<input type=\"submit\" value=\"".i18n("Invite {$user_what[$type]}")."\" />\n";
|
|
echo "</form>\n";
|
|
|
|
send_footer();
|
|
?>
|