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 <& /Admin/Elements/Header, Title => "RT/Admin/Edit the group ". $Group->Name &>
25 <& /Admin/Elements/GroupTabs, GroupObj => $Group,
26 current_tab => 'Admin/Groups/Members.html?id='.$id,
27 Title => "RT/Admin/Edit the group ". $Group->Name &>
28 <& /Elements/ListActions, actions => \@results &>
31 <& /Elements/TitleBoxStart, title => loc('Editing membership for group [_1]', $Group->Name) &>
33 <FORM ACTION="<%$RT::WebPath%>/Admin/Groups/Members.html" METHOD=POST>
34 <INPUT TYPE=HIDDEN NAME=id VALUE="<%$Group->Id%>">
38 <h3><&|/l&>Current members</&></h3>
41 <h3><&|/l&>Add members</&></h3>
48 % if ($Group->MembersObj->Count == 0 ) {
49 <i><&|/l&>(No members)</&></i>
51 <i><&|/l&>(Check box to delete)</&></i>
55 % my $UserMembers = $Group->MembersObj;
56 % $UserMembers->LimitToUsers();
58 % while (my $member = $UserMembers->Next()) {
59 <LI><INPUT TYPE=CHECKBOX Name="DeleteMember-<%$member->MemberId%>">
60 <%$member->MemberObj->Object->Name%> (<%$member->MemberObj->Object->RealName%>)
65 % my $GroupMembers = $Group->MembersObj;
66 % $GroupMembers->LimitToGroups();
67 % while (my $member = $GroupMembers->Next()) {
68 <LI><INPUT TYPE=CHECKBOX Name="DeleteMember-<%$member->MemberId%>">
69 <%$member->MemberObj->Object->Name%>
75 <& /Admin/Elements/SelectNewGroupMembers, Name => "AddMembers", Group => $Group &>
79 <& /Elements/TitleBoxEnd &>
80 <& /Elements/Submit, Caption => loc("Be sure to save your changes"), Reset => 1 &>
86 my $Group = new RT::Group($session{'CurrentUser'});
87 $Group->Load($id) || Abort(loc('Could not load group'));
92 foreach $key (keys %ARGS) {
94 if ($key =~ /^DeleteMember-(\d+)$/) {
96 my ($val,$msg) = $Group->DeleteMember($id);
97 push (@results, $msg);
101 # Make sure AddMembers is always an array
103 ((ref $AddMembersUsers eq 'ARRAY') ? @{$AddMembersUsers} : ($AddMembersUsers)),
104 ((ref $AddMembersGroups eq 'ARRAY') ? @{$AddMembersGroups} : ($AddMembersGroups)),
107 foreach my $member (@AddMembers) {
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);
131 $AddMembersUsers => undef
132 $AddMembersGroups => undef