[Rt-commit] rt branch, 4.4/hide-time-worked, created. rt-4.2.12-506-g8bf5da9
Dustin Graves
dustin at bestpractical.com
Tue Dec 1 13:44:18 EST 2015
The branch, 4.4/hide-time-worked has been created
at 8bf5da95e570db1a3fb9a68f06f0786df7f28585 (commit)
- Log -----------------------------------------------------------------
commit 8bf5da95e570db1a3fb9a68f06f0786df7f28585
Author: Dustin Graves <dustin at bestpractical.com>
Date: Fri Nov 20 21:54:31 2015 +0000
add config HideTimeWorkedForUnprivilegedUsers to hide time worked, estimated, and left for unprivileged users
Fixes: I#31302
diff --git a/etc/RT_Config.pm.in b/etc/RT_Config.pm.in
index 1f9e0d0..b14a6bf 100644
--- a/etc/RT_Config.pm.in
+++ b/etc/RT_Config.pm.in
@@ -1614,6 +1614,18 @@ Set($HideUnsetFieldsOnDisplay, 0);
=back
+=item C<$HideTimeFieldsFromUnprivilegedUsers>
+
+This determines if we should hide Time Worked, Time Estimated, and
+Time Left for unprivileged users.
+Set this to 1 to hide those fields.
+
+=cut
+
+Set($HideTimeFieldsFromUnprivilegedUsers, 0);
+
+=back
+
=head2 Articles
diff --git a/lib/RT/Ticket.pm b/lib/RT/Ticket.pm
index e7df03c..a786a83 100644
--- a/lib/RT/Ticket.pm
+++ b/lib/RT/Ticket.pm
@@ -3026,6 +3026,19 @@ sub Forward {
return ( $ret, $self->loc('Message recorded') );
}
+=head2 CurrentUserCanSeeTime
+
+Returns true if the current user can see time worked, estimated, left
+
+=cut
+
+sub CurrentUserCanSeeTime {
+ my $self = shift;
+
+ return $self->CurrentUser->Privileged ||
+ !RT->Config->Get('HideTimeFieldsFromUnprivilegedUsers');
+}
+
1;
=head1 AUTHOR
diff --git a/share/html/Elements/ShowHistoryPage b/share/html/Elements/ShowHistoryPage
index 884553c..8420289 100644
--- a/share/html/Elements/ShowHistoryPage
+++ b/share/html/Elements/ShowHistoryPage
@@ -115,6 +115,12 @@ while ( my $Transaction = $Transactions->Next ) {
and $Object->RoleGroup( $Transaction->Field )->SingleMemberRoleGroupColumn;
}
+ # Skip Time Worked fields if user is unprivileged and
+ # HideTimeWorkedForUnprivilegedUsers is set.
+ $skip = 1 if $Object->isa("RT::Ticket") and
+ not $Object->CurrentUserCanSeeTime and
+ ($Transaction->Field || '') =~ /^(?:TimeEstimated|Worked|TimeLeft)$/;
+
$m->callback(
%ARGS,
Transaction => $Transaction,
diff --git a/share/html/Ticket/Elements/ShowBasics b/share/html/Ticket/Elements/ShowBasics
index 2fc4098..ad023c6 100644
--- a/share/html/Ticket/Elements/ShowBasics
+++ b/share/html/Ticket/Elements/ShowBasics
@@ -60,6 +60,7 @@
<td class="value"><% loc($Ticket->SLA) %></td>
</tr>
% }
+% if ($show_time_worked) {
% if ($Ticket->TimeEstimated) {
<tr class="time estimated">
<td class="label"><&|/l&>Estimated</&>:</td>
@@ -95,6 +96,7 @@
<td class="value"><& ShowTime, minutes => $Ticket->TimeLeft &></td>
</tr>
% }
+% }
% $m->callback( %ARGS, CallbackName => 'AfterTimeLeft', TicketObj => $Ticket );
<tr class="priority">
<td class="label"><&|/l&>Priority</&>:</td>
@@ -122,7 +124,8 @@ $UngroupedCFs => 0
</%ARGS>
<%init>
my $time_worked;
-if ( $Ticket->TimeWorked ) {
+my $show_time_worked = $Ticket->CurrentUserCanSeeTime;
+if ( $show_time_worked && $Ticket->TimeWorked ) {
my $time_worked_attr = $Ticket->FirstAttribute('TimeWorked');
if ($time_worked_attr) {
-----------------------------------------------------------------------
More information about the rt-commit
mailing list