]> ruin.nu Git - ndwebbie.git/blobdiff - ND/Web/Forum.pm
connection to db is done in handler, so should do potential rollback and disconnect...
[ndwebbie.git] / ND / Web / Forum.pm
index 8eca745423053ee6332f147d8c9df52f00a5cc7e..1b06b8a6cbfff3b9aadfce60e79263d67ad054de 100644 (file)
@@ -34,11 +34,10 @@ sub viewForumThread {
 
        my $template = HTML::Template->new(filename => "templates/viewthread.tmpl", global_vars => 1, cache => 1);
 
-       $template->param(Subject => $thread->{subject});
        $template->param(Id => $thread->{id});
        $template->param(Post => $thread->{post});
 
-       my $posts = $ND::DBH->prepare(q{SELECT u.username,date_trunc('minute',fp.time::timestamp) AS time,fp.message,COALESCE(fp.time > ftv.time,TRUE) AS unread
+       my $posts = $ND::DBH->prepare(q{SELECT u.username,date_trunc('seconds',fp.time::timestamp) AS time,fp.message,COALESCE(fp.time > ftv.time,TRUE) AS unread
 FROM forum_threads ft JOIN forum_posts fp USING (ftid) JOIN users u USING (uid) LEFT OUTER JOIN (SELECT * FROM forum_thread_visits WHERE uid = $2) ftv ON ftv.ftid = ft.ftid
 WHERE ft.ftid = $1
 ORDER BY fp.time ASC
@@ -54,7 +53,14 @@ ORDER BY fp.time ASC
                $post->{message} = parseMarkup($post->{message});
                push @posts,$post;
        }
+
+       if (defined param('cmd') && param('cmd') eq 'Preview'){
+               my $text = parseMarkup(escapeHTML(param('message')));
+               $text .= p b $@ if $@;
+               push @posts,{message => $text, unread => 1, username => 'PREVIEW', Time => 'Not submitted yet', NewPosts => $old ? 1 : 0};
+       }
        $template->param(Posts => \@posts);
+       $template->param(Message => param('message'));
 
        markThreadAsRead($thread->{id});