Changeset 191


Ignore:
Timestamp:
04/14/09 02:07:40 (15 years ago)
Author:
nanardon
Message:
  • try to see if free choice aren't in list list already
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/lib/Vote/DB/Poll.pm

    r182 r191  
    336336} 
    337337 
     338sub find_choice_key { 
     339    my ($self, $value) = @_; 
     340 
     341    my $sth = $self->prepare_cached( 
     342        q{select key from choice where lower(label) = ? and poll = ?} 
     343    ); 
     344    $sth->execute(lc($value), $self->pollid); 
     345    my $res = $sth->fetchrow_hashref; 
     346    $sth->finish; 
     347    $res->{key} 
     348} 
     349 
    338350sub _register_ballot_items { 
    339351    my ($self, $uid, $choice, $fchoice) = @_; 
     
    352364    foreach (@{ $fchoice || []}) { 
    353365        $_ or next; 
    354         $addbc->execute($uid, $_, 'f') or do { 
     366        my $chkey = $self->find_choice_key($_); 
     367        $addbc->execute($uid, $_, $chkey ? 't' : 'f') or do { 
    355368            $self->db->rollback; 
    356369            return; 
Note: See TracChangeset for help on using the changeset viewer.