<%args> $valsi => undef $content => undef $definition => 0 <%shared> our $titlestr; <%method title> <% $titlestr %> <%init> our(%session,$dbh); my $pullwordquery = $dbh->prepare("SELECT word FROM valsi WHERE valsiid=?"); % unless(defined($session{'username'})) { Must be logged in
You ought not have been able to view this page, as you aren't logged in! % $titlestr = "Adding example: Not logged in"; % return; % } % unless(defined($valsi)) { Must specify a word to add an example for
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? % $titlestr = "Adding example: Didn't specify valsi"; % return; % } % unless(defined($content)) { <%perl> $pullwordquery->execute($valsi); my $resultrow = $pullwordquery->fetchrow_arrayref; $titlestr = sprintf('Adding example for "%s"',$resultrow->[0]); Adding example for "<% $resultrow->[0] %>"
Example Try to keep the example it as short as possible. See the example help for a description of all the relevant notation, etc. Note that an example must be a valid Lojban utterance.
% } else { Storing example
<%perl> my $exampleNum = $dbh->selectrow_array("SELECT max(exampleNum) + 1 FROM example WHERE valsiid=$valsi AND definitionid=$definition\n"); if (! defined($exampleNum)) { $exampleNum=1 } $dbh->do("INSERT INTO example (valsiid, content, time, userid, definitionId, exampleNum ) VALUES (?, ?, ?, ?, ?, ?)", undef, $valsi, $content, time(), $session{'userid'}, $definition, $exampleNum); # 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=$valsi"); # 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=$valsi"); my $emailquery = $dbh->prepare( "SELECT u.email FROM definitions d, users u WHERE d.userid = u.userid AND d.valsiid=?" ); $emailquery->execute($valsi); 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=$valsi"); utils::sendemail( \@email, "Example Added To Word $word", " In jbovlaste, the user $session{'username'} has added the following example to $word: $content You can go to to see it. ", $session{'username'} );

Example added.

<%perl> $pullwordquery->execute($valsi); my $resultrow = $pullwordquery->fetchrow_arrayref; $titlestr = sprintf('Storing example for "%s"',$resultrow->[0]);

Return to the <% $resultrow->[0] %> record.

% }