summaryrefslogtreecommitdiff
path: root/rt/lib/RT/Transaction_Overlay.pm
diff options
context:
space:
mode:
Diffstat (limited to 'rt/lib/RT/Transaction_Overlay.pm')
-rw-r--r--rt/lib/RT/Transaction_Overlay.pm107
1 files changed, 38 insertions, 69 deletions
diff --git a/rt/lib/RT/Transaction_Overlay.pm b/rt/lib/RT/Transaction_Overlay.pm
index b8ea9389c..e51e5b50d 100644
--- a/rt/lib/RT/Transaction_Overlay.pm
+++ b/rt/lib/RT/Transaction_Overlay.pm
@@ -1,40 +1,40 @@
# BEGIN BPS TAGGED BLOCK {{{
-#
+#
# COPYRIGHT:
-#
-# This software is Copyright (c) 1996-2011 Best Practical Solutions, LLC
-# <sales@bestpractical.com>
-#
+#
+# This software is Copyright (c) 1996-2009 Best Practical Solutions, LLC
+# <jesse@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
@@ -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
@@ -176,7 +176,7 @@ sub Create {
# Entry point of the rule system
my $ticket = RT::Ticket->new($RT::SystemUser);
$ticket->Load($args{'ObjectId'});
- my $rules = $self->{rules} = RT::Ruleset->FindAllRules(
+ my $rules = RT::Ruleset->FindAllRules(
Stage => 'TransactionCreate',
Type => $args{'Type'},
TicketObj => $ticket,
@@ -211,22 +211,6 @@ sub Scrips {
}
-=head2 Rules
-
-Returns the array of Rule objects for this transaction.
-This routine is only useful on a freshly created transaction object.
-Rules do not get persisted to the database with transactions.
-
-
-=cut
-
-
-sub Rules {
- my $self = shift;
- return($self->{'rules'});
-}
-
-
# {{{ sub Delete
=head2 Delete
@@ -302,29 +286,28 @@ 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<text/html>, this will return an HTML
part of the message, if available. Otherwise it looks for a text/plain
part. If $args{'Type'} is missing, it defaults to the value of
C<$RT::Transaction::PreferredContentType>, if that's missing too,
-defaults to textual.
+defaults to 'text/plain'.
=cut
sub Content {
my $self = shift;
my %args = (
- Type => $PreferredContentType || '',
+ Type => $PreferredContentType || 'text/plain',
Quote => 0,
Wrap => 70,
+ Wrap => ( $RT::MessageBoxWidth || 72 ) - 2,
@_
);
my $content;
- if ( my $content_obj =
- $self->ContentObj( $args{Type} ? ( Type => $args{Type} ) : () ) )
- {
+ if ( my $content_obj = $self->ContentObj( Type => $args{Type} ) ) {
$content = $content_obj->Content ||'';
if ( lc $content_obj->ContentType eq 'text/html' ) {
@@ -364,7 +347,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'},
@@ -415,16 +398,12 @@ Returns the RT::Attachment object which contains the content for this Transactio
sub ContentObj {
my $self = shift;
- my %args = ( Type => $PreferredContentType, Attachment => undef, @_ );
+ my %args = ( Type => $PreferredContentType || 'text/plain',
+ @_ );
# If we don't have any content, return undef now.
# Get the set of toplevel attachments to this transaction.
-
- my $Attachment = $args{'Attachment'};
-
- $Attachment ||= $self->Attachments->First;
-
- return undef unless ($Attachment);
+ return undef unless my $Attachment = $self->Attachments->First;
# If it's a textual part, just return the body.
if ( RT::I18N::IsTextualContentType($Attachment->ContentType) ) {
@@ -434,23 +413,14 @@ sub ContentObj {
# If it's a multipart object, first try returning the first part with preferred
# MIME type ('text/plain' by default).
- elsif ( $Attachment->ContentType =~ qr|^multipart/mixed|i ) {
- my $kids = $Attachment->Children;
- while (my $child = $kids->Next) {
- my $ret = $self->ContentObj(%args, Attachment => $child);
- return $ret if ($ret);
- }
- }
- elsif ( $Attachment->ContentType =~ qr|^multipart/|i ) {
- if ( $args{Type} ) {
- my $plain_parts = $Attachment->Children;
- $plain_parts->ContentType( VALUE => $args{Type} );
- $plain_parts->LimitNotEmpty;
-
- # If we actully found a part, return its content
- if ( my $first = $plain_parts->First ) {
- return $first;
- }
+ elsif ( $Attachment->ContentType =~ '^multipart/' ) {
+ my $plain_parts = $Attachment->Children;
+ $plain_parts->ContentType( VALUE => $args{Type} );
+ $plain_parts->LimitNotEmpty;
+
+ # If we actully found a part, return its content
+ if ( my $first = $plain_parts->First ) {
+ return $first;
}
# If that fails, return the first textual part which has some content.
@@ -557,8 +527,6 @@ sub ContentAsMIME {
my $self = shift;
my $main_content = $self->ContentObj;
- return unless $main_content;
-
my $entity = $main_content->ContentAsMIME;
if ( $main_content->Parent ) {
@@ -590,7 +558,11 @@ sub ContentAsMIME {
OPERATOR => 'NOT STARTSWITH',
VALUE => 'multipart/',
);
- $attachments->LimitNotEmpty;
+ $attachments->Limit(
+ FIELD => 'Content',
+ OPERATOR => '!=',
+ VALUE => '',
+ );
while ( my $a = $attachments->Next ) {
$entity->make_multipart unless $entity->is_multipart;
$entity->add_part( $a->ContentAsMIME );
@@ -684,9 +656,6 @@ sub BriefDescription {
)
);
}
- elsif ( $type =~ /SystemError/ ) {
- return $self->loc("System error");
- }
if ( my $code = $_BriefDescriptions{$type} ) {
return $code->($self);