fix daily sales/credits/receipts summary vs DST boundaries, RT#26199
[freeside.git] / rt / lib / RT / Ticket_Overlay.pm
index e8cb128..64cf2e7 100644 (file)
@@ -2,7 +2,7 @@
 #
 # COPYRIGHT:
 #
-# This software is Copyright (c) 1996-2011 Best Practical Solutions, LLC
+# This software is Copyright (c) 1996-2013 Best Practical Solutions, LLC
 #                                          <sales@bestpractical.com>
 #
 # (Except where explicitly superseded by other copyright notices)
@@ -451,6 +451,8 @@ sub Create {
         }
     }
 
+    $args{'Subject'} =~ s/\n//g;
+
     $RT::Handle->BeginTransaction();
 
     my %params = (
@@ -1305,7 +1307,7 @@ sub DeleteWatcher {
             }
         }
         else {
-            $RT::Logger->warn("$self -> DeleteWatcher got passed a bogus type");
+            $RT::Logger->warning("$self -> DeleteWatcher got passed a bogus type");
             return ( 0,
                      $self->loc('Error in parameters to Ticket->DeleteWatcher') );
         }
@@ -1861,6 +1863,13 @@ sub QueueObj {
     return ($queue_obj);
 }
 
+sub SetSubject {
+    my $self = shift;
+    my $value = shift;
+    $value =~ s/\n//g;
+    return $self->_Set( Field => 'Subject', Value => $value );
+}
+
 # }}}
 
 # }}}
@@ -2311,31 +2320,23 @@ sub _Links {
     my $links = $self->{ $cache_key }
               = RT::Links->new( $self->CurrentUser );
     unless ( $self->CurrentUserHasRight('ShowTicket') ) {
-        $links->Limit( FIELD => 'id', VALUE => 0 );
+        $links->Limit( FIELD => 'id', VALUE => 0, SUBCLAUSE => 'acl' );
         return $links;
     }
 
-    # without this you will also get RT::User(s) instead of tickets!
-    if ($field == 'Base' and $type == 'MemberOf') {
-        my $rtname = RT->Config->Get('rtname');
-        $links->Limit(
-                       FIELD    => 'Base',
-                       OPERATOR => 'STARTSWITH',
-                       VALUE    => "fsck.com-rt://$rtname/ticket/",
-                     );
-    }
-
     # Maybe this ticket is a merge ticket
-    my $limit_on = 'Local'. $field;
+    #my $limit_on = 'Local'. $field;
     # at least to myself
     $links->Limit(
-        FIELD           => $limit_on,
-        VALUE           => $self->id,
+        FIELD           => $field, #$limit_on,
+        OPERATOR        => 'MATCHES',
+        VALUE           => 'fsck.com-rt://%/ticket/'. $self->id,
         ENTRYAGGREGATOR => 'OR',
     );
     $links->Limit(
-        FIELD           => $limit_on,
-        VALUE           => $_,
+        FIELD           => $field, #$limit_on,
+        OPERATOR        => 'MATCHES',
+        VALUE           => 'fsck.com-rt://%/ticket/'. $_,
         ENTRYAGGREGATOR => 'OR',
     ) foreach $self->Merged;
     $links->Limit(
@@ -3547,6 +3548,17 @@ sub CurrentUserHasRight {
 
 # }}}
 
+=head2 CurrentUserCanSee
+
+Returns true if the current user can see the ticket, using ShowTicket
+
+=cut
+
+sub CurrentUserCanSee {
+    my $self = shift;
+    return $self->CurrentUserHasRight('ShowTicket');
+}
+
 # {{{ sub HasRight 
 
 =head2 HasRight
@@ -3665,7 +3677,9 @@ sub Transactions {
 
 sub TransactionCustomFields {
     my $self = shift;
-    return $self->QueueObj->TicketTransactionCustomFields;
+    my $cfs = $self->QueueObj->TicketTransactionCustomFields;
+    $cfs->SetContextObject( $self );
+    return $cfs;
 }
 
 # }}}