X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=rt%2Flib%2FRT%2FRecord.pm;h=121c08686181382fb72bb1213ac3e03f186d372a;hb=3e3a07a1f96d0e2f89cde0a33583c9b1276471f1;hp=9ecad765b6a06da9d1b2dd08522b8c171cbb1411;hpb=e70abd21bab68b23488f7ef1ee2e693a3b365691;p=freeside.git diff --git a/rt/lib/RT/Record.pm b/rt/lib/RT/Record.pm index 9ecad765b..121c08686 100755 --- a/rt/lib/RT/Record.pm +++ b/rt/lib/RT/Record.pm @@ -1,40 +1,40 @@ # BEGIN BPS TAGGED BLOCK {{{ -# +# # COPYRIGHT: -# -# This software is Copyright (c) 1996-2009 Best Practical Solutions, LLC -# -# +# +# This software is Copyright (c) 1996-2011 Best Practical Solutions, LLC +# +# # (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 @@ -43,7 +43,7 @@ # 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 }}} =head1 NAME @@ -67,6 +67,7 @@ use strict; use warnings; use RT::Date; +use RT::I18N; use RT::User; use RT::Attributes; use Encode qw(); @@ -723,7 +724,7 @@ Takes a potentially large attachment. Returns (ContentEncoding, EncodedBody) bas sub _EncodeLOB { my $self = shift; my $Body = shift; - my $MIMEType = shift; + my $MIMEType = shift || ''; my $ContentEncoding = 'none'; @@ -803,6 +804,7 @@ sub _DecodeLOB { elsif ( $ContentEncoding && $ContentEncoding ne 'none' ) { return ( $self->loc( "Unknown ContentEncoding [_1]", $ContentEncoding ) ); } + if ( RT::I18N::IsTextualContentType($ContentType) ) { $Content = Encode::decode_utf8($Content) unless Encode::is_utf8($Content); } @@ -1171,8 +1173,37 @@ sub DependsOn { # }}} +# {{{ Customers + +=head2 Customers + This returns an RT::Links object which references all the customers that this object is a member of. + +=cut +sub Customers { + my( $self, %opt ) = @_; + my $Debug = $opt{'Debug'}; + + unless ( $self->{'Customers'} ) { + + $self->{'Customers'} = $self->MemberOf->Clone; + + $self->{'Customers'}->Limit( + FIELD => 'Target', + OPERATOR => 'STARTSWITH', + VALUE => 'freeside://freeside/cust_main/', + ); + } + + warn "->Customers method called on $self; returning ". + ref($self->{'Customers'}). ' object' + if $Debug; + + return $self->{'Customers'}; +} + +# }}} # {{{ sub _Links @@ -1436,6 +1467,7 @@ sub _NewTransaction { MIMEObj => undef, ActivateScrips => 1, CommitScrips => 1, + CustomFields => {}, @_ ); @@ -1469,6 +1501,7 @@ sub _NewTransaction { MIMEObj => $args{'MIMEObj'}, ActivateScrips => $args{'ActivateScrips'}, CommitScrips => $args{'CommitScrips'}, + CustomFields => $args{'CustomFields'}, ); # Rationalize the object since we may have done things to it during the caching. @@ -1713,6 +1746,25 @@ sub _AddCustomFieldValue { } my $new_content = $new_value->Content; + + # For date, we need to display them in "human" format in result message + if ($cf->Type eq 'Date') { + my $DateObj = new RT::Date( $self->CurrentUser ); + $DateObj->Set( + Format => 'ISO', + Value => $new_content, + ); + $new_content = $DateObj->AsString; + + if ( defined $old_content && length $old_content ) { + $DateObj->Set( + Format => 'ISO', + Value => $old_content, + ); + $old_content = $DateObj->AsString; + } + } + unless ( defined $old_content && length $old_content ) { return ( $new_value_id, $self->loc( "[_1] [_2] added", $cf->Name, $new_content )); } @@ -1801,11 +1853,21 @@ sub DeleteCustomFieldValue { return ( 0, $self->loc( "Couldn't create a transaction: [_1]", $Msg ) ); } + my $old_value = $TransactionObj->OldValue; + # For date, we need to display them in "human" format in result message + if ( $cf->Type eq 'Date' ) { + my $DateObj = new RT::Date( $self->CurrentUser ); + $DateObj->Set( + Format => 'ISO', + Value => $old_value, + ); + $old_value = $DateObj->AsString; + } return ( $TransactionId, $self->loc( "[_1] is no longer a value for custom field [_2]", - $TransactionObj->OldValue, $cf->Name + $old_value, $cf->Name ) ); } @@ -1926,9 +1988,6 @@ sub WikiBase { return RT->Config->Get('WebPath'). "/index.html?q="; } -eval "require RT::Record_Vendor"; -die $@ if ($@ && $@ !~ qr{^Can't locate RT/Record_Vendor.pm}); -eval "require RT::Record_Local"; -die $@ if ($@ && $@ !~ qr{^Can't locate RT/Record_Local.pm}); +RT::Base->_ImportOverlays(); 1;