]> ruin.nu Git - ndwebbie.git/blobdiff - ND/Include.pm
mark threads as read
[ndwebbie.git] / ND / Include.pm
index bec7dd5b1e75bb5f3c053b30843c5e344115e309..e51d0e6b81bae9c9f849e9d390126e98258e52af 100644 (file)
 package ND::Include;
 use strict;
 use warnings FATAL => 'all';
+use CGI qw{:standard};
 require Exporter;
 
 our @ISA = qw/Exporter/;
 
 our @EXPORT = qw/isMember isHC isDC isBC isOfficer isScanner isIntel isTech parseMarkup min max listTargets
-       alliances intelquery generateClaimXml/;
+       alliances intelquery generateClaimXml markThreadAsRead/;
 
 sub isMember {
        return exists $ND::GROUPS{Members} || isTech();
@@ -67,6 +68,18 @@ sub parseMarkup {
        return $text;
 }
 
+sub markThreadAsRead {
+       my ($thread) = @_;
+       my $rows = $ND::DBH->do(q{UPDATE forum_thread_visits SET time = now() 
+WHERE uid =    $1 AND ftid = $2},undef,$ND::UID,$thread);
+       if ($rows == 0){
+               $ND::DBH->do(q{INSERT INTO forum_thread_visits (uid,ftid) VALUES ($1,$2)}
+                       ,undef,$ND::UID,$thread) or $ND::ERROR .= p($ND::DBH->errstr);
+       }else{
+               $ND::ERROR .= p($ND::DBH->errstr);
+       }
+}
+
 sub min {
     my ($x,$y) = @_;
     return ($x > $y ? $y : $x);