Commit fb4515ab authored by Richard Mansfield's avatar Richard Mansfield
Browse files

Allow group admins to remove users from group

parent 509a5c5f
......@@ -33,6 +33,7 @@ require_once(get_config('docroot') . 'interaction/lib.php');
$groupid = param_integer('group');
$userid = param_integer('user');
$newrole = param_alpha('role', null);
$remove = param_integer('remove', null);
if (!$group = get_record('group', 'id', $groupid, 'deleted', 0)) {
throw new GroupNotFoundException("Couldn't find group with id $groupid");
......@@ -54,6 +55,11 @@ if ($newrole && $newrole != $userrole) {
$SESSION->add_ok_msg(get_string('rolechanged', 'group'));
redirect('/group/members.php?id='.$groupid);
}
else if ($remove) {
delete_records('group_member', 'group', $groupid, 'member', $userid);
$SESSION->add_ok_msg(get_string('userremoved', 'group'));
redirect('/group/members.php?id='.$groupid);
}
define('TITLE', $group->name . ' - ' . get_string('Changerole', 'group'));
......
......@@ -253,4 +253,6 @@ $string['changeroleofuseringroup'] = 'Change role of %s in %s';
$string['currentrole'] = 'Current role';
$string['changeroleto'] = 'Change role to';
$string['rolechanged'] = 'Role changed';
$string['removefromgroup'] = 'Remove from group';
$string['userremoved'] = 'User removed';
?>
......@@ -7,8 +7,7 @@
{include file="group/tabstart.tpl" current="members"}
<div class="group-info-para"><h3>{$subtitle}</h3></div>
<div class="group-info-para">{str tag=currentrole section=group}: {$roles[$userrole]->display}</div>
<div class="group-info-para">
<div class="group-info-para">{str tag=currentrole section=group}: {$roles[$userrole]->display}
<form method="post">
<input type="hidden" name="userid" value="{$userid|escape}" />
<input type="hidden" name="groupid" value="{$groupid|escape}" />
......@@ -18,9 +17,11 @@
<option value="{$role->role}"{if ($role->role == $userrole)} selected{/if}>{$role->display}</option>
{/foreach}
</select>
<input type="submit" value="{str tag=submit}" />
<input type="submit" value="{str tag=submit}" /><br />
</form>
</div><br />
</div>
<div class="group-info-para"><a href="{$WWWROOT}group/changerole.php?user={$userid}&amp;group={$groupid}&amp;remove=1">{str tag=removefromgroup section=group}</a></div>
<br />
{include file="group/tabend.tpl"}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment