Changeset 42 for trunk/lib/Vote/Model/Vote.pm
- Timestamp:
- 03/16/09 18:57:18 (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/lib/Vote/Model/Vote.pm
r38 r42 458 458 q{ 459 459 select count(*) from ballot where poll = ? 460 and id in (select id from ballot_item) and invalid = 'false' 460 and id in (select id from ballot_item) and 461 (invalid = 'false' or invalid is null) 461 462 } 462 463 ); … … 486 487 487 488 $vinfo->{password} or return; 488 warn $vinfo->{password};489 489 if (crypt($passwd, $vinfo->{password} || '') eq $vinfo->{password}) { 490 490 return 1; … … 537 537 my $sth = $self->db->prepare( 538 538 q{ 539 select count(ballot.id), value from ballot join ballot_item 540 on ballot.id = ballot_item.id where ballot.poll = ? and invalid = 'false' 541 group by value 539 select count(ballot.id), coalesce(corrected, value) as value 540 from ballot join ballot_item 541 on ballot.id = ballot_item.id where ballot.poll = ? and 542 (invalid = 'false' or invalid is null) 543 group by coalesce(corrected, value) 542 544 order by count desc 543 545 } … … 622 624 } 623 625 626 sub vote_ballot_untrusted_values { 627 my ($self, $voteid) = @_; 628 629 my $getval = $self->db->prepare_cached( 630 q{ 631 select value from ballot join ballot_item 632 on ballot.id = ballot_item.id 633 where poll = ? and fromlist = false 634 group by value order by value 635 } 636 ); 637 $getval->execute($voteid); 638 my @vals; 639 while (my $res = $getval->fetchrow_hashref) { 640 push(@vals, $res->{value}); 641 } 642 @vals 643 } 644 645 sub vote_ballot_values { 646 my ($self, $voteid) = @_; 647 648 my $getval = $self->db->prepare_cached( 649 q{ 650 select value from ballot join ballot_item 651 on ballot.id = ballot_item.id 652 where poll = ? 653 group by value order by value 654 } 655 ); 656 $getval->execute($voteid); 657 my @vals; 658 while (my $res = $getval->fetchrow_hashref) { 659 push(@vals, $res->{value}); 660 } 661 @vals 662 } 663 664 sub vote_map_value { 665 my ($self, $voteid, $from, $to) = @_; 666 667 my $sth = $self->db->prepare_cached( 668 q{ 669 update ballot_item set corrected = ? where 670 id in (select id from ballot where poll = ?) 671 and value = ? 672 } 673 ); 674 675 $sth->execute($to, $voteid, $from) or $self->db->rollback; 676 $self->db->commit; 677 } 678 624 679 sub addupd_voting { 625 680 my ($self, $voteid, $mail, $id) = @_; … … 631 686 ); 632 687 633 if ($upd->execute($ mail, $voteid, $id) == 0) {688 if ($upd->execute($id, $mail, $voteid) == 0) { 634 689 my $add = $self->db->prepare_cached(q{ 635 690 insert into voting (poll, label, mail) values (?,?,?)
Note: See TracChangeset
for help on using the changeset viewer.