<%init> our($dbh,%session); <%args> $example => undef $content => undef $word => undef % unless(defined($session{'username'})) { You ought not have been able to view this page, as you aren't logged in! % return; % } % unless(defined($example)) { You'll need to specify a valsi to add examples. How about you go to the right page and follow the link instead of playing around? % return; % } <%method title> Editing example % unless(defined($content)) { <%perl> <%perl> my $examplequery = $dbh->prepare("SELECT * FROM convenientexamples WHERE exampleid=?"); $examplequery->execute( $example ); my $examplerow = $examplequery->fetchrow_hashref; Editing example for valsi "<% $examplerow->{'word'} %>".
Example ID: <% $examplerow->{'exampleid'} %>
% if(defined($examplerow)) {
Example
% } else {

The example you requested to edit doesn't exist. Sorry.

% } % } else { Updating example record for "<% $word %>".
<%perl> # Send e-mail to the definition creator. my $valsiid = $dbh->selectrow_array("SELECT valsiid FROM example WHERE exampleid = ?", undef, $example); my $definitionid = $dbh->selectrow_array("SELECT definitionid FROM example WHERE exampleid = ?", undef, $example); # Send e-mail to the valsi creator, and all definition creators for that valsi my @email; push @email, $dbh->selectrow_array("SELECT u.email FROM valsi v, users u WHERE v.userid = u.userid AND v.valsiid=$valsiid"); # And the example creator(s) too! push @email, $dbh->selectrow_array("SELECT u.email FROM example e, users u WHERE e.userid = u.userid AND e.valsiid=$valsiid"); my $emailquery = $dbh->prepare( "SELECT u.email FROM definitions d, users u WHERE d.userid = u.userid AND d.valsiid=?" ); $emailquery->execute($valsiid); while( defined(my $emailrow=$emailquery->fetchrow_hashref) ) { push @email, $emailrow->{'email'}; } @email = keys %{{ map { $_ => 1 } @email }}; my $word = $dbh->selectrow_array( "SELECT word FROM valsi WHERE valsiid=$valsiid"); my $oldcontent = $dbh->selectrow_array("SELECT content FROM example WHERE exampleid = ?", undef, $example); utils::sendemail( \@email, "Example Edited At Word $word", " In jbovlaste, the user $session{'username'} has edited the following example at $word: Former content: $oldcontent New content: $content You can go to to see it. ", $session{'username'} ); $dbh->do("UPDATE example SET content = ?, time = ? WHERE exampleid = ?", { }, $content, time(), $example);

Done.

Return to where you were.

% }