[Rt-commit] [svn] r707 - rt/branches/rt-3.3/lib/RT
jesse at pallas.eruditorum.org
jesse at pallas.eruditorum.org
Tue Apr 20 21:21:12 EDT 2004
Author: jesse
Date: Tue Apr 20 21:21:11 2004
New Revision: 707
Modified:
rt/branches/rt-3.3/lib/RT/Attachment_Overlay.pm
rt/branches/rt-3.3/lib/RT/ObjectCustomFieldValue_Overlay.pm
rt/branches/rt-3.3/lib/RT/Record.pm
Log:
Adding support for encoding LOBs for the new custom field behaviour
Modified: rt/branches/rt-3.3/lib/RT/Attachment_Overlay.pm
==============================================================================
--- rt/branches/rt-3.3/lib/RT/Attachment_Overlay.pm (original)
+++ rt/branches/rt-3.3/lib/RT/Attachment_Overlay.pm Tue Apr 20 21:21:11 2004
@@ -212,26 +212,7 @@
sub Content {
my $self = shift;
- my $decode_utf8 = (($self->ContentType eq 'text/plain') ? 1 : 0);
-
- if ( $self->ContentEncoding eq 'none' || ! $self->ContentEncoding ) {
- return $self->_Value(
- 'Content',
- decode_utf8 => $decode_utf8,
- );
- } elsif ( $self->ContentEncoding eq 'base64' ) {
- return ( $decode_utf8
- ? Encode::decode_utf8(MIME::Base64::decode_base64($self->_Value('Content')))
- : MIME::Base64::decode_base64($self->_Value('Content'))
- );
- } elsif ( $self->ContentEncoding eq 'quoted-printable' ) {
- return ( $decode_utf8
- ? Encode::decode_utf8(MIME::QuotedPrint::decode($self->_Value('Content')))
- : MIME::QuotedPrint::decode($self->_Value('Content'))
- );
- } else {
- return( $self->loc("Unknown ContentEncoding [_1]", $self->ContentEncoding));
- }
+ $self->_DecodeLOB($self->ContentType, $self->ContentEncoding, $self->_Value('Content', decode_utf8 => 0));
}
Modified: rt/branches/rt-3.3/lib/RT/ObjectCustomFieldValue_Overlay.pm
==============================================================================
--- rt/branches/rt-3.3/lib/RT/ObjectCustomFieldValue_Overlay.pm (original)
+++ rt/branches/rt-3.3/lib/RT/ObjectCustomFieldValue_Overlay.pm Tue Apr 20 21:21:11 2004
@@ -25,6 +25,45 @@
no warnings qw(redefine);
+sub Create {
+ my $self = shift;
+ my %args = (
+ CustomField => '0',
+ ObjectType => '',
+ ObjectId => '0',
+ Current => '1',
+ Content => '',
+ LargeContent => '',
+ ContentType => '',
+ ContentEncoding => '',
+
+ @_);
+ ($args{'ContentEncoding'}, $args{'LargeContent'}) = $self->_EncodeLOB($args{'LargeContent'}, $args{'ContentType'}) if ($args{'LargeContent'});
+ $self->SUPER::Create(
+ CustomField => $args{'CustomField'},
+ ObjectType => $args{'ObjectType'},
+ ObjectId => $args{'ObjectId'},
+ Current => $args{'Current'},
+ Content => $args{'Content'},
+ LargeContent => $args{'LargeContent'},
+ ContentType => $args{'ContentType'},
+ ContentEncoding => $args{'ContentEncoding'},
+);
+
+
+
+}
+
+
+sub LargeContent {
+ my $self = shift;
+ $self->_DecodeLOB( $self->ContentType, $self->ContentEncoding,
+ $self->_Value( 'LargeContent', decode_utf 8 => 0 ) );
+
+}
+
+
+
=head2 LoadByTicketContentAndCustomField { Ticket => TICKET, CustomField => CUSTOMFIELD, Content => CONTENT }
Modified: rt/branches/rt-3.3/lib/RT/Record.pm
==============================================================================
--- rt/branches/rt-3.3/lib/RT/Record.pm (original)
+++ rt/branches/rt-3.3/lib/RT/Record.pm Tue Apr 20 21:21:11 2004
@@ -676,6 +676,28 @@
}
+sub _DecodeLOB {
+ my $self = shift;
+ my $ContentType = shift;
+ my $ContentEncoding = shift;
+ my $Content = shift;
+
+ if ( $ContentEncoding eq 'base64' ) {
+ $Content = MIME::Base64::decode_base64($Content);
+ }
+ elsif ( $ContentEncoding eq 'quoted-printable' ) {
+ $Content = MIME::QuotedPrint::decode($Content);
+ }
+ elsif ( $ContentEncoding && $ContentEncoding ne 'none' ) {
+ return ( $self->loc( "Unknown ContentEncoding [_1]", $ContentEncoding ) );
+ }
+ if ( $ContentType eq 'text/plain' ) {
+ return Encode::decode_utf8($Content);
+ }
+ else {
+ return ($Content);
+ }
+}
# {{{ LINKDIRMAP
# A helper table for relationships mapping to make it easier
More information about the Rt-commit
mailing list