Ignore:
Timestamp:
03/08/09 15:36:06 (15 years ago)
Author:
nanardon
Message:
  • mark untrusted ballot
File:
1 edited

Legend:

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

    r19 r20  
    6464    $c->stash->{choices} = { %choices }; 
    6565    $c->stash->{sbal} = { map { $_ => 1 } $c->req->param('sbal') }; 
    66     $c->stash->{fsbal} = [ map { 
     66    $c->stash->{fsbal} = [ grep { $_ } map { 
    6767        s/^\s+//; 
    6868        s/\s+$//; 
     
    7171    } ($c->req->param('fsbal')) ]; 
    7272 
    73     my @torecord = grep { $_ } ( 
    74         (map { $choices{$_} } $c->req->param('sbal')), 
    75         @{ $c->stash->{fsbal} } 
    76     ); 
    77      
    78     if (scalar(@torecord) > $vote->vote_info($id)->{choice_count}) { 
     73    my @sbalval = grep { $_ } map { $choices{$_} } $c->req->param('sbal'); 
     74 
     75    if (scalar(@sbalval) + scalar(@{$c->stash->{fsbal} || []}) 
     76        > $vote->vote_info($id)->{choice_count}) { 
    7977        $c->req->param('ballot', ''); 
    8078        $c->stash->{vote_error} = 'Seulement ' . 
     
    8482    { 
    8583        my %uniq; 
    86         $uniq{lc($_)} foreach(@torecord); 
    87         if (scalar(keys %uniq) != scalar(@torecord)) { 
     84        $uniq{lc($_)} = 1 foreach(@sbalval, @{$c->stash->{fsbal} || []}); 
     85        if (scalar(keys %uniq) != scalar(@sbalval) + scalar(@{$c->stash->{fsbal} || []})) { 
    8886            $c->req->param('ballot', ''); 
    8987            $c->stash->{vote_error} = 'Une valeur est en double'; 
     
    9694            $uid, 
    9795            $id, 
    98             [ @torecord ], 
     96            [ @sbalval ], 
     97            [ @{ $c->stash->{fsbal} } ], 
    9998            $c->req->address, 
    10099        ); # TODO trap error 
Note: See TracChangeset for help on using the changeset viewer.