Changeset 224
- Timestamp:
- 04/20/09 05:45:33 (15 years ago)
- Location:
- trunk
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/lib/Vote/Controller/Admin.pm
r221 r224 122 122 123 123 /^AFTER$/ and do { 124 if ($c->req->param('mapfrom') && $c->req->param('mapto')) {124 if ($c->req->param('mapfrom')) { 125 125 $poll->map_value( 126 $id,127 126 $c->req->param('mapfrom'), 128 $c->req->param('mapto') ,127 $c->req->param('mapto') || undef, 129 128 ); 130 129 } -
trunk/lib/Vote/DB/Poll.pm
r219 r224 573 573 select value from ballot join ballot_item 574 574 on ballot.id = ballot_item.id 575 where poll = ? and fromlist = false and corrected is null575 where poll = ? and fromlist = false 576 576 group by value order by value 577 577 } … … 604 604 } 605 605 606 sub value_map_to { 607 my ($self, $from) = @_; 608 my $sth = $self->db->prepare_cached( 609 q{select "to" from ballot_map where poll = ? and "from" = ?} 610 ); 611 $sth->execute($self->voteid, $from); 612 my $res = $sth->fetchrow_hashref; 613 $sth->finish; 614 $res->{to} 615 } 616 606 617 sub map_value { 607 618 my ($self, $from, $to) = @_; 608 619 609 my $sth = $self->db->prepare_cached( 610 q{ 611 insert into ballot_map (poll, "from", "to") values (?,?,?) 612 } 613 ); 614 615 $sth->execute($self->voteid, $from, $to) or $self->rollback; 620 if (!$to) { 621 my $sth = $self->db->prepare_cached( 622 q{delete from ballot_map where poll = ? and "from" = ?} 623 ); 624 $sth->execute($self->voteid, $from); 625 } else { 626 my $sthup = $self->db->prepare_cached( 627 q{update ballot_map set "to" = ? where poll = ? and "from" = ?} 628 ); 629 if ($sthup->execute($to, $self->voteid, $from) == 0) { 630 my $sth = $self->db->prepare_cached( 631 q{ 632 insert into ballot_map (poll, "from", "to") values (?,?,?) 633 } 634 ); 635 636 $sth->execute($self->voteid, $from, $to) or $self->rollback; 637 } 638 } 616 639 $self->commit; 617 640 } -
trunk/root/templates/admin/includes/ballot_validation.tt
r223 r224 16 16 <input type="hidden" name="mapfrom" value="[% untrusted | html %]"> 17 17 <select name="mapto"> 18 <option></option> 18 19 [% FOREACH v = poll.ballot_values %] 19 20 [% NEXT IF v == untrusted %] 20 <option >[% v | html %]</options>21 <option[% " selected" IF poll.value_map_to(untrusted) == v %]>[% v | html %]</options> 21 22 [% END %] 22 23 </select>
Note: See TracChangeset
for help on using the changeset viewer.