%# BEGIN LICENSE BLOCK %# %# Copyright (c) 2002-2003 Jesse Vincent %# %# This program is free software; you can redistribute it and/or modify %# it under the terms of version 2 of the GNU General Public License %# as published by the Free Software Foundation. %# %# A copy of that license should have arrived with this %# software, but in any event can be snarfed from www.gnu.org. %# %# This program 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. %# %# END LICENSE BLOCK <& /RTFM/Admin/Elements/CustomFieldTabs, id => $id, current_tab => "RTFM/Admin/CustomFields/UserRights.html?id=".$id, Title => loc('Modify group rights for custom field [_1]', $CustomFieldObj->Name) &> <& /Elements/ListActions, actions => \@results &>

<&|/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 => $CustomFieldObj &>

<&|/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 => $CustomFieldObj &>
<& /Elements/Submit, Caption => loc("Be sure to save your changes"), Reset => 1 &>
<%INIT> if (!defined $id) { $m->comp("/RTFM/Elements/Error", Why => loc("No CustomField defined")); } my $CustomFieldObj = RT::FM::CustomField->new($session{'CurrentUser'}); $CustomFieldObj->Load($id) || $m->comp("/RTFM/Elements/Error", Why => loc("Couldn't load CustomField [_1]",$id)); my $Groups; 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::FM::CustomField') { $obj = RT::FM::CustomField->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::FM::CustomField') { $obj = RT::FM::CustomField->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); } } <%ARGS> $id => undef