From 5ce75f9a82556b6fe32fb95e8a8a5ae6aeece7e2 Mon Sep 17 00:00:00 2001 From: james Date: Thu, 3 Mar 2011 05:13:29 +0000 Subject: [PATCH] Allow uninviting participants --- participant_invite.php | 26 ++++++++++++++++++++++---- user.inc.php | 26 ++++++++++++++++---------- 2 files changed, 38 insertions(+), 14 deletions(-) diff --git a/participant_invite.php b/participant_invite.php index 1fe1c57..60b6296 100644 --- a/participant_invite.php +++ b/participant_invite.php @@ -78,6 +78,17 @@ exit; } +//this is ajax too, but we dont explicitly say AJAX==1, thats silly :p + if($_POST['action']=="uninvite") { + if($_POST['userid']) { + user_uninvite(intval($_POST['userid']),$type); + } + exit; + } + + + + send_header("Invite Participants", array('Committee Main' => 'committee_main.php', 'Administration' => 'admin/index.php' @@ -143,6 +154,14 @@ $("#status").html(text); } + function uninvite(id) { + if(confirmClick('Are you sure you want to uninvite this participant?')) { + $.post("participant_invite.php",{action: 'uninvite', userid: id},function() { + document.location.href='participant_invite.php'; + }); + } + } + \n"; echo "\n"; echo ""; @@ -207,7 +224,7 @@ if($_POST['action']=="invitenew" && $_POST['email'] && $type != '') { echo "\n"; - $q=mysql_query("SELECT users.firstname, users.lastname, accounts.username, accounts.email, accounts.pendingemail FROM users + $q=mysql_query("SELECT users.id, 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 @@ -219,7 +236,7 @@ if($_POST['action']=="invitenew" && $_POST['email'] && $type != '') { echo "
"; echo "

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

\n"; echo "
\n"; - echo ""; + echo ""; echo "\n"; while($r=mysql_fetch_object($q)) { echo ""; @@ -234,6 +251,7 @@ if($_POST['action']=="invitenew" && $_POST['email'] && $type != '') { echo ""; echo " "; echo " "; + echo " "; echo ""; } diff --git a/user.inc.php b/user.inc.php index 91a9f50..19bee1e 100644 --- a/user.inc.php +++ b/user.inc.php @@ -1763,19 +1763,24 @@ function user_uninvite($uid, $roles_id){ // idiot proofing if(!is_numeric($uid)) return "Invalid user id"; - if(!is_numeric($roles_id)) return "Invalid role id"; + + $roletype = null; + //if its numeric, then we got an id, so get the associated roletype + if(is_numeric($roles_id)) { + foreach($roles as $t => $r){ + if($r['id'] == $roles_id){ + $roletype = $t; + break; + } + } + } else { //if its not numeric, then its a roletype, so set the type and get the id + $roletype=$roles_id; + $roles_id=$roles[$roletype]['id']; + } $u = user_load($_SESSION['users_id']); $returnval = null; - $roletype = null; - foreach($roles as $t => $r){ - if($r['id'] == $roles_id){ - $roletype = $t; - break; - } - } - if($roletype === null){ $returnval = 'Invalid roles_id parameter'; }else if(!user_has_authority($u, $roletype)){ @@ -1801,7 +1806,8 @@ function user_uninvite($uid, $roles_id){ $returnval = mysql_error(); } - if($returnval == null) $returnval = user_load($uid); + if($returnval == null) + $returnval = user_load($uid); return $returnval; }
UsernameEmail AddressFirst NameLast Name
UsernameEmail AddressFirst NameLast NameActions
$r->firstname$r->lastnameid)\">uninvite