[rt-users] Hide standard fields from some users?
Torsten Brumm
torsten.brumm at googlemail.com
Thu Apr 1 04:55:34 EDT 2010
If you like to a clean version try something like this:
1. MyTineRightsAddOn.pm
---------------------------------------------
package RT::Extension::MyTinyRightsAddOn;
our $VERSION = '0.01';
use warnings;
use strict;
use RT::System;
my %rights = (
ViewSomeMenuItems => 'View some Menu Items', #loc_pair
);
$RT::System::RIGHTS = { %$RT::System::RIGHTS, %rights };
%RT::ACE::LOWERCASERIGHTNAMES = ( %RT::ACE::LOWERCASERIGHTNAMES,
map { lc($_) => $_ } keys %rights);
1;
------------------------------------------------------------
Inside the module you like to check do something like this:
% if ( $Ticket->CurrentUserHasRight('ViewSomeMenuItems') ) {
% }
Example: from EditBasics (share/html/Ticket/Elements/EditBasics)
moved to local/html/Ticket/Elements/EditBasics or better create a
"real" RT Modul with this..
<table>
<tr>
<td class="label"><&|/l&>Subject</&>:</td>
<td class="value"><input name="Subject"
value="<%$TicketObj->Subject|h%>" size="50" /></td>
</tr>
% if ( $Ticket->CurrentUserHasRight('ViewSomeMenuItems') ) {
<tr>
<td class="label"><&|/l&>Status</&>:</td>
<td class="value"><%$SelectStatus|n%></td>
</tr>
}
<tr>
<td class="label"><&|/l&>Queue</&>:</td>
<td class="value"><%$SelectQueue|n%></td>
</tr>
<tr>
<td class="label"><&|/l&>Owner</&>:</td>
<td class="value"><& /Elements/SelectOwner,
Name => 'Owner',
QueueObj => $TicketObj->QueueObj,
TicketObj => $TicketObj,
Default => $TicketObj->OwnerObj->Id,
DefaultValue => 0,
&></td>
</tr>
<tr>
<td class="label"><&|/l&>Time Estimated</&>:</td>
<td class="value">
<& /Elements/EditTimeValue,
Name => 'TimeEstimated',
Default => $TicketObj->TimeEstimated,
&>
</td>
</tr>
<tr>
<td class="label"><&|/l&>Time Worked</&>:</td>
<td class="value">
<& /Elements/EditTimeValue,
Name => 'TimeWorked',
Default => $TicketObj->TimeWorked,
&>
</td>
</tr>
<tr>
<td class="label"><&|/l&>Time Left</&>:</td>
<td class="value">
<& /Elements/EditTimeValue,
Name => 'TimeLeft',
Default => $TicketObj->TimeLeft,
&>
</td>
</tr>
<tr>
<td class="label"><&|/l&>Priority</&>:</td>
<td class="value"><& /Elements/SelectPriority,
Default => $TicketObj->Priority,
&></td>
</tr>
<tr>
<td class="label"><&|/l&>Final Priority</&>:</td>
<td class="value"><& /Elements/SelectPriority,
Name => "FinalPriority",
Default => $TicketObj->FinalPriority,
&></td>
</tr>
% $m->callback( CallbackName => 'EndOfList', TicketObj => $TicketObj, %ARGS );
</table>
<%INIT>
#It's hard to do this inline, so we'll preload the html of the
selectstatus in here.
my $SelectStatus = $m->scomp("/Elements/SelectStatus", Name =>
'Status', DefaultLabel => loc("[_1]
(Unchanged)",loc($TicketObj->Status)));
my $SelectQueue = $m->scomp("/Elements/SelectQueue", Name => 'Queue',
Default =>$TicketObj->QueueObj->Id, ShowNullOption => 0);
</%INIT>
<%ARGS>
$TicketObj => undef
</%ARGS>
another, less complex but performance suboptimal version you can find
on the wiki: http://wiki.bestpractical.com/view/GroupMembershipCheck
Let's assume again you like to change the EditBasics file:
% my $GroupObj = RT::Group->new( $session{ 'CurrentUser' } );
% my $PrincipalObj = RT::Principal->new( $session{ 'CurrentUser' } );
% $PrincipalObj->Load( $session{ 'CurrentUser' }->id );
% $GroupObj->LoadUserDefinedGroup(
'NameOfTheGroupYouLikeToGrantAccessToTheMenuItem' );
% my $HasMember = $GroupObj->HasMemberRecursively( $PrincipalObj );
<table>
<tr>
<td class="label"><&|/l&>Subject</&>:</td>
<td class="value"><input name="Subject"
value="<%$TicketObj->Subject|h%>" size="50" /></td>
</tr>
% if ( $HasMember ) {
<tr>
<td class="label"><&|/l&>Status</&>:</td>
<td class="value"><%$SelectStatus|n%></td>
</tr>
}
<tr>
<td class="label"><&|/l&>Queue</&>:</td>
<td class="value"><%$SelectQueue|n%></td>
</tr>
<tr>
<td class="label"><&|/l&>Owner</&>:</td>
<td class="value"><& /Elements/SelectOwner,
Name => 'Owner',
QueueObj => $TicketObj->QueueObj,
TicketObj => $TicketObj,
Default => $TicketObj->OwnerObj->Id,
DefaultValue => 0,
&></td>
</tr>
<tr>
<td class="label"><&|/l&>Time Estimated</&>:</td>
<td class="value">
<& /Elements/EditTimeValue,
Name => 'TimeEstimated',
Default => $TicketObj->TimeEstimated,
&>
</td>
</tr>
<tr>
<td class="label"><&|/l&>Time Worked</&>:</td>
<td class="value">
<& /Elements/EditTimeValue,
Name => 'TimeWorked',
Default => $TicketObj->TimeWorked,
&>
</td>
</tr>
<tr>
<td class="label"><&|/l&>Time Left</&>:</td>
<td class="value">
<& /Elements/EditTimeValue,
Name => 'TimeLeft',
Default => $TicketObj->TimeLeft,
&>
</td>
</tr>
<tr>
<td class="label"><&|/l&>Priority</&>:</td>
<td class="value"><& /Elements/SelectPriority,
Default => $TicketObj->Priority,
&></td>
</tr>
<tr>
<td class="label"><&|/l&>Final Priority</&>:</td>
<td class="value"><& /Elements/SelectPriority,
Name => "FinalPriority",
Default => $TicketObj->FinalPriority,
&></td>
</tr>
% $m->callback( CallbackName => 'EndOfList', TicketObj => $TicketObj, %ARGS );
</table>
<%INIT>
#It's hard to do this inline, so we'll preload the html of the
selectstatus in here.
my $SelectStatus = $m->scomp("/Elements/SelectStatus", Name =>
'Status', DefaultLabel => loc("[_1]
(Unchanged)",loc($TicketObj->Status)));
my $SelectQueue = $m->scomp("/Elements/SelectQueue", Name => 'Queue',
Default =>$TicketObj->QueueObj->Id, ShowNullOption => 0);
</%INIT>
<%ARGS>
$TicketObj => undef
</%ARGS>
2010/3/31 Jeff Blaine <jblaine at kickflop.net>:
> We have a need to hide (ideally) certain standard RT fields
> from privileged users.
>
> I don't see that this is possible with the standard rights
> controls.
>
> Is that accurate?
>
> Discover RT's hidden secrets with RT Essentials from O'Reilly Media.
> Buy a copy at http://rtbook.bestpractical.com
>
--
MFG
Torsten Brumm
http://www.brumm.me
http://www.elektrofeld.de
More information about the rt-users
mailing list