From 32b3d1d368c7021e64df1b7c402f33d4d7cd3532 Mon Sep 17 00:00:00 2001 From: james Date: Wed, 2 Mar 2011 06:22:27 +0000 Subject: [PATCH] Add a quick and dirty participant_invite page to allow teachers to invite participants, since the teacher interface hasnt been created yet on the drupal side --- account.inc.php | 8 +- participant_invite.php | 243 +++++++++++++++++++++++++++++++++++++++++ user.inc.php | 5 + 3 files changed, 255 insertions(+), 1 deletion(-) create mode 100644 participant_invite.php diff --git a/account.inc.php b/account.inc.php index 0b787e8..94c831d 100644 --- a/account.inc.php +++ b/account.inc.php @@ -298,7 +298,13 @@ function account_add_role($accounts_id, $roles_id, $conferences_id, $password = } break; case 'invite': - $error = 'invalidrole'; + if( in_array("teacher",$_SESSION['roles']) && $role=='participant') { + //if they are a teacher, they can add a participant role a-ok + $error = ''; + } + else { + $error = 'invalidrole(invite only)'; + } break; } } diff --git a/participant_invite.php b/participant_invite.php new file mode 100644 index 0000000..1fe1c57 --- /dev/null +++ b/participant_invite.php @@ -0,0 +1,243 @@ + + 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. +*/ +?> + 'committee_main.php', + 'Administration' => 'admin/index.php' + ) ); + +?> + +"; + +/* +//FIXME: commente dby james 2010-12-21 - we need ta better way to know which types we can invite + $allowed_types = array('judge', 'volunteer'); + if($type == '') $type = $_GET['type']; + if($type != '') { + if(!in_array($type, $allowed_types)) { + echo "Type $type not allowed for invite

"; + exit; + } + } + */ + +if($_POST['action']=="invitenew" && $_POST['email'] && $type != '') { + $newUser=user_invite($_POST['email'], null, $_POST['email'], $type); + if(is_array($newUser)) { + echo happy(i18n("%1 successfully invited to be a %2",array($_POST['email'],$type))); + } + else { + echo error($newUser); + } + } + else if($_POST['action']=="inviteexisting" && $_POST['email'] && $type != '') { + + $newUser=user_invite($_POST['email'], null, $_POST['email'], $type); + if(is_array($newUser)) { + echo happy(i18n("%1 successfully invited to be a %2",array($_POST['email'],$type))); + } + else { + echo error($newUser); + } + } + + + echo "
\n"; + echo "\n"; + echo ""; + /* + echo ""; + */ + echo "
"; + echo i18n("Select a Role: "); + echo "
"; + echo i18n("Enter an Email: "); + echo ""; + echo "
"; + echo "
\n"; + echo "
".i18n('Enter an email address')."
"; + + echo "
\n"; + echo "\n"; + + echo "
\n"; + + $q=mysql_query("SELECT users.firstname, users.lastname, accounts.username, accounts.email, accounts.pendingemail FROM users + JOIN accounts on users.accounts_id=accounts.id + JOIN user_roles ON user_roles.users_id=users.id + JOIN roles ON user_roles.roles_id=roles.id + WHERE schools_id='$schoolid' + AND conferences_id='{$conference['id']}' + AND roles.type='participant'"); + echo mysql_error(); + echo "
"; + echo "
"; + echo "

".i18n("The following participants have been invited from your school")."

\n"; + echo "\n"; + echo ""; + echo "\n"; + while($r=mysql_fetch_object($q)) { + echo ""; + echo " "; + echo " "; + echo " "; + echo " "; + echo ""; + + } + echo "
UsernameEmail AddressFirst NameLast Name
$r->username"; + if($r->email) { + echo "$r->email"; + } + else if($r->pendingemail) { + echo "$r->pendingemail"; + } + echo "$r->firstname$r->lastname
\n"; + + send_footer(); +?> diff --git a/user.inc.php b/user.inc.php index 0730e94..ff14f23 100644 --- a/user.inc.php +++ b/user.inc.php @@ -1701,8 +1701,13 @@ function user_invite($username, $password, $email, $roles_id){ $returnval = 'Error creating user'; }else{ if($roletype == 'participant'){ + /* $newUser['schools_id'] = $u['schools_id']; user_save($newUser); + */ + //user_save doesnt save schools_id, and we cant use the user_set_school either because it relies on the access code being passed in, so, lets just set it manually. + mysql_query("UPDATE users SET schools_id = {$u['schools_id']} WHERE id = " . $newUser['id']); + } } }else{