Changeset 829

Show
Ignore:
Timestamp:
08/03/06 17:39:13 (2 years ago)
Author:
nick
Message:

Support for toggling moderation on and off on nodes

Location:
trunk
Files:
2 added
3 modified

Legend:

Unmodified
Added
Removed
  • trunk/MANIFEST

    r824 r829  
    4444templates/map_index.tt 
    4545templates/missing_metadata.tt 
     46templates/moderate_confirm.tt 
     47templates/moderate_password_wrong.tt 
    4648templates/navbar.tt 
    4749templates/needing_moderation.tt 
  • trunk/lib/OpenGuides.pm

    r826 r829  
    11331133} 
    11341134 
     1135=item B<set_node_moderation> 
     1136 
     1137  $guide->set_node_moderation( 
     1138                         id       => "FAQ", 
     1139                         password => "beer", 
     1140                         moderation_flag => 1, 
     1141                     ); 
     1142 
     1143Sets the moderation needed flag on a node, either on or off. 
     1144 
     1145If C<password> is not supplied then a form for entering the password 
     1146will be displayed. 
     1147=cut 
     1148sub set_node_moderation { 
     1149    my ($self, %args) = @_; 
     1150    my $node = $args{id} or croak "No node ID supplied for node moderation"; 
     1151    my $return_tt_vars = $args{return_tt_vars} || 0; 
     1152    my $return_output = $args{return_output} || 0; 
     1153 
     1154    # Get the moderation flag into something sane 
     1155    if($args{moderation_flag} eq "1" || $args{moderation_flag} eq "yes" || 
     1156       $args{moderation_flag} eq "on" || $args{moderation_flag} eq "true") { 
     1157        $args{moderation_flag} = 1; 
     1158    } else { 
     1159        $args{moderation_flag} = 0; 
     1160    } 
     1161 
     1162    # Set up the TT variables 
     1163    my %tt_vars = ( 
     1164                      not_editable  => 1, 
     1165                      not_deletable => 1, 
     1166                      deter_robots  => 1, 
     1167                      moderation_action => 'set_moderation', 
     1168                      moderation_flag   => $args{moderation_flag}, 
     1169                      moderation_url_args => 'action=set_moderation;moderation_flag='.$args{moderation_flag}, 
     1170                  ); 
     1171 
     1172    my $password = $args{password}; 
     1173 
     1174    if ($password) { 
     1175        if ($password ne $self->config->admin_pass) { 
     1176            return %tt_vars if $return_tt_vars; 
     1177            my $output = $self->process_template( 
     1178                                                    id       => $node, 
     1179                                                    template => "moderate_password_wrong.tt", 
     1180                                                    tt_vars  => \%tt_vars, 
     1181                                                ); 
     1182            return $output if $return_output; 
     1183            print $output; 
     1184        } else { 
     1185            $self->wiki->set_node_moderation( 
     1186                                        name    => $node, 
     1187                                        required => $args{moderation_flag}, 
     1188                                    ); 
     1189 
     1190            # Send back to the admin interface 
     1191            my $script_url = $self->config->script_url; 
     1192            my $script_name = $self->config->script_name; 
     1193            my $q = CGI->new; 
     1194            my $output = $q->redirect( $script_url.$script_name."?action=admin&moderation=changed" ); 
     1195            return $output if $return_output; 
     1196            print $output; 
     1197        } 
     1198    } else { 
     1199        return %tt_vars if $return_tt_vars; 
     1200        my $output = $self->process_template( 
     1201                                                id       => $node, 
     1202                                                template => "moderate_confirm.tt", 
     1203                                                tt_vars  => \%tt_vars, 
     1204                                            ); 
     1205        return $output if $return_output; 
     1206        print $output; 
     1207    } 
     1208} 
     1209 
    11351210=item B<show_missing_metadata> 
    11361211Search for nodes which don't have a certain kind of metadata. Optionally 
  • trunk/wiki.cgi

    r825 r829  
    9696                             id       => $node, 
    9797                             password => $q->param("password") || "", 
    98                              moderation_flag => $q->param("moderation_flat") || "", 
     98                             moderation_flag => $q->param("moderation_flag") || "", 
    9999                           ); 
    100100    } elsif ( $action eq 'moderate' ) {