Changeset 88 for trunk/lib


Ignore:
Timestamp:
03/19/09 17:16:25 (15 years ago)
Author:
nanardon
Message:
  • send mail to confirm ballot registration
Location:
trunk/lib/Vote
Files:
2 edited

Legend:

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

    r82 r88  
    109109            $c->req->address, 
    110110        ); # TODO trap error 
     111        $vote->mail_ballot_confirm($mail, $id, { 
     112                ballotid => $c->stash->{ballotid}, 
     113                url => $c->uri_for('/vote', $id), 
     114        }); 
    111115        $c->stash->{template} = 'ballot/done.tt'; 
    112116        $c->delete_session('Vote terminé'); 
  • trunk/lib/Vote/Model/Vote.pm

    r87 r88  
    413413    $self->db->commit; 
    414414 
     415     
    415416    $uid 
     417} 
     418 
     419sub mail_ballot_confirm { 
     420    my ($self, $vid, $voteid, $info) = @_; 
     421    my $voteinfo = $self->vote_info($voteid) or return; 
     422    $info->{ballotid} or return; 
     423    my $mailer = new Mail::Mailer 'smtp', Server => (Vote->config->{smtp} || 'localhost'); 
     424    $mailer->open({ 
     425        From => $vid, # TODO allow to configure this 
     426        To => $vid, 
     427        Subject => 'Confirmation de vote: ' . $voteinfo->{label}, 
     428        mail_header(), 
     429    }); 
     430    print $mailer <<EOF; 
     431 
     432Vous venez de participer au vote: 
     433 
     434-------- 
     435$voteinfo->{label} 
     436-------- 
     437 
     438Votre bulletin est idéntifié sous le numéro: 
     439$info->{ballotid} 
     440 
     441Les résultats seront disponibles à cet url: 
     442$info->{url} 
     443 
     444Cordialement. 
     445EOF 
     446    $mailer->close 
     447        or warn "couldn't send whole message: $!\n"; 
     448 
    416449} 
    417450 
Note: See TracChangeset for help on using the changeset viewer.