[Rt-commit] rt branch, 4.4/hide-time-worked, created. rt-4.4.0rc2-2-gba9ee2d

Dustin Graves dustin at bestpractical.com
Thu Dec 3 13:03:43 EST 2015


The branch, 4.4/hide-time-worked has been created
        at  ba9ee2d140f56a3ec74c2a0a4858aad4d895d604 (commit)

- Log -----------------------------------------------------------------
commit ba9ee2d140f56a3ec74c2a0a4858aad4d895d604
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 b89cd2c..35ac0a2 100644
--- a/etc/RT_Config.pm.in
+++ b/etc/RT_Config.pm.in
@@ -1612,6 +1612,16 @@ Set this to 1 to hide unset fields.
 
 Set($HideUnsetFieldsOnDisplay, 0);
 
+=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
 
 
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