[Rt-commit] r8820 - rt/branches/3.7-EXPERIMENTAL/lib/RT
ruz at bestpractical.com
ruz at bestpractical.com
Wed Aug 29 08:23:23 EDT 2007
Author: ruz
Date: Wed Aug 29 08:23:21 2007
New Revision: 8820
Modified:
rt/branches/3.7-EXPERIMENTAL/lib/RT/Attachment_Overlay.pm
Log:
RT::Attachment::
* add new method AddHeader
* add new method DelHeader
Modified: rt/branches/3.7-EXPERIMENTAL/lib/RT/Attachment_Overlay.pm
==============================================================================
--- rt/branches/3.7-EXPERIMENTAL/lib/RT/Attachment_Overlay.pm (original)
+++ rt/branches/3.7-EXPERIMENTAL/lib/RT/Attachment_Overlay.pm Wed Aug 29 08:23:21 2007
@@ -510,6 +510,43 @@
return undef;
}
+=head DelHeader $TAG
+
+Delete a field from the attachment's headers.
+
+=cut
+
+sub DelHeader {
+ my $self = shift;
+ my $tag = shift;
+
+ my $newheader = '';
+ foreach my $line ($self->_SplitHeaders) {
+ next if $line =~ /^\Q$tag\E:\s+(.*)$/is;
+ $newheader .= "$line\n";
+ }
+ return $self->__Set( Field => 'Headers', Value => $newheader);
+}
+
+=head AddHeader $TAG, $VALUE, ...
+
+Add one or many fields to the attachment's headers.
+
+=cut
+
+sub AddHeader {
+ my $self = shift;
+
+ my $newheader = $self->__Value( 'Headers' );
+ while ( my ($tag, $value) = splice @_, 0, 2 ) {
+ $value = '' unless defined $value;
+ $value =~ s/\s+$//s;
+ $value =~ s/\r+\n/\n /g;
+ $newheader .= "$tag: $value\n";
+ }
+ return $self->__Set( Field => 'Headers', Value => $newheader);
+}
+
=head2 SetHeader ( 'Tag', 'Value' )
Replace or add a Header to the attachment's headers.
@@ -519,8 +556,8 @@
sub SetHeader {
my $self = shift;
my $tag = shift;
- my $newheader = '';
+ my $newheader = '';
foreach my $line ($self->_SplitHeaders) {
if (defined $tag and $line =~ /^\Q$tag\E:\s+(.*)$/i) {
$newheader .= "$tag: $_[0]\n";
More information about the Rt-commit
mailing list