]> ruin.nu Git - ndwebbie.git/commitdiff
Possible to mark threads unread from a specific post
authorMichael Andreen <harv@ruin.nu>
Mon, 19 Oct 2009 15:54:24 +0000 (17:54 +0200)
committerMichael Andreen <harv@ruin.nu>
Mon, 19 Oct 2009 15:54:24 +0000 (17:54 +0200)
lib/NDWeb/Controller/Forum.pm
root/src/forum/thread.tt2

index def82bb5dc12c3690af46e406d884da115a1961c..bf7dc3ca8f11b76788ef52aa4cc8bbc2b4e72582 100644 (file)
@@ -232,7 +232,7 @@ sub findPosts :Private {
        my $dbh = $c->model;
 
        my $posts = $dbh->prepare(q{
        my $dbh = $c->model;
 
        my $posts = $dbh->prepare(q{
-               SELECT u.uid,u.username,date_trunc('seconds',fp.time::timestamp) AS time
+               SELECT fpid,u.uid,u.username,date_trunc('seconds',fp.time::timestamp) AS time
                        ,fp.message,COALESCE(fp.time > ftv.time,TRUE) AS unread
                FROM forum_threads ft
                        JOIN forum_posts fp USING (ftid)
                        ,fp.message,COALESCE(fp.time > ftv.time,TRUE) AS unread
                FROM forum_threads ft
                        JOIN forum_posts fp USING (ftid)
@@ -308,6 +308,22 @@ DELETE FROM forum_thread_visits WHERE uid = $1 AND ftid = $2
        $c->res->redirect($c->uri_for('board',$fbid));
 }
 
        $c->res->redirect($c->uri_for('board',$fbid));
 }
 
+sub markPostAsUnread : Local {
+       my ( $self, $c, $post ) = @_;
+       my $dbh = $c->model;
+
+       my ($fbid) = $dbh->selectrow_array(q{
+SELECT fbid FROM forum_threads JOIN forum_posts USING (ftid) WHERE fpid = $1
+               },undef, $post);
+
+       $dbh->do(q{
+UPDATE forum_thread_visits ftv SET time = (fp.time - interval '1 second')
+FROM forum_posts fp
+WHERE ftv.uid = $1 AND fp.fpid = $2 AND fp.ftid = ftv.ftid
+               }, undef, $c->user->id, $post);
+       $c->res->redirect($c->uri_for('board',$fbid));
+}
+
 sub moveThreads : Local {
        my ( $self, $c, $board ) = @_;
        my $dbh = $c->model;
 sub moveThreads : Local {
        my ( $self, $c, $board ) = @_;
        my $dbh = $c->model;
index d2820580ffd06da3ce3da1c30de11a5d5942286c..19c3589a81e7f52395706f60c1bc8ae857ffae67 100644 (file)
@@ -17,7 +17,8 @@
 <p><a name="NewPosts">New posts below:</a></p>
        [% END %]
 <fieldset class="forum-post">
 <p><a name="NewPosts">New posts below:</a></p>
        [% END %]
 <fieldset class="forum-post">
-<legend class="forum-post-header"><b>[% post.username %]</b> : [% post.time %] </legend>
+<legend class="forum-post-header"><b>[% post.username %]</b> : [% post.time %]
+       <a href="[% c.uri_for('markPostAsUnread',post.fpid) %]">Unread from here</a></legend>
 <div class="forum-post-body">[% post.message %]</div>
 </fieldset>
 [% END %]
 <div class="forum-post-body">[% post.message %]</div>
 </fieldset>
 [% END %]
@@ -89,6 +90,8 @@
 [% IF thread.post %]
 <script type="text/javascript">
 $(document).ready(function(){
 [% IF thread.post %]
 <script type="text/javascript">
 $(document).ready(function(){
+       $(".forum-post-header").append(
+               $("<span>").text(" | "));
        $(".forum-post-header").append(
                $("<a>").attr("href","#Reply").addClass("quotelink").text("Quote"));
        $(".quotelink").click(function(){
        $(".forum-post-header").append(
                $("<a>").attr("href","#Reply").addClass("quotelink").text("Quote"));
        $(".quotelink").click(function(){