%args> $meaning => undef $notes => undef $word => undef $wordid => undef $valid => undef %args> <%init> our(%session,$dbh); my $lang = $dbh->selectrow_array("SELECT tag FROM languages l, natlangwords nlw where nlw.wordid=$wordid AND l.langid=nlw.langid"); %init> <%shared> our $titlestr; %shared> <%method title> <% $titlestr %> %method> <%perl> if( ! defined( $word ) ) { $word = $dbh->selectrow_array("SELECT word FROM natlangwords where wordid=$wordid"); } unless(defined($session{'username'})) { %perl> Not logged in
Important: Make sure you understand what sort of data should be fed into this by reading the help section on natural language words.
% } else { % $titlestr = "Storing new natural language word";Here we go...
<%perl> my $ok = 1; my $langid = $dbh->selectrow_array("SELECT langid FROM languages WHERE tag=?", undef, $lang); my $query = $dbh->prepare("SELECT * FROM natlangwords WHERE word=? AND langid=$langid"); $query->execute($word); $meaning =~ s/^\s+//g; $meaning =~ s/\s+$//g; while (defined(my $row = $query->fetchrow_hashref) && $ok ) { if( (length($meaning) == 0) ) { %perl>This word is already defined, but you are trying to add a definition with a default meaning (i.e. you put nothing in the "in the sense of" box).
The problem here is that the existence of a default meaning implies that no differentiation from that meaning is reasonable. Since another definition exists, this is patently false.
Please go look at other definitions for this word, and see if any of them work for you.
If not, you're just going to have to go back and narrow the sense of the word.
<%perl> $ok = 0; } elsif ( ($row->{'wordid'} != $wordid) && $row->{'meaning'} eq $meaning ) { $m->out("Another copy of this word already exists with that meaning...
"); $ok = 0; } } if($ok) { # Get the old info my $oldmeaning = $dbh->selectrow_array("SELECT meaning FROM natlangwords WHERE wordid = ?", undef, $wordid); my $oldnotes = $dbh->selectrow_array("SELECT notes FROM natlangwords WHERE wordid = ?", undef, $wordid); if(length($meaning)) { $dbh->do("UPDATE natlangwords SET word=?, meaning=?, notes=? WHERE wordid=?", undef, $word, $meaning, $notes, $wordid); } else { $dbh->do("UPDATE natlangwords SET word=?, meaning=null, notes=? WHERE wordid=?", undef, $word, $notes, $wordid); } # Send e-mail to the word creator(s) my @email; push @email, $dbh->selectrow_array("SELECT u.email FROM natlangwords nlw, users u WHERE nlw.userid = u.userid AND nlw.word=? AND nlw.langid = ?", undef, $word, $langid ); # Get language info my $langtag = $dbh->selectrow_array("SELECT tag FROM languages WHERE langid = ?", undef, $langid); my $langname = $dbh->selectrow_array("SELECT realname FROM languages WHERE langid = ?", undef, $langid); @email = keys %{{ map { $_ => 1 } @email }}; utils::sendemail( \@email, "Edited NatLang Word $word", " In jbovlaste, the user $session{'username'} has edited the natural language word $word in the language $langname: Old Content: In Sense: $oldmeaning Notes: $oldnotes New Content: In Sense: $meaning Notes: $notes You can go toNo errors? Excellent.
Go to the page for the word you edited.
% } else {We were unable to add the new word.
% } % }