From: Steinar H. Gunderson Date: Wed, 16 Feb 2005 14:33:30 +0000 (+0000) Subject: Make it possible to edit scores. X-Git-Url: https://git.sesse.net/?p=ccbs;a=commitdiff_plain;h=9e9977d8d73f4f28e6f8f3d6d1a007a859bc3955;ds=sidebyside Make it possible to edit scores. --- diff --git a/html/do-edit-scores.pl b/html/do-edit-scores.pl index 4b5d482..fe29c16 100755 --- a/html/do-edit-scores.pl +++ b/html/do-edit-scores.pl @@ -8,18 +8,25 @@ my $dbh = ccbs::db_connect(); my $cgi = new CGI; my $tournament = $cgi->param('tournament'); +my $round = $cgi->param('round'); +my $group = $cgi->param('group'); -# Loop through all parameters until we find the update button -my $player; -for my $param ($cgi->param()) { - if ($param =~ /^update(\d+)$/) { - $player = $1; - last; +$dbh->{AutoCommit} = 0; + +# Loop through all parameters and see what parameters differ between old- and current +# versions +for my $p ($cgi->param()) { + next if ($p =~ /^old-(.*?)$/); + next unless (defined($cgi->param('old-' . $p))); + next if ($cgi->param($p) eq $cgi->param('old-' . $p)); + + if ($p =~ /^score(\d+)-(\d+)/) { + $dbh->do('UPDATE scores SET score=? WHERE tournament=? AND round=? AND parallel=? AND player=? AND songnumber=?', undef, + $cgi->param($p), $tournament, $round, $group, $1, $2); } } -die "Form-submit uten å trykke på noen update-knapp?" unless (defined($player)); - +$dbh->commit; $dbh->disconnect; ccbs::print_see_other('show-tournament.pl?id=' . $tournament); diff --git a/html/templates/show-tournament.tmpl b/html/templates/show-tournament.tmpl index 074e21e..decfe5e 100644 --- a/html/templates/show-tournament.tmpl +++ b/html/templates/show-tournament.tmpl @@ -81,11 +81,13 @@ + [% ELSE %] + Gruppe [% p.parallel %] [% END %]