This commit was generated by cvs2svn to compensate for changes in r2523,
[freeside.git] / rt / webrt / SelfService / Attachment / dhandler
1 <%perl>
2      my ($ticket, $trans,$attach, $filename);
3      my $arg = $m->dhandler_arg;                # get rest of path
4      if ($arg =~ '^(\d+)/(\d+)') {
5         $trans = $1;
6         $attach = $2;
7      }
8     else {
9         Abort("Corrupted attachment URL.");
10         }
11      my $AttachmentObj = new RT::Attachment($session{'CurrentUser'});
12      $AttachmentObj->Load($attach) || Abort("Attachment '$attach' could not be loaded");
13
14
15      unless ($AttachmentObj->id) {
16         Abort("Bad attachment id. Couldn't find attachment '$attach'\n");
17     }
18      unless ($AttachmentObj->TransactionId() == $trans ) {
19         Abort("Bad transaction number for attachment. $trans should be".$AttachmentObj->TransactionId() ."\n");
20
21      }
22      my $content_type = $AttachmentObj->ContentType || 'text/plain';
23      SetContentType($content_type);
24      $m->out($AttachmentObj->Content); 
25      $m->abort; 
26 </%perl>
27