Changeset 28 for trunk/lib/Vote/Model/Vote.pm
- Timestamp:
- 03/14/09 16:02:04 (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/lib/Vote/Model/Vote.pm
r27 r28 6 6 use Vote; 7 7 use DBI; 8 use Mail::Mailer; 8 9 9 10 =head1 NAME … … 637 638 638 639 sub mail_passwd_ifnul { 639 my ($self, $voteid ) = @_;640 my ($self, $voteid, $mailinfo) = @_; 640 641 641 642 my $list_voting = $self->db->prepare_cached( 642 q{select key from voting where poll = ? and passwd is null }643 q{select key from voting where poll = ? and passwd is null or passwd = ''} 643 644 ); 644 645 645 646 $list_voting->execute($voteid); 646 647 while (my $res = $list_voting->fetchrow_hashref) { 647 $self->mail_voting_passwd($res->{key} );648 $self->mail_voting_passwd($res->{key}, $mailinfo); 648 649 } 649 650 } 650 651 651 652 sub mail_voting_passwd { 652 my ($self, $id ) = @_;653 my ($self, $id, $mailinfo) = @_; 653 654 654 655 my $vinfo = $self->voting_info($id) or return; 655 656 656 my $voteinfo = $self->vote_info($vinfo->{poll}); 657 658 my $passwd = random_string(8); 659 my $encpasswd = $self->gen_enc_passwd($passwd); 660 661 my $upd_voting = $self->db->prepare_cached( 662 q{update voting set passwd = ? where key = ?} 663 ); 664 665 $upd_voting->execute($encpasswd, $id); 666 667 # TODO complete this properly: 668 my $mailer = new Mail::Mailer 'smtp', Server => 'mailhost'; 669 $mailer->open({ 670 From => 'Voting system <nomail@nomail.com>', 671 To => $vinfo->{mail}, 672 Subject => 'Vote passwd', 673 }); 674 print $mailer <<EOF; 675 Vous êtes convié à voter: 676 $voteinfo->{label} 677 678 Votre identifiant est: $vinfo->{id} 679 Votre mot de passe est: $passwd 680 681 Cordialement. 682 EOF 683 $mailer->close; 684 685 $self->db->commit; 657 686 } 658 687
Note: See TracChangeset
for help on using the changeset viewer.