%# 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 <& /RTFM/Admin/Elements/ClassTabs, id => $id , Title => loc('Modify user rights for class [_1]', $ClassObj->Name) &> <& /Elements/ListActions, actions => \@results &>
<& /Elements/TitleBoxStart, title => loc('Modify user rights for class [_1]', $ClassObj->Name) &> % while (my $Member = $Users->Next()) { % my $UserObj = $Member->MemberObj->Object(); % my $group = RT::Group->new($session{'CurrentUser'}); % $group->LoadACLEquivalenceGroup($Member->MemberObj); % }
<% $UserObj->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; 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::FM::Class') { $obj = RT::FM::Class->new($session{'CurrentUser'}); $obj->Load($object_id); } 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); } } # {{{ Deal with setting up the display of current rights. if (!defined $id) { $m->comp("/RTFM/Elements/Error", Why => loc("No Class defined")); } my $ClassObj = RT::FM::Class->new($session{'CurrentUser'}); $ClassObj->Load($id) || $m->comp("/RTFM/Elements/Error", Why => loc("Couldn't load Class [_1]",$id)); # Find out which users we want to display ACL selects for my $Privileged = RT::Group->new($session{'CurrentUser'}); $Privileged->LoadSystemInternalGroup('Privileged'); my $Users = $Privileged->MembersObj(); # }}} <%ARGS> $id => undef $UserString => undef $UserOp => undef $UserField => undef