X-Git-Url: https://ruin.nu/git/?a=blobdiff_plain;f=forum.pl;h=cdd51fec478d0ac40bb4047a133da8bb831b483e;hb=5c0e48870efcfab42fdb34910645775ca3ebdbbc;hp=a9f1be1bd2dfcfaa49cfe3acc9ffcd4b0c647d6e;hpb=98378b594064426cdbc06b30a58553195d8cf8ec;p=ndwebbie.git diff --git a/forum.pl b/forum.pl index a9f1be1..cdd51fe 100644 --- a/forum.pl +++ b/forum.pl @@ -52,14 +52,7 @@ if(param('t')){ if (defined param('cmd') && param('cmd') eq 'forumpost'){ $DBH->begin_work; if ($board && $board->{post}){ - my $insert = $DBH->prepare(q{INSERT INTO forum_threads (fbid,subject) VALUES($1,$2)}); - if ($insert->execute($board->{id},escapeHTML(param('subject')))){ - $thread = $DBH->selectrow_hashref($findThread,undef, - $DBH->last_insert_id(undef,undef,undef,undef,"forum_threads_ftid_seq"),$ND::UID) - or $ERROR .= p($DBH->errstr); - }else{ - $ERROR .= p($DBH->errstr); - } + $thread = addForumThread $DBH,$board,$ND::UID,param('subject'); } if ($thread && $thread->{post}){ addForumPost($DBH,$thread,$ND::UID,param('message')); @@ -128,9 +121,9 @@ GROUP BY fb.fbid,fb.board $BODY->param(Overview => 1); $categories->execute or $ERROR .= p($DBH->errstr); my $boards = $DBH->prepare(q{SELECT fb.fbid AS id,fb.board,count(NULLIF(COALESCE(fp.fpid::boolean,FALSE) AND COALESCE(fp.time > ftv.time,TRUE),FALSE)) AS unread -FROM forum_boards fb NATURAL JOIN forum_access fa LEFT OUTER JOIN (forum_threads ft JOIN forum_posts fp USING (ftid)) ON fb.fbid = ft.fbid LEFT OUTER JOIN (SELECT * FROM forum_thread_visits WHERE uid = $2) ftv ON ftv.ftid = ft.ftid -WHERE fb.fcid = $1 AND (gid = -1 OR gid IN (SELECT gid FROM groupmembers - WHERE uid = $2)) +FROM forum_boards fb LEFT OUTER JOIN (forum_threads ft JOIN forum_posts fp USING (ftid)) ON fb.fbid = ft.fbid LEFT OUTER JOIN (SELECT * FROM forum_thread_visits WHERE uid = $2) ftv ON ftv.ftid = ft.ftid +WHERE fb.fcid = $1 AND + fb.fbid IN (SELECT fbid FROM forum_access WHERE gid IN (SELECT groups($2))) GROUP BY fb.fbid, fb.board ORDER BY fb.fbid }); my @categories;