Changeset 1068


Ignore:
Timestamp:
Jun 11, 2007, 9:37:06 PM (14 years ago)
Author:
Dominic Hargreaves
Message:

Add framework for generic content/metadata validation into commit_node

Location:
trunk/lib
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/lib/OpenGuides.pm

    r1067 r1068  
    13361336    $new_metadata{host} = $ENV{REMOTE_ADDR};
    13371337
     1338    # General validation
     1339    eval { OpenGuides::Utils->validate_edit(
     1340        content  => $content,
     1341        metadata => \%new_metadata
     1342    ) };
     1343
     1344    if ( $@ ) {
     1345        my $output = OpenGuides::Template->output(
     1346            wiki     => $self->wiki,
     1347            config   => $config,
     1348            template => "validate_edit_failed.tt",
     1349            vars => {
     1350                message => $@
     1351            }
     1352        );
     1353        return $output if $return_output;
     1354        print $output;
     1355        return;
     1356    }
     1357
    13381358    # Wiki::Toolkit::Plugin::RSS::ModWiki wants "major_change" to be set.
    13391359    $new_metadata{major_change} = ( $new_metadata{edit_type} eq "Normal edit" )
  • trunk/lib/OpenGuides/Utils.pm

    r1066 r1068  
    356356}
    357357
     358=item B<validate_edit>
     359
     360    eval { OpenGuides::Utils->validate_edit(
     361        id       => $node,
     362        content  => $content
     363        metadata => \%new_metadata
     364    ) };
     365
     366Checks supplied content for general validity. If anything is invalid,
     367dies with an error string suitable for reporting to the user.
     368
     369=cut
     370
     371sub validate_edit {
     372    my ( $self, %args ) = @_;
     373    die "Content missing\n" unless $args{content};
     374    die "Metadata missing\n" unless $args{metadata};
     375
     376};
     377
    358378=back
    359379
Note: See TracChangeset for help on using the changeset viewer.