]> ruin.nu Git - ndwebbie.git/commitdiff
Make it possible to move a thread from the thread view
authorMichael Andreen <harv@ruin.nu>
Mon, 3 Nov 2008 16:37:18 +0000 (17:37 +0100)
committerMichael Andreen <harv@ruin.nu>
Mon, 3 Nov 2008 16:37:18 +0000 (17:37 +0100)
lib/NDWeb/Controller/Forum.pm
root/src/forum/thread.tt2

index f4fa3c0abd74dd36411e6db572161b3eaf50476c..1a796246688d090a717e7046e02af5bb52c12e16 100644 (file)
@@ -182,33 +182,10 @@ sub board : Local {
        }
        $c->stash(threads => \@threads);
 
-       if ($board->{moderate}){
-               my $categories = $dbh->prepare(q{SELECT fcid,category FROM forum_categories ORDER BY fcid});
-               my $boards = $dbh->prepare(q{SELECT fb.fbid,fb.board, bool_or(fa.post) AS post
-                       FROM forum_boards fb NATURAL JOIN forum_access fa
-                       WHERE fb.fcid = $1 AND
-                               gid IN (SELECT groups($2))
-                       GROUP BY fb.fbid,fb.board
-                       ORDER BY fb.fbid
-               });
-               $categories->execute;
-               my @categories;
-               while (my $category = $categories->fetchrow_hashref){
-                       $boards->execute($category->{fcid},$c->stash->{UID});
-
-                       my @boards;
-                       while (my $b = $boards->fetchrow_hashref){
-                               next if (not $b->{post} or $b->{fbid} == $board->{fbid});
-                               push @boards,$b;
-                       }
-                       $category->{boards} = \@boards;
-                       push @categories,$category if @boards;
-               }
-               $c->stash(categories => \@categories);
-       }
+       $c->forward('listModeratorBoards', [$board->{fbid}]) if $board->{moderate};
+       
 }
 
-
 sub thread : Local {
        my ( $self, $c, $thread ) = @_;
        my $dbh = $c->model;
@@ -222,9 +199,12 @@ sub thread : Local {
                JOIN forum_priv_access fta USING (uid) WHERE fta.ftid = $1});
        $query->execute($thread);
        $c->stash(access => $query->fetchall_arrayref({}) );
-       $c->forward('findUsers') if $c->stash->{thread}->{moderate};
        $c->forward('findPosts');
        $c->forward('markThreadAsRead') if $c->user_exists;
+       if ($c->stash->{thread}->{moderate}) {
+               $c->forward('findUsers');
+               $c->forward('listModeratorBoards', [$c->stash->{thread}->{fbid}]);
+       }
 }
 
 sub findPosts :Private {
@@ -535,6 +515,35 @@ sub insertPost : Private {
        $insert->execute($thread,html_escape($c->req->param('message')),$c->stash->{UID});
 }
 
+sub listModeratorBoards : Private {
+       my ( $self, $c, $fbid ) = @_;
+       my $dbh = $c->model;
+
+       my $categories = $dbh->prepare(q{SELECT fcid,category FROM forum_categories ORDER BY fcid});
+       my $boards = $dbh->prepare(q{SELECT fb.fbid,fb.board, bool_or(fa.post) AS post
+               FROM forum_boards fb NATURAL JOIN forum_access fa
+               WHERE fb.fcid = $1
+                       AND gid IN (SELECT groups($2))
+                       AND moderate
+               GROUP BY fb.fbid,fb.board
+               ORDER BY fb.fbid
+               });
+       $categories->execute;
+       my @categories;
+       while (my $category = $categories->fetchrow_hashref){
+               $boards->execute($category->{fcid},$c->stash->{UID});
+
+               my @boards;
+               while (my $b = $boards->fetchrow_hashref){
+                       next if ($b->{fbid} == $fbid);
+                       push @boards,$b;
+               }
+               $category->{boards} = \@boards;
+               push @categories,$category if @boards;
+       }
+       $c->stash(categories => \@categories);
+}
+
 =head1 AUTHOR
 
 Michael Andreen (harv@ruin.nu)
index bd3a1be8d7aa66e1062351a6f60007ed12dd9974..0095155f04e14633d88b6c1eb3bf27960ccb389d 100644 (file)
 [% END %]
 
 [% IF thread.moderate %]
+
+<form action="[% c.uri_for('moveThreads',thread.fbid) %]" method="post">
+<p>Move checked threads to:
+<input type="hidden" name="t:[% thread.ftid %]" value="1">
+<select name="board">
+[% FOR category IN categories %]
+       <optgroup label="[% category.category %]">
+       [% FOR targetboard IN category.boards %]
+               <option value="[% targetboard.fbid %]">[% targetboard.board %]</option>
+       [% END %]
+       </optgroup>
+[% END %]
+</select>
+<input type="submit" name="cmd" value="Move">
+</p>
+</form>
+
 <form action="[% c.uri_for('postthreadaccess',thread.ftid) %]#NewPosts" method="post">
 <fieldset class="forum-post"> <legend>Change thread access</legend>
 <table>