X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=rt%2Flib%2FRT%2FTransaction_Overlay.pm;h=469cf0872d470a348ba3c56b1c8aa73371a98373;hb=d32f4c43b0fde5c18b8c2ee8f3d4cb9c6861a403;hp=b8ea9389c6bce3da6ca3e6b1482c90727a640a88;hpb=fc6209f398899f0211cfcedeb81a3cd65e04a941;p=freeside.git diff --git a/rt/lib/RT/Transaction_Overlay.pm b/rt/lib/RT/Transaction_Overlay.pm index b8ea9389c..469cf0872 100644 --- a/rt/lib/RT/Transaction_Overlay.pm +++ b/rt/lib/RT/Transaction_Overlay.pm @@ -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 # # # (Except where explicitly superseded by other copyright notices) @@ -110,12 +110,13 @@ sub Create { NewValue => undef, MIMEObj => undef, ActivateScrips => 1, - CommitScrips => 1, - ObjectType => 'RT::Ticket', - ObjectId => 0, - ReferenceType => undef, - OldReference => undef, - NewReference => undef, + CommitScrips => 1, + ObjectType => 'RT::Ticket', + ObjectId => 0, + ReferenceType => undef, + OldReference => undef, + NewReference => undef, + CustomFields => {}, @_ ); @@ -130,21 +131,21 @@ sub Create { #lets create our transaction my %params = ( - Type => $args{'Type'}, - Data => $args{'Data'}, - Field => $args{'Field'}, - OldValue => $args{'OldValue'}, - NewValue => $args{'NewValue'}, - Created => $args{'Created'}, - ObjectType => $args{'ObjectType'}, - ObjectId => $args{'ObjectId'}, + Type => $args{'Type'}, + Data => $args{'Data'}, + Field => $args{'Field'}, + OldValue => $args{'OldValue'}, + NewValue => $args{'NewValue'}, + Created => $args{'Created'}, + ObjectType => $args{'ObjectType'}, + ObjectId => $args{'ObjectId'}, ReferenceType => $args{'ReferenceType'}, - OldReference => $args{'OldReference'}, - NewReference => $args{'NewReference'}, + OldReference => $args{'OldReference'}, + NewReference => $args{'NewReference'}, ); # Parameters passed in during an import that we probably don't want to touch, otherwise - foreach my $attr qw(id Creator Created LastUpdated TimeTaken LastUpdatedBy) { + foreach my $attr (qw(id Creator Created LastUpdated TimeTaken LastUpdatedBy)) { $params{$attr} = $args{$attr} if ($args{$attr}); } @@ -158,6 +159,10 @@ sub Create { } } + # Set up any custom fields passed at creation. Has to happen + # before scrips. + + $self->UpdateCustomFields(%{ $args{'CustomFields'} }); #Provide a way to turn off scrips if we need to $RT::Logger->debug('About to think about scrips for transaction #' .$self->Id); @@ -302,7 +307,7 @@ textual part (as defined in RT::I18N::IsTextualContentType). Otherwise, returns undef. Takes a paramhash. If the $args{'Quote'} parameter is set, wraps this message -at $args{'Wrap'}. $args{'Wrap'} defaults to 70. +at $args{'Wrap'}. $args{'Wrap'} defaults to $RT::MessageBoxWidth - 2 or 70. If $args{'Type'} is set to C, this will return an HTML part of the message, if available. Otherwise it looks for a text/plain @@ -318,6 +323,7 @@ sub Content { Type => $PreferredContentType || '', Quote => 0, Wrap => 70, + Wrap => ( $RT::MessageBoxWidth || 72 ) - 2, @_ ); @@ -364,7 +370,7 @@ sub Content { $max = length if length > $max; } - if ( $max > 76 ) { + if ( $max > $args{'Wrap'}+6 ) { # 76 ) { require Text::Wrapper; my $wrapper = new Text::Wrapper( columns => $args{'Wrap'}, @@ -506,7 +512,7 @@ sub Attachments { $self->{'attachments'} = RT::Attachments->new( $self->CurrentUser ); unless ( $self->CurrentUserCanSee ) { - $self->{'attachments'}->Limit(FIELD => 'id', VALUE => '0'); + $self->{'attachments'}->Limit(FIELD => 'id', VALUE => '0', SUBCLAUSE => 'acl'); return $self->{'attachments'}; } @@ -728,6 +734,7 @@ sub BriefDescription { if ( $self->Field ) { my $cf = RT::CustomField->new( $self->CurrentUser ); + $cf->SetContextObject( $self->Object ); $cf->Load( $self->Field ); $field = $cf->Name(); } @@ -1062,14 +1069,8 @@ sub CurrentUserCanSee { $cf->Load( $cf_id ); return 0 unless $cf->CurrentUserHasRight('SeeCustomField'); } - #if they ain't got rights to see, don't let em - elsif ( $self->__Value('ObjectType') eq "RT::Ticket" ) { - unless ( $self->CurrentUserHasRight('ShowTicket') ) { - return 0; - } - } - - return 1; + # Defer to the object in question + return $self->Object->CurrentUserCanSee("Transaction"); } # }}} @@ -1094,7 +1095,7 @@ sub OldValue { return $Object->Content; } else { - return $self->__Value('OldValue'); + return $self->_Value('OldValue'); } } @@ -1108,7 +1109,7 @@ sub NewValue { return $Object->Content; } else { - return $self->__Value('NewValue'); + return $self->_Value('NewValue'); } } @@ -1162,6 +1163,7 @@ sub UpdateCustomFields { unless ( $arg =~ /^(?:Object-RT::Transaction--)?CustomField-(\d+)/ ); next if $arg =~ /-Magic$/; + next if $arg =~ /-TimeUnits$/; my $cfid = $1; my $values = $args->{$arg}; foreach @@ -1197,6 +1199,7 @@ sub CustomFieldValues { # do we want to cover this situation somehow here? unless ( defined $field && $field =~ /^\d+$/o ) { my $CFs = RT::CustomFields->new( $self->CurrentUser ); + $CFs->SetContextObject( $self->Object ); $CFs->Limit( FIELD => 'Name', VALUE => $field ); $CFs->LimitToLookupType($self->CustomFieldLookupType); $CFs->LimitToGlobalOrObjectId($self->Object->QueueObj->id);