rt 4.2.13 ticket#13852
[freeside.git] / rt / share / html / m / ticket / show
index 4190bd3..90513bc 100644 (file)
@@ -1,3 +1,50 @@
+%# BEGIN BPS TAGGED BLOCK {{{
+%#
+%# COPYRIGHT:
+%#
+%# This software is Copyright (c) 1996-2016 Best Practical Solutions, LLC
+%#                                          <sales@bestpractical.com>
+%#
+%# (Except where explicitly superseded by other copyright notices)
+%#
+%#
+%# LICENSE:
+%#
+%# 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.
+%#
+%# You should have received a copy of the GNU General Public License
+%# along with this program; if not, write to the Free Software
+%# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+%# 02110-1301 or visit their web page on the internet at
+%# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html.
+%#
+%#
+%# CONTRIBUTION SUBMISSION POLICY:
+%#
+%# (The following paragraph is not intended to limit the rights granted
+%# to you to modify and distribute this software under the terms of
+%# the GNU General Public License and is only of importance to you if
+%# you choose to contribute your changes and enhancements to the
+%# community by submitting them to Best Practical Solutions, LLC.)
+%#
+%# By intentionally submitting any modifications, corrections or
+%# derivatives to this work, or any other work intended for use with
+%# Request Tracker, to Best Practical Solutions, LLC, you confirm that
+%# you are the copyright holder for those contributions and you grant
+%# Best Practical Solutions,  LLC a nonexclusive, worldwide, irrevocable,
+%# royalty-free, perpetual, license to use, copy, create derivative
+%# works based on those contributions, and sublicense and distribute
+%# those contributions and any derivatives thereof.
+%#
+%# END BPS TAGGED BLOCK }}}
 <%args>
 $id => undef
 </%args>
@@ -12,7 +59,7 @@ unless ($id) {
 if ($ARGS{'id'} eq 'new') {
     # {{{ Create a new ticket
 
-    my $Queue = new RT::Queue( $session{'CurrentUser'} );
+    my $Queue = RT::Queue->new( $session{'CurrentUser'} );
     $Queue->Load($ARGS{'Queue'});
     unless ( $Queue->id ) {
         Abort('Queue not found');
@@ -22,14 +69,10 @@ if ($ARGS{'id'} eq 'new') {
         Abort('You have no permission to create tickets in that queue.');
     }
 
-    ($Ticket, @Actions) = CreateTicket(
-        Attachments => delete $session{'Attachments'},
-        %ARGS,
-    );
+    ($Ticket, @Actions) = CreateTicket( %ARGS );
     unless ( $Ticket->CurrentUserHasRight('ShowTicket') ) {
         Abort("No permission to view newly created ticket #".$Ticket->id.".");
     }
-    # }}}
 } else { 
     $Ticket ||= LoadTicket($ARGS{'id'});
 
@@ -37,7 +80,7 @@ if ($ARGS{'id'} eq 'new') {
         TicketObj => $Ticket,
         ActionsRef => \@Actions, ARGSRef => \%ARGS );
     if ( defined $ARGS{'Action'} ) {
-        if ($ARGS{'Action'} =~ /^(Steal|Kill|Take|SetTold)$/) {
+        if ($ARGS{'Action'} =~ /^(Steal|Delete|Take|SetTold)$/) {
             my $action = $1;
             my ($res, $msg) = $Ticket->$action();
             push(@Actions, $msg);
@@ -49,14 +92,12 @@ if ($ARGS{'id'} eq 'new') {
             ARGSRef => \%ARGS, 
             Actions => \@Actions);
     
-    $ARGS{UpdateAttachments} = $session{'Attachments'};
     push @Actions,
         ProcessUpdateMessage(
         ARGSRef   => \%ARGS,
         Actions   => \@Actions,
         TicketObj => $Ticket,
         );
-    delete $session{'Attachments'};
 
     #Process status updates
     push @Actions, ProcessTicketWatchers(ARGSRef => \%ARGS, TicketObj => $Ticket );
@@ -64,11 +105,14 @@ if ($ARGS{'id'} eq 'new') {
     push @Actions, ProcessTicketLinks(   ARGSRef => \%ARGS, TicketObj => $Ticket );
     push @Actions, ProcessTicketDates(   ARGSRef => \%ARGS, TicketObj => $Ticket );
     push @Actions, ProcessObjectCustomFieldUpdates(ARGSRef => \%ARGS, TicketObj => $Ticket );
+    push @Actions, ProcessTicketReminders( ARGSRef => \%ARGS, TicketObj => $Ticket );
 
-    # XXX: we shouldn't block actions here if user has no right to see the ticket,
-    # but we should allow him to see actions he has done
     unless ($Ticket->CurrentUserHasRight('ShowTicket')) {
-        Abort("No permission to view ticket");
+        if (@Actions) {
+            Abort("A change was applied successfully, but you no longer have permissions to view the ticket", Actions => \@Actions);
+        } else {
+            Abort("No permission to view ticket");
+        }
     }
     if ( $ARGS{'MarkAsSeen'} ) {
         $Ticket->SetAttribute(
@@ -103,7 +147,7 @@ if (@Actions) {
 
 # If we haven't been passed in an Attachments object (through the precaching mechanism)
 # then we need to find one
-my $Attachments = $m->comp('/Ticket/Elements/FindAttachments', Ticket => $Ticket);
+my $Attachments = $Ticket->Attachments;
 
 my %documents;
 while ( my $attach = $Attachments->Next() ) {
@@ -111,12 +155,6 @@ while ( my $attach = $Attachments->Next() ) {
    unshift( @{ $documents{ $attach->Filename } }, $attach );
 }
 
-my $Customers = $Ticket->Customers;
-my @customers;
-while ( my $customer = $Customers->Next() ) {
-  push @customers, $customer;
-}
-
 my $CustomFields = $Ticket->CustomFields;
 $m->callback(
     CallbackName => 'MassageCustomFields',
@@ -129,7 +167,7 @@ my $print_value = sub {
     my $linked = $value->LinkValueTo;
     if ( defined $linked && length $linked ) {
         my $linked = $m->interp->apply_escapes( $linked, 'h' );
-        $m->out('<a href="'. $linked .'" target="_new">');
+        $m->out('<a href="'. $linked .'" target="_blank">');
     }
     my $comp = "ShowCustomField". $cf->Type;
     $m->callback(
@@ -161,7 +199,7 @@ my $print_value = sub {
 };
 
 </%init>
-<&| /m/_elements/wrapper, title => $Ticket->Subject &>
+<&| /m/_elements/wrapper, title => loc("#[_1]: [_2]", $Ticket->Id, $Ticket->Subject || '') &>
 <div id="ticket-show">
 <& /m/_elements/ticket_menu, ticket => $Ticket &>
 
@@ -204,9 +242,13 @@ my $print_value = sub {
     <div class="label queue"><&|/l&>Queue</&>:</div>
     <div class="value queue"><& /Ticket/Elements/ShowQueue, QueueObj => $Ticket->QueueObj &></div>
   </div>
+ <div class="entry">
+    <div class="label bookmark"><&|/l&>Bookmark</&>:</div>
+    <div class="value bookmark"><& /Ticket/Elements/Bookmark, id => $Ticket->id &></div>
+  </div>
     </&>
 
-% if ($Ticket->CustomFields->First) {
+% if ($CustomFields->Count) {
     <&| /Widgets/TitleBox, title => loc('Custom Fields'),
         class => 'ticket-info-cfs',
     &>
@@ -242,20 +284,20 @@ my $print_value = sub {
 
  <div class="entry">
     <div class="label"><&|/l&>Owner</&>:</div>
-    <div class="value"><& /Elements/ShowUser, User => $Ticket->OwnerObj, Ticket => $Ticket &>
+    <div class="value"><& /Elements/ShowUser, User => $Ticket->OwnerObj, Ticket => $Ticket, Link => 0 &>
     </div>
   </div>
  <div class="entry">
     <div class="label"><&|/l&>Requestors</&>:</div>
-    <div class="value"><& /Ticket/Elements/ShowGroupMembers, Group => $Ticket->Requestors, Ticket => $Ticket &></div>
+    <div class="value"><& /Ticket/Elements/ShowGroupMembers, Group => $Ticket->Requestors, Ticket => $Ticket, Link => 0 &></div>
   </div>
  <div class="entry">
     <div class="label"><&|/l&>Cc</&>:</div>
-    <div class="value"><& /Ticket/Elements/ShowGroupMembers, Group => $Ticket->Cc, Ticket => $Ticket &></div>
+    <div class="value"><& /Ticket/Elements/ShowGroupMembers, Group => $Ticket->Cc, Ticket => $Ticket, Link => 0 &></div>
   </div>
  <div class="entry">
     <div class="label"><&|/l&>AdminCc</&>:</div>
-    <div class="value"><& /Ticket/Elements/ShowGroupMembers, Group => $Ticket->AdminCc, Ticket => $Ticket &></div>
+    <div class="value"><& /Ticket/Elements/ShowGroupMembers, Group => $Ticket->AdminCc, Ticket => $Ticket, Link => 0 &></div>
   </div>
 
     </&>
@@ -271,34 +313,10 @@ my $print_value = sub {
 <%$key%><br />
 <ul>
 % foreach my $rev (@{$documents{$key}}) {
-
-<%PERL>
-my $size = $rev->ContentLength;
-
-if ($size) {
-    my $kb = int($size/102.4) / 10;
-    my $units = RT->Config->Get('AttachmentUnits');
-
-    if (!defined($units)) {
-        if ($size > 1024) {
-            $size = $kb . "k";
-        }
-        else {
-            $size = $size . "b";
-        }
-    }
-    elsif ($units eq 'k') {
-        $size = $kb . "k";
-    }
-    else {
-        $size = $size . "b";
-    }
-
-</%PERL>
-
+% if ($rev->ContentLength) {
 <li><font size="-2">
-<a href="<%RT->Config->Get('WebPath')%>/Ticket/Attachment/<%$rev->TransactionId%>/<%$rev->Id%>/<%$rev->Filename | u%>">
-<&|/l, $rev->CreatedAsString, $size, $rev->CreatorObj->Name &>[_1] ([_2]) by [_3]</&>
+<a href="<%RT->Config->Get('WebPath')%>/Ticket/Attachment/<%$rev->TransactionId%>/<%$rev->Id%>/<%$rev->Filename | u%>">
+<&|/l, $rev->CreatedAsString, $rev->FriendlyContentLength, $rev->CreatorObj->Name &>[_1] ([_2]) by [_3]</&>
 </a>
 </font></li>
 % }
@@ -323,19 +341,6 @@ if ($size) {
     </&>
 % }
 
-% if ( @customers ) {
-    <&| /Widgets/TitleBox, title => loc("Customers"),
-        class => 'ticket-info-customers',
-    &>
-%   foreach my $customer ( @customers ) {
-%     my $resolver = $customer->TargetURI->Resolver or next;
-<div class="entry"><a href="<% $resolver->HREF %>"><% $resolver->AsString |n%></A>
-</div>
-%   } #foreach
-    </&>
-% } # if @customers
-
-
     <&| /Widgets/TitleBox, title => loc("Dates"),
         class => 'ticket-info-dates',
     &>
@@ -360,7 +365,7 @@ if ($size) {
  <div class="entry">
     <div class="label date due"><&|/l&>Due</&>:</div>
 % my $due = $Ticket->DueObj;
-% if ( $due && $due->Unix > 0 && $due->Diff < 0 ) {
+% if ( $due && $due->IsSet && $due->Diff < 0 && $Ticket->QueueObj->IsActiveStatus($Ticket->Status) ) {
     <div class="value date due"><span class="overdue"><% $due->AsString  %></span></div>
 % } else {
     <div class="value date due"><% $due->AsString  %></div>
@@ -422,11 +427,11 @@ for my $link ( @{ $Ticket->DependsOn->ItemsArrayRef } ) {
   </div>
  <div class="entry">
     <div class="label"><% loc('Parents') %>:</div>
-    <div class="value"><& /Ticket/Elements/ShowParents, Ticket => $Ticket &></div>
+    <div class="value"><& /Elements/ShowLinksOfType, Object => $Ticket, Type => 'MemberOf' &></div>
   </div>
  <div class="entry">
     <div class="label"><% loc('Children')%>:</div>
-    <div class="value"><& /Ticket/Elements/ShowMembers, Ticket => $Ticket &></div>
+    <div class="value"><& /Elements/ShowLinksOfType, Object => $Ticket, Type => 'Members' &></div>
   </div>
  <div class="entry">
     <div class="label"><% loc('Refers to')%>:</div>
@@ -443,7 +448,7 @@ for my $link ( @{ $Ticket->DependsOn->ItemsArrayRef } ) {
     <div class="value">
     <ul>
 % while (my $Link = $Ticket->ReferredToBy->Next) {
-% next if (UNIVERSAL::isa($Link->BaseObj, 'RT::Ticket')  && $Link->BaseObj->Type eq 'reminder');
+% next if (UNIVERSAL::isa($Link->BaseObj, 'RT::Ticket')  && $Link->BaseObj->__Value('Type') eq 'reminder');
 <li><& /Elements/ShowLink, URI => $Link->BaseURI &></li>
 % }
 </ul>