Changeset 17 for trunk/lib


Ignore:
Timestamp:
03/07/09 18:44:50 (15 years ago)
Author:
nanardon
Message:
  • check count of selected items
File:
1 edited

Legend:

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

    r16 r17  
    5959    $c->stash->{choices} = { %choices }; 
    6060    $c->stash->{sbal} = { map { $_ => 1 } $c->req->param('sbal') }; 
     61    $c->stash->{fsbal} = [ map { 
     62        s/^\s+//; 
     63        s/\s+$//; 
     64        s/\s+/ /g; 
     65        $_ 
     66    } ($c->req->param('fsbal')) ]; 
     67 
     68    my @torecord = grep { $_ } ( 
     69        (map { $choices{$_} } $c->req->param('sbal')), 
     70        @{ $c->stash->{fsbal} } 
     71    ); 
     72     
     73    warn $vote->vote_info($id)->{choice_count}; 
     74    warn scalar(@torecord); 
     75    warn $_ foreach(@torecord); 
     76    if (scalar(@torecord) > $vote->vote_info($id)->{choice_count}) { 
     77        $c->req->param('ballot', ''); 
     78        $c->stash->{vote_error} = 'Seulement ' . 
     79            $vote->vote_info($id)->{choice_count} . ' choix possible'; 
     80        return; 
     81    } 
    6182 
    6283    if ($c->req->param('confirm')) { 
     
    6485            $uid, 
    6586            $id, 
    66             [ grep { $_ } ( 
    67               map { $choices{$_} } $c->req->param('sbal'), 
    68               $c->req->param('fsbal'), 
    69             ) ], 
     87            [ @torecord ], 
    7088            $c->req->address, 
    7189        ); # TODO trap error 
Note: See TracChangeset for help on using the changeset viewer.