Changeset 182
- Timestamp:
- 04/11/09 03:55:22 (15 years ago)
- Location:
- trunk
- Files:
-
- 1 added
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MANIFEST
r181 r182 58 58 root/mail/poll_request.tt 59 59 root/mail/ballot_confirm.tt 60 root/mail/voting_passwd.tt 60 61 root/templates/admin/default.tt 61 62 root/templates/admin/denied.tt -
trunk/lib/Vote/Controller/Admin.pm
r176 r182 87 87 and $vote->db->commit; 88 88 } elsif($c->req->param('mailpasswd')) { 89 $vote->mail_passwd_ifnul($id, { 90 voteurl => $c->uri_for('/ballot', $id), 91 }); 89 # TODO 90 foreach my $vkey ($poll->list_voting_no_passwd) { 91 my $voting = $poll->voting($vkey); 92 my $pass = $voting->gen_passwd; 93 $c->forward( 94 q'Vote::View::Mail', 'render', 95 [ 'voting_passwd.tt', { 96 From => $poll->info->{owner}, 97 To => $voting->info->{mail}, 98 Subject => "Invitation à voter", 99 mail => { 100 voteid => $id, 101 mail => $voting->info->{mail}, 102 passwd => $pass, 103 } 104 } ] 105 ); 106 } 92 107 } 93 108 }; -
trunk/lib/Vote/DB.pm
r181 r182 286 286 } 287 287 288 sub mail_passwd_ifnul {289 my ($self, $voteid, $mailinfo) = @_;290 $self->poll($voteid)->mail_passwd_ifnul($mailinfo);291 }292 293 288 sub clean_old_poll_request { 294 289 my ($self) = @_; -
trunk/lib/Vote/DB/Poll.pm
r181 r182 811 811 } 812 812 813 sub mail_passwd_ifnul{814 my ($self , $mailinfo) = @_;813 sub list_voting_no_passwd { 814 my ($self) = @_; 815 815 816 816 my $list_voting = $self->db->prepare_cached( … … 819 819 820 820 $list_voting->execute($self->voteid); 821 my @ids; 821 822 while (my $res = $list_voting->fetchrow_hashref) { 822 $self->mail_voting_passwd($res->{key}, $mailinfo); 823 } 823 push(@ids, $res->{key}); 824 } 825 @ids 824 826 } 825 827 -
trunk/lib/Vote/DB/Voting.pm
r161 r182 5 5 use strict; 6 6 use warnings; 7 use Mail::Mailer;8 7 use base 'Vote::DB::common'; 9 8 use Vote::DB::Poll; … … 82 81 } 83 82 84 sub mail_voting_passwd { 85 my ($self, $mailinfo) = @_; 86 87 my $vinfo = $self->info or return; 88 my $voteinfo = $self->poll->info; 89 $voteinfo->{description} ||= ""; 90 83 sub gen_passwd { 84 my ($self) = @_; 91 85 my $passwd = Vote::DB::common::random_string(8); 92 86 my $encpasswd = $self->gen_enc_passwd($passwd); 93 94 87 my $upd_voting = $self->db->prepare_cached( 95 88 q{update voting set passwd = ? where key = ?} … … 97 90 98 91 $upd_voting->execute($encpasswd, $self->votingkey); 99 100 my $date = $voteinfo->{dstart} && $voteinfo->{dend}101 ? sprintf("\n" . 'Vous pourrez voter entre le %s %s et le %s %s' . "\n",102 $voteinfo->{dstart}, $voteinfo->{hstart}, $voteinfo->{dend}, $voteinfo->{hend})103 : '';104 105 # TODO complete this properly:106 my $mailer = new Mail::Mailer 'smtp', Server => (Vote->config->{smtp} || 'localhost');107 $ENV{MAILADDRESS} = $voteinfo->{owner};108 $mailer->open({109 From => $voteinfo->{owner},110 To => $vinfo->{mail},111 Subject => 'Invitation a voter: ' . $voteinfo->{label},112 'X-Epoll-poll' => $self->poll->voteid,113 Vote::DB::common::mail_header(),114 });115 print $mailer <<EOF;116 Vous êtes convié à participer a ce vote:117 118 --------119 $voteinfo->{label}120 --------121 $voteinfo->{description}122 --------123 124 à l'adresse:125 126 $mailinfo->{voteurl}127 $date128 129 --130 Votre identifiant est: $vinfo->{mail}131 Votre mot de passe est: $passwd132 133 Conservez précieusement ces identifiants, il ne vous seront pas retransmits.134 135 Cordialement.136 EOF137 $mailer->close or warn "couldn't send whole message: $!\n";138 139 92 $self->db->commit; 93 $passwd 140 94 } 141 95
Note: See TracChangeset
for help on using the changeset viewer.