Author: nick Date: 2006-08-03 17:39:13 +0100 (Thu, 03 Aug 2006) New Revision: 829
Added: trunk/templates/moderate_confirm.tt trunk/templates/moderate_password_wrong.tt Modified: trunk/MANIFEST trunk/lib/OpenGuides.pm trunk/wiki.cgi Log: Support for toggling moderation on and off on nodes
Modified: trunk/MANIFEST =================================================================== --- trunk/MANIFEST 2006-08-03 15:08:05 UTC (rev 828) +++ trunk/MANIFEST 2006-08-03 16:39:13 UTC (rev 829) @@ -43,6 +43,8 @@ templates/home_node.tt templates/map_index.tt templates/missing_metadata.tt +templates/moderate_confirm.tt +templates/moderate_password_wrong.tt templates/navbar.tt templates/needing_moderation.tt templates/newpage.tt
Modified: trunk/lib/OpenGuides.pm =================================================================== --- trunk/lib/OpenGuides.pm 2006-08-03 15:08:05 UTC (rev 828) +++ trunk/lib/OpenGuides.pm 2006-08-03 16:39:13 UTC (rev 829) @@ -1132,6 +1132,81 @@ } }
+=item B<set_node_moderation> + + $guide->set_node_moderation( + id => "FAQ", + password => "beer", + moderation_flag => 1, + ); + +Sets the moderation needed flag on a node, either on or off. + +If C<password> is not supplied then a form for entering the password +will be displayed. +=cut +sub set_node_moderation { + my ($self, %args) = @_; + my $node = $args{id} or croak "No node ID supplied for node moderation"; + my $return_tt_vars = $args{return_tt_vars} || 0; + my $return_output = $args{return_output} || 0; + + # Get the moderation flag into something sane + if($args{moderation_flag} eq "1" || $args{moderation_flag} eq "yes" || + $args{moderation_flag} eq "on" || $args{moderation_flag} eq "true") { + $args{moderation_flag} = 1; + } else { + $args{moderation_flag} = 0; + } + + # Set up the TT variables + my %tt_vars = ( + not_editable => 1, + not_deletable => 1, + deter_robots => 1, + moderation_action => 'set_moderation', + moderation_flag => $args{moderation_flag}, + moderation_url_args => 'action=set_moderation;moderation_flag='.$args{moderation_flag}, + ); + + my $password = $args{password}; + + if ($password) { + if ($password ne $self->config->admin_pass) { + return %tt_vars if $return_tt_vars; + my $output = $self->process_template( + id => $node, + template => "moderate_password_wrong.tt", + tt_vars => %tt_vars, + ); + return $output if $return_output; + print $output; + } else { + $self->wiki->set_node_moderation( + name => $node, + required => $args{moderation_flag}, + ); + + # Send back to the admin interface + my $script_url = $self->config->script_url; + my $script_name = $self->config->script_name; + my $q = CGI->new; + my $output = $q->redirect( $script_url.$script_name."?action=admin&moderation=changed" ); + return $output if $return_output; + print $output; + } + } else { + return %tt_vars if $return_tt_vars; + my $output = $self->process_template( + id => $node, + template => "moderate_confirm.tt", + tt_vars => %tt_vars, + ); + return $output if $return_output; + print $output; + } +} + =item B<show_missing_metadata> Search for nodes which don't have a certain kind of metadata. Optionally also excludes Locales and Categories
Added: trunk/templates/moderate_confirm.tt =================================================================== --- trunk/templates/moderate_confirm.tt 2006-08-03 15:08:05 UTC (rev 828) +++ trunk/templates/moderate_confirm.tt 2006-08-03 16:39:13 UTC (rev 829) @@ -0,0 +1,40 @@ +[% IF moderation_action == 'set_moderation' %] + [% INCLUDE header.tt page_title = "Change moderation status of $node_name" %] +[% ELSE %] + [% INCLUDE header.tt page_title = "Moderate a version of $node_name" %] +[% END %] +[% INCLUDE banner.tt %] +<div id="content"> +[% INCLUDE navbar.tt %] +<div id="maincontent"> + +<h1>Confirm Moderation</h1> +<p> +[% IF moderation_action == 'set_moderation' %] + You are about to change the moderation flag on + <span class="node_name">[% node_name %]</span>. +[% ELSE %] + You are about to moderate a version of + <span class="node_name">[% node_name %]</span>. + completely erase this page and all its history. +[% END %] +To do so, please enter the admin password. If not, you can +<a href="[% cgi_url %]?action=admin">go back to the admin page</a>. +</p> +<form action="[% cgi_url %]" method="post"> + <input type="hidden" name="action" value="[% moderation_action %]" /> + <input type="hidden" name="id" value="[% node_param %]" /> +[% IF moderation_action == 'set_moderation' %] + <label for="moderation_flag">Moderation Required:</label> + <input type="checkbox" name="moderation_flag" [% IF moderation_flag %]checked="yes"[% END %] /> + <br /> +[% ELSE %] + <input type="hidden" name="version" value="[% version %]" /> +[% END %] + <strong>Password:</strong> + <input type="password" name="password" /> + <input type="submit" value="Action Moderation" /> +</form> + +</div> +[% INCLUDE footer.tt %]
Added: trunk/templates/moderate_password_wrong.tt =================================================================== --- trunk/templates/moderate_password_wrong.tt 2006-08-03 15:08:05 UTC (rev 828) +++ trunk/templates/moderate_password_wrong.tt 2006-08-03 16:39:13 UTC (rev 829) @@ -0,0 +1,12 @@ +[% INCLUDE header.tt page_title = "Incorrect password for page moderation - $site_name" %] +[% INCLUDE banner.tt %] +<div id="content"> +[% INCLUDE navbar.tt %] +<div id="maincontent"> +<h1>Incorrect Password</h1> +<p> +Sorry, that was not the correct password. Please +<a href="[% cgi_url %]?id=[% node_param %];[% moderation_url_args %]">try again</a>. +</p> +</div> +[% INCLUDE footer.tt %]
Modified: trunk/wiki.cgi =================================================================== --- trunk/wiki.cgi 2006-08-03 15:08:05 UTC (rev 828) +++ trunk/wiki.cgi 2006-08-03 16:39:13 UTC (rev 829) @@ -95,7 +95,7 @@ $guide->set_node_moderation( id => $node, password => $q->param("password") || "", - moderation_flag => $q->param("moderation_flat") || "", + moderation_flag => $q->param("moderation_flag") || "", ); } elsif ( $action eq 'moderate' ) { $guide->moderate_node(