3 %# Copyright (c) 1996-2003 Jesse Vincent <jesse@bestpractical.com>
5 %# (Except where explictly superceded by other copyright notices)
7 %# This work is made available to you under the terms of Version 2 of
8 %# the GNU General Public License. A copy of that license should have
9 %# been provided with this software, but in any event can be snarfed
12 %# This work is distributed in the hope that it will be useful, but
13 %# WITHOUT ANY WARRANTY; without even the implied warranty of
14 %# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 %# General Public License for more details.
17 %# Unless otherwise specified, all modifications, corrections or
18 %# extensions to this work which alter its source code become the
19 %# property of Best Practical Solutions, LLC when submitted for
20 %# inclusion in the work.
24 <& /Elements/Header, Title => $title &>
25 <& /User/Elements/GroupTabs,
27 current_subtab => "User/Groups/Members.html?id=".$Group->id,
29 <& /Elements/ListActions, actions => \@results &>
33 <FORM ACTION="<%$RT::WebPath%>/User/Groups/Members.html" METHOD="POST">
34 <INPUT TYPE=HIDDEN NAME=id VALUE="<%$Group->Id%>">
38 <&|/l&>Add members</&>
41 <&|/l&>Current members</&>
47 <& /Admin/Elements/SelectNewGroupMembers, Name => "AddMembers", Group => $Group &>
51 % if ($Group->MembersObj->Count == 0 ) {
52 <i><&|/l&>(No members)</&></i>
54 <i><&|/l&>(Check box to delete)</&></i>
58 % my $UserMembers = $Group->MembersObj;
59 % $UserMembers->LimitToUsers();
61 % while (my $member = $UserMembers->Next()) {
62 <LI><INPUT TYPE=CHECKBOX Name="DeleteMember-<%$member->MemberId%>">
63 <%$member->MemberObj->Object->Name%> (<%$member->MemberObj->Object->RealName%>)
68 % my $GroupMembers = $Group->MembersObj;
69 % $GroupMembers->LimitToGroups();
70 % while (my $member = $GroupMembers->Next()) {
71 <LI><INPUT TYPE=CHECKBOX Name="DeleteMember-<%$member->MemberId%>">
72 <%$member->MemberObj->Object->Name%>
79 <& /Elements/Submit &>
85 my $Group = new RT::Group($session{'CurrentUser'});
89 Abort(loc('Could not load group'));
94 foreach my $key (keys %ARGS) {
96 if ($key =~ /^DeleteMember-(\d+)$/) {
98 my ($val,$msg) = $Group->DeleteMember($mem_id);
99 push (@results, $msg);
103 # Make sure AddMembers is always an array
104 my @AddMembersUsers = (ref $AddMembersUsers eq 'ARRAY') ? @{$AddMembersUsers} : ($AddMembersUsers);
105 my @AddMembersGroups = (ref $AddMembersGroups eq 'ARRAY') ? @{$AddMembersGroups} : ($AddMembersGroups);
107 foreach my $member (@AddMembersUsers, @AddMembersGroups) {
108 next unless ($member);
112 if ($member =~ /^Group-(\d+)$/) {
113 $principal = RT::Group->new($session{'CurrentUser'});
114 $principal->Load($1);
115 } elsif ($member =~ /^User-(\d+)$/) {
116 $principal = RT::User->new($session{'CurrentUser'});
117 $principal->Load($1);
123 my ($val, $msg) = $Group->AddMember($principal->PrincipalId);
124 push (@results, $msg);
128 my $title = loc('Editing membership for personal group [_1]', $Group->Name);
133 $AddMembersUsers => undef
134 $AddMembersGroups => undef