summaryrefslogtreecommitdiff
path: root/rt/webrt/Ticket/Attachment/dhandler
blob: 0d646cc0be1d41133e93f3288738098cf2e92f06 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
<%perl>
     my ($ticket, $trans,$attach, $filename);
     my $arg = $m->dhandler_arg;                # get rest of path
     if ($arg =~ '^(\d+)/(\d+)') {
        $trans = $1;
        $attach = $2;
     }
    else {
        Abort("Corrupted attachment URL.");
        }
     my $AttachmentObj = new RT::Attachment($session{'CurrentUser'});
     $AttachmentObj->Load($attach) || Abort("Attachment '$attach' could not be loaded");


     unless ($AttachmentObj->id) {
        Abort("Bad attachment id. Couldn't find attachment '$attach'\n");
    }
     unless ($AttachmentObj->TransactionId() == $trans ) {
        Abort("Bad transaction number for attachment. $trans should be".$AttachmentObj->TransactionId() ."\n");

     }
     my $content_type = $AttachmentObj->ContentType || 'text/plain';
     SetContentType($content_type);
     $m->out($AttachmentObj->Content); 
     $m->abort; 
</%perl>