]> ruin.nu Git - ndwebbie.git/commitdiff
initial commit of the forum page
authorMichael Andreen <harv@ruin.nu>
Mon, 1 Jan 2007 21:25:23 +0000 (21:25 +0000)
committerMichael Andreen <harv@ruin.nu>
Mon, 1 Jan 2007 21:25:23 +0000 (21:25 +0000)
forum.pl [new file with mode: 0644]
pages
templates/forum.tmpl [new file with mode: 0644]

diff --git a/forum.pl b/forum.pl
new file mode 100644 (file)
index 0000000..f9960b4
--- /dev/null
+++ b/forum.pl
@@ -0,0 +1,69 @@
+#**************************************************************************
+#   Copyright (C) 2006 by Michael Andreen <harvATruinDOTnu>               *
+#                                                                         *
+#   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 2 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.                          *
+#                                                                         *
+#   You should have received a copy of the GNU General Public License     *
+#   along with this program; if not, write to the                         *
+#   Free Software Foundation, Inc.,                                       *
+#   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.         *
+#**************************************************************************/
+
+use strict;
+use warnings FATAL => 'all';
+
+$ND::TEMPLATE->param(TITLE => 'Forum');
+
+our $BODY;
+our $DBH;
+my $error;
+
+my %thread;
+#TODO: fetch thread info.
+
+my %board;
+#TODO: fetch board info.
+
+if (%thread){ #Display the thread
+}elsif(%board){ #List threads in this board
+}else{ #List boards
+       $BODY->param(Overview => 1);
+       my $categories = $DBH->prepare(q{SELECT fcid AS id,category FROM
+               forum_categories});
+       my $boards = $DBH->prepare(q{SELECT fb.fbid AS id,fb.board
+               FROM forum_boards fb NATURAL JOIN forum_access fa
+               WHERE fcid = $1 AND (gid = -1 OR gid IN (SELECT gid FROM groupmembers
+                       WHERE uid = $2))
+               GROUP BY fb.fbid, fb.board
+               });
+       $categories->execute or $error .= p($DBH->errstr);
+       my @categories;
+       while (my $category = $categories->fetchrow_hashref){
+               $boards->execute($category->{id},$ND::UID) or $error .= p($DBH->errstr);
+               my @boards;
+               my $i = 0;
+               while (my $board = $boards->fetchrow_hashref){
+                       $board->{Unread} = 0;
+                       $i++;
+                       $board->{Odd} = $i % 2;
+                       push @boards,$board;
+               }
+               $category->{Boards} = \@boards;
+               delete $category->{id};
+               push @categories,$category if $i > 0;
+       }
+       $BODY->param(Categories => \@categories);
+
+}
+$BODY->param(Error => $error);
+
+1;
+
diff --git a/pages b/pages
index 13b0138962c0d2d66b41b51ba2bc506dbc6523ed..d03af29ac2fca4ceea539a37459ed1d50f250745 100644 (file)
--- a/pages
+++ b/pages
@@ -16,3 +16,4 @@ alliances
 memberIntel
 resources
 planetNaps
+forum
diff --git a/templates/forum.tmpl b/templates/forum.tmpl
new file mode 100644 (file)
index 0000000..6d5019c
--- /dev/null
@@ -0,0 +1,22 @@
+<TMPL_VAR NAME=Error>
+<TMPL_IF Thread>
+</TMPL_IF>
+<TMPL_IF Board>
+</TMPL_IF>
+<TMPL_IF Overview>
+<table class="boards">
+<tr>
+       <th>Unread</th>
+       <th>Board</th>
+</tr>
+<TMPL_LOOP Categories>
+       <tr><th colspan="2"><TMPL_VAR NAME=Category></th></tr>
+       <TMPL_LOOP Boards>
+       <tr class="<TMPL_IF ODD>odd<TMPL_ELSE>even</TMPL_IF>">
+               <td align="center"><TMPL_VAR NAME=Unread></td>
+               <td><a href="<TMPL_VAR NAME=PAGE>?board=<TMPL_VAR NAME=Id>"><TMPL_VAR NAME=Board></a></td>
+       </tr>
+       </TMPL_LOOP>
+</TMPL_LOOP>
+</table>
+</TMPL_IF>