]> ruin.nu Git - ndwebbie.git/commitdiff
keep track of last forum visit, so we can check if posts are really new, or just...
authorMichael Andreen <harv@ruin.nu>
Wed, 10 Jan 2007 14:41:22 +0000 (14:41 +0000)
committerMichael Andreen <harv@ruin.nu>
Wed, 10 Jan 2007 14:41:22 +0000 (14:41 +0000)
ND.pm
ND/Include.pm
ND/Web/Pages/Forum.pm
stylesheets/black.css
stylesheets/echoke.css
stylesheets/nd.css
templates/skel.tmpl

diff --git a/ND.pm b/ND.pm
index 8b2fdb3d9b2e872213e899edf86c686a1fa490c2..b5aee8646a9466ef103fe415b69b22fa71ce5725 100755 (executable)
--- a/ND.pm
+++ b/ND.pm
@@ -30,7 +30,9 @@ use ND::Include;
 use Tie::File;
 use Fcntl 'O_RDONLY';
 use strict;
-use warnings FATAL => 'all';
+use warnings;
+
+$SIG{__WARN__} = sub {$ND::ERROR .= p $_[0]};
 
 chdir '/var/www/ndawn/code';
 our %PAGES;
@@ -111,9 +113,13 @@ sub page {
 
                $fleetupdate = 0 unless defined $fleetupdate;
 
-               my ($unread,$lastv) = $DBH->selectrow_array(unread_query,undef,$UID) or $ERROR .= p($DBH->errstr);
+               my ($last_forum_visit) = $DBH->selectrow_array(q{SELECT last_forum_visit FROM users WHERE uid = $1}
+                       ,undef,$UID) or $ERROR .= p($DBH->errstr);
+               my ($unread,$newposts) = $DBH->selectrow_array(unread_query,undef,$UID,$last_forum_visit)
+                       or $ERROR .= p($DBH->errstr);
                
                $TEMPLATE->param(UnreadPosts => $unread);
+               $TEMPLATE->param(NewPosts => $newposts);
                $TEMPLATE->param(Tick => $TICK);
                $TEMPLATE->param(isMember => (($TICK - $fleetupdate < 24) || isScanner()) && $PLANET && isMember());
                $TEMPLATE->param(isHC => isHC());
index 81f5a8db8fcbe73a84aa222fefca7f15fcd5991b..53e7a4c17580a48c1e26c2c0d6d36b0690547d51 100644 (file)
@@ -53,7 +53,7 @@ sub intel_log {
 
 sub unread_query {
        return $ND::DBH->prepare_cached(q{
-                       SELECT count(*) AS unread
+                       SELECT count(*) AS unread, count(NULLIF(fp.time > $2,FALSE)) AS new
 FROM forum_boards fb NATURAL JOIN forum_threads ft 
        JOIN forum_posts fp USING (ftid) LEFT OUTER JOIN 
                (SELECT * FROM forum_thread_visits WHERE uid = $1) ftv ON ftv.ftid = ft.ftid
index 6a703fbe909319f2261d1b33e736bf81d26cc4b0..2b287a9d1193828485eef2d7f556e0d54f7f4afe 100644 (file)
@@ -19,8 +19,7 @@
 
 package ND::Web::Pages::Forum;
 use strict;
-use warnings FATAL => 'all';
-no warnings 'uninitialized';
+use warnings;
 use ND::Web::Forum;
 use CGI qw/:standard/;
 use ND::Web::Include;
@@ -43,6 +42,8 @@ sub render {
 
        $ND::TEMPLATE->param(TITLE => 'Forum');
 
+       $DBH->do(q{UPDATE users SET last_forum_visit = NOW() WHERE uid = $1},undef,$ND::UID) or $ND::ERROR .= p($DBH->errstr);
+
        my $board;
        if(param('b')){
                my $boards = $DBH->prepare(q{SELECT fb.fbid AS id,fb.board, bool_or(fa.post) AS post
index 20c57987b4f49338bc902ae8b99aa625b7b5f25a..d5f18310a566724e3922a56f1e67bd3d2221407a 100644 (file)
@@ -195,3 +195,9 @@ td.HighestPrio{
        background: green;
        color: black;
 }
+span.newposts,span.unreadposts {
+       font-weight: bold;
+}
+span.newposts {
+       color: red;
+}
index 1b2aa4ca575baf6e8613d3a13973771683a11f0f..0c60e63337e52483bc0cf34288df5c7efbe01ee4 100644 (file)
@@ -224,3 +224,9 @@ td.HighestPrio
        background: #336666; 
        color: white; 
 }
+span.newposts,span.unreadposts {
+       font-weight: bold;
+}
+span.newposts {
+       color: red;
+}
index 4e031f1c56214d629d38397ea657c75ee79ea790..6c38f07fc0b7e491434ac2cf7beaf55937ae24c8 100644 (file)
@@ -185,3 +185,9 @@ td.HighestPrio{
        background: green;
        color: black;
 }
+span.newposts,span.unreadposts {
+       font-weight: bold;
+}
+span.newposts {
+       color: red;
+}
index c7d1d075c4d7c05f81b4cfd1791e230c6e739dc1..0bc222bf6a73278d445d3b789a1e8b35e294ae11 100644 (file)
@@ -15,7 +15,7 @@
                <li><a href="/main">Main page</a></li>
                <li><a href="/settings">Settings</a></li>
                <li><a href="/forum">Forum</a></li>
-               <li><a href="/forum/allUnread">New posts <TMPL_IF UnreadPosts>(<b><TMPL_VAR NAME=UnreadPosts></b>)</TMPL_IF></a></li>
+               <li><a href="/forum/allUnread">New posts <TMPL_IF UnreadPosts>(<span class="<TMPL_IF NewPosts>newposts<TMPL_ELSE>unreadposts</TMPL_IF>"><TMPL_VAR NAME=UnreadPosts></span>)</TMPL_IF></a></li>
        </ul>   <p>Tick: <TMPL_VAR NAME=TICK></p>
        <TMPL_IF isMEMBER>
        <p>Member menu</p>