Changeset 34
- Timestamp:
- 03/15/09 16:28:12 (15 years ago)
- Location:
- trunk
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/lib/Vote/Controller/Ballot.pm
r22 r34 36 36 } 37 37 38 my $ uid = $c->session->{uid} || $c->req->param('uid');38 my $mail = $c->session->{mail} || $c->req->param('mail'); 39 39 my $password = $c->session->{password} || $c->req->param('password'); 40 40 41 if (!$c->model('Vote')->auth_voting($id, $ uid, $password)) {41 if (!$c->model('Vote')->auth_voting($id, $mail, $password)) { 42 42 $c->delete_session('invalid user/pass'); 43 43 $c->stash->{template} = 'ballot/login.tt'; … … 45 45 } 46 46 47 $c->session->{ uid} = $uid;47 $c->session->{mail} = $mail; 48 48 $c->session->{password} = $password; 49 49 50 50 # login succeed, but those this user has already voted 51 if (my $date = $c->model('Vote')->voting_has_sign($id, $ uid)) {51 if (my $date = $c->model('Vote')->voting_has_sign($id, $mail)) { 52 52 $c->stash->{uid} = $c->session->{uid}; 53 53 $c->stash->{template} = 'ballot/signed.tt'; … … 92 92 if ($c->req->param('confirm')) { 93 93 $vote->register_ballot( 94 $ uid,94 $mail, 95 95 $id, 96 96 [ @sbalval ], -
trunk/lib/Vote/Model/Vote.pm
r33 r34 207 207 select *, voting.key as vkey from voting left join signing 208 208 on signing.key = voting.key 209 where poll = ? order by voting. id209 where poll = ? order by voting.mail 210 210 } 211 211 ); … … 219 219 220 220 sub vote_voting { 221 my ($self, $ id) = @_;221 my ($self, $voteid) = @_; 222 222 223 223 my $sth = $self->db->prepare_cached( 224 224 q{ 225 225 select key from voting 226 where poll = ? order by voting. id227 } 228 ); 229 $sth->execute($ id);226 where poll = ? order by voting.mail 227 } 228 ); 229 $sth->execute($voteid); 230 230 my @people; 231 231 while (my $res = $sth->fetchrow_hashref) { … … 246 246 ); 247 247 $sth->execute($id); 248 248 249 249 my $res = $sth->fetchrow_hashref; 250 250 $sth->finish; … … 330 330 331 331 sub voting_info_id { 332 my ($self, $ id, $voteid) = @_;333 334 my $sth = $self->db->prepare_cached( 335 q{ 336 select * from voting where id= ? and poll = ?337 } 338 ); 339 $sth->execute($ id, $voteid);332 my ($self, $mail, $voteid) = @_; 333 334 my $sth = $self->db->prepare_cached( 335 q{ 336 select * from voting where mail = ? and poll = ? 337 } 338 ); 339 $sth->execute($mail, $voteid); 340 340 my $res = $sth->fetchrow_hashref(); 341 341 $sth->finish; … … 344 344 345 345 sub _register_signing { 346 my ($self, $ vid, $voteid, $referal) = @_;347 348 my $vinfo = $self->voting_info_id($ vid, $voteid) or return;346 my ($self, $mail, $voteid, $referal) = @_; 347 348 my $vinfo = $self->voting_info_id($mail, $voteid) or return; 349 349 350 350 my $sth = $self->db->prepare_cached( … … 464 464 465 465 sub auth_voting { 466 my ($self, $poll, $ user, $password) = @_;467 my $userinfo = $self->voting_info_id($ user, $poll) or return;466 my ($self, $poll, $mail, $password) = @_; 467 my $userinfo = $self->voting_info_id($mail, $poll) or return; 468 468 469 469 $userinfo->{passwd} or return; … … 496 496 select date from signing join voting 497 497 on voting.key = signing.key 498 where poll = ? and id= ?498 where poll = ? and mail = ? 499 499 } 500 500 ); … … 618 618 619 619 sub addupd_voting { 620 my ($self, $voteid, $ id, $mail) = @_;620 my ($self, $voteid, $mail, $id) = @_; 621 621 622 622 my $upd = $self->db->prepare_cached( 623 623 q{ 624 update voting set mail = ? where poll = ? and id= ?624 update voting set label = ? where mail = ? and poll = ? 625 625 } 626 626 ); … … 628 628 if ($upd->execute($mail, $voteid, $id) == 0) { 629 629 my $add = $self->db->prepare_cached(q{ 630 insert into voting (poll, id, mail) values (?,?,?)630 insert into voting (poll, label, mail) values (?,?,?) 631 631 }); 632 632 … … 705 705 $voteinfo->{label} 706 706 707 Votre identifiant est: $vinfo->{ id}707 Votre identifiant est: $vinfo->{mail} 708 708 Votre mot de passe est: $passwd 709 709 -
trunk/root/templates/admin/default.tt
r29 r34 57 57 <form action="[% c.uri_for(voteid) %]"> 58 58 <input type="hidden" name="delvoting" value="[% voting.vkey %]"> 59 [% voting. id| html %] [% voting.mail | html %]59 [% voting.label | html %] [% voting.mail | html %] 60 60 [% IF voting.passwd %]<i>(pass envoyé)</i>[% END %] 61 61 <input type="submit" name="delete" value="delete"><br> -
trunk/root/templates/ballot/login.tt
r9 r34 1 1 <form action="[% c.uri_for(voteid) %]"> 2 <input type="text" name=" uid" value="[% c.req.param('uid') %]">2 <input type="text" name="mail" value="[% c.req.param('mail') %]"> 3 3 <input type="password" name="password" value=""> 4 4 <input type="submit"> -
trunk/root/templates/vote/default.tt
r21 r34 48 48 [% signing = [ vote.vote_signing(voteid) ] %] 49 49 [% FOREACH voting = signing %] 50 [% voting. id| html %] [% voting.date %]<br>50 [% voting.label | html %] [% voting.date %]<br> 51 51 [% END %] 52 52
Note: See TracChangeset
for help on using the changeset viewer.