Allow uninviting participants

This commit is contained in:
james 2011-03-03 05:13:29 +00:00
parent a5eeefa195
commit 5ce75f9a82
2 changed files with 38 additions and 14 deletions

View File

@ -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';
});
}
}
</script>
<?
@ -179,8 +198,6 @@ if($_POST['action']=="invitenew" && $_POST['email'] && $type != '') {
echo error($newUser);
}
}
echo "<form method=\"post\" name=\"invite\" action=\"participant_invite.php\">\n";
echo "<input type=\"hidden\" name=\"action\" id=\"action\" value=\"invite\" />\n";
echo "<table>";
@ -207,7 +224,7 @@ if($_POST['action']=="invitenew" && $_POST['email'] && $type != '') {
echo "</form>\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 "<br />";
echo "<h2>".i18n("The following participants have been invited from your school")."</h2>\n";
echo "<table class=\"tableview\">\n";
echo "<tr><th>Username</th><th>Email Address</th><th>First Name</th><th>Last Name</th>";
echo "<tr><th>Username</th><th>Email Address</th><th>First Name</th><th>Last Name</th><th>Actions</th>";
echo "</tr>\n";
while($r=mysql_fetch_object($q)) {
echo "<tr>";
@ -234,6 +251,7 @@ if($_POST['action']=="invitenew" && $_POST['email'] && $type != '') {
echo "</td>";
echo " <td>$r->firstname</td>";
echo " <td>$r->lastname</td>";
echo " <td><a href=\"#\" onclick=\"return uninvite($r->id)\">uninvite</a></td>";
echo "</tr>";
}

View File

@ -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;
}