%# BEGIN LICENSE BLOCK %# %# Copyright (c) 1996-2002 Jesse Vincent %# %# (Except where explictly superceded by other copyright notices) %# %# This work is made available to you under the terms of Version 2 of %# the GNU General Public License. A copy of that license should have %# been provided with this software, but in any event can be snarfed %# from www.gnu.org %# %# This work is distributed in the hope that it will be useful, but %# WITHOUT ANY WARRANTY; without even the implied warranty of %# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU %# General Public License for more details. %# %# %# Unless otherwise specified, all modifications, corrections or %# extensions to this work which alter its source code become the %# property of Best Practical Solutions, LLC when submitted for %# inclusion in the work. %# %# %# END LICENSE BLOCK <& /Admin/Elements/Header, Title => loc('Modify group rights for Class [_1]', $ClassObj->Name) &> <& /RTFM/Admin/Elements/ClassTabs, id => $id &> <& /Elements/ListActions, actions => \@results &>
<& /Elements/TitleBoxStart, title => loc('Modify group rights for Class [_1]', $ClassObj->Name) &>

<&|/l&>System groups

% $Groups = RT::Groups->new($session{'CurrentUser'}); % $Groups->LimitToSystemInternalGroups(); % while (my $Group = $Groups->Next()) { % }
<% loc($Group->Type) %> <& /Admin/Elements/SelectRights, PrincipalId => $Group->PrincipalId, Object => $ClassObj &>

<&|/l&>User defined groups

% $Groups = RT::Groups->new($session{'CurrentUser'}); % $Groups->LimitToUserDefinedGroups(); % while (my $Group = $Groups->Next()) { % }
<% $Group->Name %> <& /Admin/Elements/SelectRights, PrincipalId => $Group->PrincipalId, Object => $ClassObj &>
<& /Elements/TitleBoxEnd &> <& /Elements/Submit, Caption => loc("Be sure to save your changes"), Reset => 1 &>
<%INIT> #Update the acls. my @results my ( $ACL, @results ); foreach my $arg (keys %ARGS) { if ($arg =~ /GrantRight-(\d+)-(.*?)-(\d+)$/) { my $principal_id = $1; my $object_type = $2; my $object_id = $3; my $rights = $ARGS{$arg}; my $principal = RT::Principal->new($session{'CurrentUser'}); $principal->Load($principal_id); my $obj; if ($object_type eq 'RT::Queue') { $obj = RT::Queue->new($session{'CurrentUser'}); $obj->Load($object_id); } elsif ($object_type eq 'RT::Group') { $obj = RT::Group->new($session{'CurrentUser'}); $obj->Load($object_id); } elsif ($object_type eq 'RT::System') { $obj = $RT::System; } else { push (@results, loc("System Error"). loc("Rights could not be granted for [_1]", $object_type)); next; } my @rights = ref($ARGS{$arg}) eq 'ARRAY' ? @{$ARGS{$arg}} : ($ARGS{$arg}); foreach my $right (@rights) { next unless ($right); my ($val, $msg) = $principal->GrantRight(Object => $obj, Right => $right); push (@results, $msg); } } elsif ($arg =~ /RevokeRight-(\d+)-(.*?)-(\d+)-(.*?)$/) { my $principal_id = $1; my $object_type = $2; my $object_id = $3; my $right = $4; my $principal = RT::Principal->new($session{'CurrentUser'}); $principal->Load($principal_id); next unless ($right); my $obj; if ($object_type eq 'RT::Class') { $obj = RT::Class->new($session{'CurrentUser'}); $obj->Load($object_id); } else { push (@results, loc("System Error"). loc("Rights could not be revoked for [_1]", $object_type)); next; } my ($val, $msg) = $principal->RevokeRight(Object => $obj, Right => $right); push (@results, $msg); } } if (!defined $id) { Abort(loc("No Class defined")); } my $ClassObj = RT::FM::Class->new($session{'CurrentUser'}); $ClassObj->Load($id) || Abort(loc("Couldn't load Class [_1]",$id)); my $Groups; <%ARGS> $id => undef