RT 5.0.6 Documentation

RT::Attachment

Go to latest version →

SYNOPSIS

    use RT::Attachment;

DESCRIPTION

This module should never be instantiated directly by client code. it's an internal module which should only be instantiated through exported APIs in Ticket, Queue and other similar objects.

METHODS

Create

Create a new attachment. Takes a paramhash:

    'Attachment' Should be a single MIME body with optional subparts
    'Parent' is an optional id of the parent attachment
    'TransactionId' is the mandatory id of the transaction this attachment is associated with.;

TransactionObj

Returns the transaction object associated with this attachment.

ParentObj

Returns a parent's RT::Attachment object if this attachment has a parent, otherwise returns undef.

Closest

Takes a MIME type as a string or regex. Returns an RT::Attachment object for the nearest containing part with a matching "ContentType". Strings must match exactly and all matches are done case insensitively. Strings ending in a / must only match the first part of the MIME type. For example:

    # Find the nearest multipart/* container
    my $container = $attachment->Closest("multipart/");

Returns undef if no such object is found.

Children

Returns an RT::Attachments object which is preloaded with all attachments objects with this attachment's Id as their Parent.

Siblings

Returns an RT::Attachments object containing all the attachments sharing the same immediate parent as the current object, excluding the current attachment itself.

If the current attachment is a top-level part (i.e. Parent == 0) then a guaranteed empty RT::Attachments object is returned.

Content

Returns the attachment's content. if it's base64 encoded, decode it before returning it.

OriginalContent

Returns the attachment's content as octets before RT's mangling. Generally this just means restoring text content back to its original encoding.

If the attachment has a message/* Content-Type, its children attachments are reconstructed and returned as a string.

OriginalEncoding

Returns the attachment's original encoding.

ContentLength

Returns length of "Content" in bytes.

FriendlyContentLength

Returns "ContentLength" in bytes, kilobytes, or megabytes as most appropriate. The size is suffixed with MiB, KiB, or B and the returned string is localized.

Returns the empty string if the "ContentLength" is 0 or undefined.

ContentAsMIME [Children => 1]

Returns MIME entity built from this attachment.

If the optional parameter Children is set to a true value, the children are recursively added to the entity.

IsMessageContentType

Returns a boolean indicating if the Content-Type of this attachment is a message/ subtype.

IsAttachmentContentDisposition

Returns a boolean indicating if the Content-Disposition of this attachment is a MIME attachment.

Addresses

Returns a hashref of all addresses related to this attachment. The keys of the hash are From, To, Cc, Bcc, RT-Send-Cc and RT-Send-Bcc. The values are references to lists of Email::Address objects.

NiceHeaders

Returns a multi-line string of the To, From, Cc, Date and Subject headers.

Headers

Returns this object's headers as a string. This method specifically removes the RT-Send-Bcc: header, so as to never reveal to whom RT sent a Bcc. We need to record the RT-Send-Cc and RT-Send-Bcc values so that we can actually send out mail. The mailing rules are separated from the ticket update code by an abstraction barrier that makes it impossible to pass this data directly.

EncodedHeaders

Takes encoding as argument and returns the attachment's headers as octets in encoded using the encoding.

This is not protection using quoted printable or base64 encoding.

GetHeader $TAG

Returns the value of the first header Tag as a string. This bypasses the weeding out done in Headers() above.

GetAllHeaders $TAG

Returns a list of all values for the the given header tag, in the order they appear.

DelHeader $TAG

Delete a field from the attachment's headers.

AddHeader $TAG, $VALUE, ...

Add one or many fields to the attachment's headers.

SetHeader ( 'Tag', 'Value' )

Replace or add a Header to the attachment's headers.

ReplaceHeaders ( Search => 'SEARCH', Replacement => 'Replacement' )

Search the attachments table's Header column for the search string provided. When a match is found call the SetHeader() method on the header with the match, either set the header to empty or a replacement value.

ReplaceContent ( Search => 'SEARCH', Replacement => 'Replacement' )

Search the attachments table's Content column for the search string provided. When a match is found either replace it with the provided replacement string or an empty string.

SplitHeaders

Returns an array of this attachment object's headers, with one header per array entry. Multiple lines are folded.

Never returns RT-Send-Bcc field.

_SplitHeaders

Returns an array of this attachment object's headers, with one header per array entry. multiple lines are folded.

CryptStatus

Returns the parsed status from the X-RT-GnuPG-Status or X-RT-SMIME-Status header.

The return value is an array of hashrefs; each hashref is as described in RT::Crypt::ParseStatus; however, each hashref has one additional entry 'Protocol' which is the name of the crypto protocol used and is one of 'SMIME' or 'GnuPG'.

If no crypto header exists, returns an empty array

_Value

Takes the name of a table column. Returns its value as a string, if the user passes an ACL check

CurrentUserCanSee

Returns true if the current user can see the attachment, via corresponding transaction's rights check.

id

Returns the current value of id. (In the database, id is stored as int(19).)

TransactionId

Returns the current value of TransactionId. (In the database, TransactionId is stored as int(19).)

SetTransactionId VALUE

Set TransactionId to VALUE. Returns (1, 'Status message') on success and (0, 'Error Message') on failure. (In the database, TransactionId will be stored as a int(19).)

Parent

Returns the current value of Parent. (In the database, Parent is stored as int(19).)

SetParent VALUE

Set Parent to VALUE. Returns (1, 'Status message') on success and (0, 'Error Message') on failure. (In the database, Parent will be stored as a int(19).)

MessageId

Returns the current value of MessageId. (In the database, MessageId is stored as varchar(160).)

SetMessageId VALUE

Set MessageId to VALUE. Returns (1, 'Status message') on success and (0, 'Error Message') on failure. (In the database, MessageId will be stored as a varchar(160).)

Subject

Returns the current value of Subject. (In the database, Subject is stored as varchar(255).)

SetSubject VALUE

Set Subject to VALUE. Returns (1, 'Status message') on success and (0, 'Error Message') on failure. (In the database, Subject will be stored as a varchar(255).)

Filename

Returns the current value of Filename. (In the database, Filename is stored as varchar(255).)

SetFilename VALUE

Set Filename to VALUE. Returns (1, 'Status message') on success and (0, 'Error Message') on failure. (In the database, Filename will be stored as a varchar(255).)

ContentType

Returns the current value of ContentType. (In the database, ContentType is stored as varchar(80).)

SetContentType VALUE

Set ContentType to VALUE. Returns (1, 'Status message') on success and (0, 'Error Message') on failure. (In the database, ContentType will be stored as a varchar(80).)

ContentEncoding

Returns the current value of ContentEncoding. (In the database, ContentEncoding is stored as varchar(80).)

SetContentEncoding VALUE

Set ContentEncoding to VALUE. Returns (1, 'Status message') on success and (0, 'Error Message') on failure. (In the database, ContentEncoding will be stored as a varchar(80).)

Content

Returns the current value of Content. (In the database, Content is stored as longblob.)

SetContent VALUE

Set Content to VALUE. Returns (1, 'Status message') on success and (0, 'Error Message') on failure. (In the database, Content will be stored as a longblob.)

Headers

Returns the current value of Headers. (In the database, Headers is stored as longtext.)

SetHeaders VALUE

Set Headers to VALUE. Returns (1, 'Status message') on success and (0, 'Error Message') on failure. (In the database, Headers will be stored as a longtext.)

Creator

Returns the current value of Creator. (In the database, Creator is stored as int(11).)

Created

Returns the current value of Created. (In the database, Created is stored as datetime.)

← Back to index