hide the old typeset statements with a non-default (and not added on upgrade) ACL...
[freeside.git] / httemplate / view / cust_msg_part.html
1 <%init>
2 die "access denied" unless $FS::CurrentUser::CurrentUser->access_right('View email logs');
3 # invoke this as "view/cust_msg_part.html?$custmsgnum+$partnum"
4 my ($custmsgnum, $partnum) = $cgi->keywords;
5 $custmsgnum =~ /^\d+$/ or die "bad custmsgnum";
6 $partnum =~ /^\d+$/ or die "bad partnum";
7 my $cust_msg = FS::cust_msg->by_key($custmsgnum)
8   or die "message not found";
9 my $part = ($cust_msg->parts)[$partnum]
10   or die "message part $partnum does not exist";
11
12 my $filename = $part->head->recommended_filename;
13 if (!$filename) {
14   # for lack of a better idea
15   $part->bodyhandle->{MB_Path} =~ /.*\/(.*)/;
16   $filename = $1;
17 }
18
19 $m->clear_buffer;
20 $r->content_type($part->mime_type || 'application/octet-stream');
21 $r->headers_out->add('Content-Disposition' => 'attachment;filename=' . $filename);
22 $m->print($part->bodyhandle->as_string);
23 </%init>