Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Allow Org admins to Remove Users from their Organization #8705

Merged
merged 10 commits into from
Jul 31, 2023
14 changes: 13 additions & 1 deletion cgi/org.pl
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,19 @@
$template_data_ref->{profile_url} = canonicalize_tag_link("editors", "org-" . $orgid);
$template_data_ref->{profile_name} = sprintf(lang('user_s_page'), $org_ref->{name});
}
elsif ($type eq 'delete') {
elsif ($type eq 'user_delete') {
$log->debug("before deleting the user from org",
{type => $type, action => $action, orgid => $orgid, userid => single_param('user_id')})
if $log->is_debug();
if (is_user_in_org_group($org_ref, $User_id, "admins")) {
my $groups_ref = ['members'];
my $user_to_remove = single_param('user_id');
remove_user_from_org($orgid, $user_to_remove, $groups_ref);
$template_data_ref->{result} = "User successfully removed from the organization";
$log->debug("after removal")
if $log->is_debug();
}

}
}

Expand Down
44 changes: 44 additions & 0 deletions templates/web/pages/org_form/org_form.tt.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,50 @@
<div class="panel" style="background-color:#ffdddd">The organization <strong>[% orgid %]</strong> does not exist yet. It will be created if you submit the form.</div>
[% END %]

[% IF org_members.size %]
alexgarel marked this conversation as resolved.
Show resolved Hide resolved
<h2>[% lang("organization_members") %]</h2>
<p>[% lang("number_of_members") %][% sep %]: [% org_members.size %]</p>
<div style="position:relative">
<table>
<thead>
<tr>
<th>[% lang("serial_no") %]</th>
<th>[% lang("username") %]</th>
<th>[% lang("name") %]</th>
<th>[% lang("email") %]</th>
<th>[% lang("select_lang") %]</th>
<th>[% lang("select_country") %]</th>
<th>[% lang("delete_user") %]</th>

</tr>
</thead>
<tbody>
[% SET count = 1 %]
[% FOREACH users IN org_members %]
<tr>
<td>[% count %].</td>
<td>[% users.userid %]</td>
<td>[% users.name %]</td>
<td>[% users.email %]</td>
<td>[% users.initial_lc %]</td>
<td>[% users.initial_cc %]</td>
<td>
<form method="post" action="/cgi/org.pl?type=edit&orgid=[% orgid %]" onsubmit="return confirm('Are you sure you want to remove this user?')">
<input type="hidden" name="action" value="process" />
<input type="hidden" name="type" value="user_delete" />
<input type="hidden" name="org_id" value="[% orgid %]">
<input type="hidden" name="user_id" value="[% users.userid %]">
<input type="submit" name="remove_user" class="button small" value="Remove User" />
</form>
</td>
</tr>
[% SET count = count + 1 %]
[% END %]
</tbody>
</table>
</div>
[% END %]

<!-- Start form -->

<p>[% lang('org_profile_description') %]</p>
Expand Down
35 changes: 0 additions & 35 deletions templates/web/pages/org_profile/org_profile.tt.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,41 +14,6 @@
<p>&rarr; <a href="[% link %]">[% lang("official_site") %]</a></p>
[% END %]

[% IF org_members.size %]
<h2>[% lang("organization_members") %]</h2>
<p>[% lang("number_of_members") %][% sep %]: [% org_members.size %]</p>
<div style="position:relative">
<table>
<thead>
<tr>
<th>[% lang("serial_no") %]</th>
<th>[% lang("username") %]</th>
<th>[% lang("name") %]</th>
<th>[% lang("email") %]</th>
<th>[% lang("select_lang") %]</th>
<th>[% lang("select_country") %]</th>

</tr>
</thead>
<tbody>
[% FOREACH users IN org_members %]
[% SET count = 1 %]
<tr>
<td>[% count %].</td>
<td>[% users.userid %]</td>
<td>[% users.name %]</td>
<td>[% users.email %]</td>
<td>[% users.initial_lc %]</td>
<td>[% users.initial_cc %]</td>
</tr>
[% SET count = count + 1 %]
[% END %]
</tbody>
</table>
</div>
[% END %]


<div class="row">

[% FOREACH contact IN ['customer_service', 'commercial_service'] %]
Expand Down
Loading