]> ruin.nu Git - ndwebbie.git/blobdiff - ND/Web/Forum.pm
some restructuring, put intel messages in forum board instead of separate table
[ndwebbie.git] / ND / Web / Forum.pm
index 8e194199413b726c261636baaaec04394c12d457..8eca745423053ee6332f147d8c9df52f00a5cc7e 100644 (file)
@@ -27,7 +27,7 @@ require Exporter;
 
 our @ISA = qw/Exporter/;
 
-our @EXPORT = qw/viewForumThread addForumPost markThreadAsRead/;
+our @EXPORT = qw/viewForumThread addForumPost addForumThread markThreadAsRead/;
 
 sub viewForumThread {
        my ($thread) = @_;
@@ -71,6 +71,21 @@ sub addForumPost {
        return 1;
 }
 
+sub addForumThread {
+       my ($dbh,$board,$uid,$subject) = @_;
+
+       my $insert = $dbh->prepare(q{INSERT INTO forum_threads (fbid,subject) VALUES($1,$2)});
+
+       if ($insert->execute($board->{id},escapeHTML($subject))){
+               my $id = $dbh->last_insert_id(undef,undef,undef,undef,"forum_threads_ftid_seq");
+               return $dbh->selectrow_hashref(q{SELECT ftid AS id, subject, $2::boolean AS post FROM forum_threads WHERE ftid = $1}
+                       ,undef,$id,$board->{post})
+                       or $ND::ERROR .= p($dbh->errstr);
+       }else{
+               $ND::ERROR .= p($dbh->errstr);
+       }
+}
+
 sub markThreadAsRead {
        my ($thread) = @_;
        my $rows = $ND::DBH->do(q{UPDATE forum_thread_visits SET time = now()