Changeset 19


Ignore:
Timestamp:
03/07/09 20:53:41 (15 years ago)
Author:
nanardon
Message:
  • check double value in ballot
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/lib/Vote/Controller/Ballot.pm

    r18 r19  
    6868        s/\s+$//; 
    6969        s/\s+/ /g; 
    70         $_ 
     70        lc($_) 
    7171    } ($c->req->param('fsbal')) ]; 
    7272 
     
    7676    ); 
    7777     
    78     warn $vote->vote_info($id)->{choice_count}; 
    79     warn scalar(@torecord); 
    80     warn $_ foreach(@torecord); 
    8178    if (scalar(@torecord) > $vote->vote_info($id)->{choice_count}) { 
    8279        $c->req->param('ballot', ''); 
     
    8481            $vote->vote_info($id)->{choice_count} . ' choix possible'; 
    8582        return; 
     83    } 
     84    { 
     85        my %uniq; 
     86        $uniq{lc($_)} foreach(@torecord); 
     87        if (scalar(keys %uniq) != scalar(@torecord)) { 
     88            $c->req->param('ballot', ''); 
     89            $c->stash->{vote_error} = 'Une valeur est en double'; 
     90            return; 
     91        } 
    8692    } 
    8793 
Note: See TracChangeset for help on using the changeset viewer.