| | 1135 | =item B<set_node_moderation> |
| | 1136 | |
| | 1137 | $guide->set_node_moderation( |
| | 1138 | id => "FAQ", |
| | 1139 | password => "beer", |
| | 1140 | moderation_flag => 1, |
| | 1141 | ); |
| | 1142 | |
| | 1143 | Sets the moderation needed flag on a node, either on or off. |
| | 1144 | |
| | 1145 | If C<password> is not supplied then a form for entering the password |
| | 1146 | will be displayed. |
| | 1147 | =cut |
| | 1148 | sub 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 | |