#!/usr/bin/perl #------------------------------------------------------------------------------ # mwForum - Web-based discussion forum # Copyright (c) 1999-2015 Markus Wichitill # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. #------------------------------------------------------------------------------ use strict; use warnings; no warnings qw(uninitialized redefine); # Imports use TyfMain; #------------------------------------------------------------------------------ # Init my ( $m, $cfg, $lng, $user, $userId ) = TyfMain->new( $_[0] ); # Check if access should be denied $cfg->{messages} or $m->error('errNoAccess'); $userId or $m->error('errNoAccess'); # Get messages my $messages = $m->fetchAllHash( " SELECT messages.*, senders.userName AS senderName, receivers.userName AS receiverName FROM messages AS messages INNER JOIN users AS senders ON senders.id = messages.senderId INNER JOIN users AS receivers ON receivers.id = messages.receiverId WHERE (messages.senderId = :userId AND messages.sentbox = 1) OR (messages.receiverId = :userId AND messages.inbox = 1) ORDER BY messages.sendTime DESC", { userId => $userId } ); # Print header $m->printHttpHeader( { 'content-disposition' => "attachment; filename=Messages.html" } ); my $fontFaceStr = $user->{fontFace} ? "font-family: '$user->{fontFace}', sans-serif;" : ""; my $fontSizeStr = $user->{fontSize} ? "font-size: $user->{fontSize}px;" : ""; print "\n", "\n", "\n", "$lng->{mslTitle}\n", "\n", "\n", "\n", "\n\n"; # Print messages for my $msg (@$messages) { # Print message my $subject = $msg->{subject}; $subject =~ s!Re: !!; my $time = $m->formatTime( $msg->{sendTime}, $user->{timezone} ); my $timeIso = $m->formatTime( $msg->{sendTime}, 0, "%Y-%m-%dT%TZ" ); print "
\n", "
\n", "

$subject

\n", "\n", "\n", "\n", "\n", "
$lng->{mssFrom}$msg->{senderName}
$lng->{mssTo}$msg->{receiverName}
$lng->{mssDate}
\n", "
\n", "
\n$msg->{body}\n
\n", "
\n\n"; } print "\n", "\n"; # Log action and finish $m->logAction( 2, 'msg', 'export', $userId ); $m->finish();