1 #**************************************************************************
2 # Copyright (C) 2006 by Michael Andreen <harvATruinDOTnu> *
4 # This program is free software; you can redistribute it and/or modify *
5 # it under the terms of the GNU General Public License as published by *
6 # the Free Software Foundation; either version 2 of the License, or *
7 # (at your option) any later version. *
9 # This program is distributed in the hope that it will be useful, *
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of *
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
12 # GNU General Public License for more details. *
14 # You should have received a copy of the GNU General Public License *
15 # along with this program; if not, write to the *
16 # Free Software Foundation, Inc., *
17 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
18 #**************************************************************************/
20 package NDWeb::Pages::Forum::Search;
24 use CGI qw/:standard/;
28 use base qw/NDWeb::Pages::Forum/;
33 my $DBH = $self->{DBH};
34 $self->{TITLE} = 'Forum';
37 my $posts = $DBH->prepare(q{SELECT fp.ftid,u.username,ft.subject
38 ,ts_headline(fp.message,to_tsquery($2)) AS headline
39 ,ts_rank_cd(fp.textsearch, to_tsquery($2),32) AS rank
41 JOIN forum_threads ft USING (fbid)
42 JOIN forum_posts fp USING (ftid)
43 JOIN users u ON fp.uid = u.uid
44 WHERE fb.fbid IN (SELECT fbid FROM forum_access
45 WHERE gid IN (SELECT groups($1)))
46 AND fp.textsearch @@@ to_tsquery($2)
48 }) or warn $DBH->errstr;
49 $posts->execute($ND::UID,param('search')) or warn $DBH->errstr;
51 while (my $post = $posts->fetchrow_hashref){
54 $BODY->param(SearchResult => \@posts);