| … | |
… | |
| 48 | $self->{rows} = (defined($r->param('rows'))) ? $r->param('rows') : $ce->{mail}->{editor_window_rows}; |
48 | $self->{rows} = (defined($r->param('rows'))) ? $r->param('rows') : $ce->{mail}->{editor_window_rows}; |
| 49 | $self->{columns} = (defined($r->param('columns'))) ? $r->param('columns') : $ce->{mail}->{editor_window_columns}; |
49 | $self->{columns} = (defined($r->param('columns'))) ? $r->param('columns') : $ce->{mail}->{editor_window_columns}; |
| 50 | $self->{default_msg_file} = $default_msg_file; |
50 | $self->{default_msg_file} = $default_msg_file; |
| 51 | $self->{old_default_msg_file} = $old_default_msg_file; |
51 | $self->{old_default_msg_file} = $old_default_msg_file; |
| 52 | $self->{merge_file} = (defined($r->param('merge_file' ))) ? $r->param('merge_file') : 'None'; |
52 | $self->{merge_file} = (defined($r->param('merge_file' ))) ? $r->param('merge_file') : 'None'; |
| 53 | $self->{preview_user} = (defined($r->param('preview_user'))) ? $r->param('preview_user') : 'Yourself'; |
53 | $self->{preview_user} = (defined($r->param('preview_user'))) ? $r->param('preview_user') : $user; |
| 54 | |
54 | |
| 55 | |
55 | |
| 56 | ############################################################################################# |
56 | ############################################################################################# |
| 57 | # gather database data |
57 | # gather database data |
| 58 | ############################################################################################# |
58 | ############################################################################################# |
| … | |
… | |
| 221 | ############################################################################################# |
221 | ############################################################################################# |
| 222 | # If form is submitted deal with filled out forms |
222 | # If form is submitted deal with filled out forms |
| 223 | # and various actions resulting from different buttons |
223 | # and various actions resulting from different buttons |
| 224 | ############################################################################################# |
224 | ############################################################################################# |
| 225 | |
225 | |
| 226 | |
|
|
| 227 | |
|
|
| 228 | # user_errors |
|
|
| 229 | # save |
|
|
| 230 | # save as |
|
|
| 231 | # save as default |
|
|
| 232 | # send mail |
|
|
| 233 | # set defaults |
|
|
| 234 | |
226 | |
| 235 | if ($action eq 'Save' or $action eq 'Save as:' or $action eq 'Save as Default') { |
227 | if ($action eq 'Save' or $action eq 'Save as:' or $action eq 'Save as Default') { |
| 236 | |
228 | |
| 237 | # warn "FIXME Saving files action = $action outputFileName=$output_file"; |
229 | # warn "FIXME Saving files action = $action outputFileName=$output_file"; |
| 238 | |
230 | |
| … | |
… | |
| 280 | warn "No recipients selected " unless @recipients; |
272 | warn "No recipients selected " unless @recipients; |
| 281 | # get merge file |
273 | # get merge file |
| 282 | my $merge_file = ( defined($self->{merge_file}) ) ? $self->{merge_file} : 'None'; |
274 | my $merge_file = ( defined($self->{merge_file}) ) ? $self->{merge_file} : 'None'; |
| 283 | my $delimiter = ','; |
275 | my $delimiter = ','; |
| 284 | my $rh_merge_data = $self->read_merge_file("$merge_file", "$delimiter"); |
276 | my $rh_merge_data = $self->read_merge_file("$merge_file", "$delimiter"); |
| 285 | warn "No data for merge file $merge_file" unless ref($rh_merge_data); |
277 | unless (ref($rh_merge_data) ) { |
|
|
278 | warn "no merge data file"; |
|
|
279 | $self->submission_error("Can't read merge file $merge_file. No message sent"); |
|
|
280 | return; |
|
|
281 | } ; |
|
|
282 | |
| 286 | |
283 | |
| 287 | foreach my $recipient (@recipients) { |
284 | foreach my $recipient (@recipients) { |
| 288 | #warn "FIXME sending email to $recipient"; |
285 | #warn "FIXME sending email to $recipient"; |
| 289 | my $ur = $self->{db}->getUser($recipient); |
286 | my $ur = $self->{db}->getUser($recipient); |
| 290 | my ($msg, $preview_header); |
287 | my ($msg, $preview_header); |
| … | |
… | |
| 304 | unless (ref $mailer->Open()) { |
301 | unless (ref $mailer->Open()) { |
| 305 | warn "Failed to open the mailer: $Mail::Sender::Error"; |
302 | warn "Failed to open the mailer: $Mail::Sender::Error"; |
| 306 | next; |
303 | next; |
| 307 | } |
304 | } |
| 308 | my $MAIL = $mailer->GetHandle() or warn "Couldn't get handle"; |
305 | my $MAIL = $mailer->GetHandle() or warn "Couldn't get handle"; |
| 309 | $msg = 'Hi ' . $msg; |
|
|
| 310 | print $MAIL $msg || warn "Couldn't print to $MAIL"; |
306 | print $MAIL $msg || warn "Couldn't print to $MAIL"; |
| 311 | close $MAIL || warn "Couldn't close $MAIL"; |
307 | close $MAIL || warn "Couldn't close $MAIL"; |
| 312 | #warn "FIXME mailed to ", $ur->email_address, "from $from subject $subject"; |
308 | #warn "FIXME mailed to ", $ur->email_address, "from $from subject $subject"; |
| 313 | |
309 | |
| 314 | } |
310 | } |
| 315 | |
|
|
| 316 | |
311 | |
| 317 | #&success; |
|
|
| 318 | |
|
|
| 319 | |
|
|
| 320 | } else { |
312 | } else { |
| 321 | warn "Didn't recognize button $action"; |
313 | warn "Didn't recognize button $action"; |
| 322 | } |
314 | } |
| 323 | |
315 | |
| 324 | |
316 | |
| … | |
… | |
| 458 | ), "\n",CGI::br(), |
450 | ), "\n",CGI::br(), |
| 459 | |
451 | |
| 460 | "Save file to: $output_file","\n",CGI::br(), |
452 | "Save file to: $output_file","\n",CGI::br(), |
| 461 | "\n", 'From:',' ', CGI::textfield(-name=>"from", -size=>30, -value=>$from, -override=>1), |
453 | "\n", 'From:',' ', CGI::textfield(-name=>"from", -size=>30, -value=>$from, -override=>1), |
| 462 | "\n", CGI::br(),'Reply-To: ', CGI::textfield(-name=>"replyTo", -size=>30, -value=>$replyTo, -override=>1), |
454 | "\n", CGI::br(),'Reply-To: ', CGI::textfield(-name=>"replyTo", -size=>30, -value=>$replyTo, -override=>1), |
| 463 | "\n", CGI::br(),'Subject: ', CGI::br(), CGI::textarea(-name=>'subject', -default=>$subject, -rows=>3,-columns=>35, -override=>1), |
455 | "\n", CGI::br(),'Subject: ', CGI::br(), CGI::textarea(-name=>'subject', -default=>$subject, -rows=>3,-columns=>30, -override=>1), |
| 464 | ), |
456 | ), |
| 465 | ############################################################################################# |
457 | ############################################################################################# |
| 466 | # second column |
458 | # second column |
| 467 | ############################################################################################# |
459 | ############################################################################################# |
| 468 | CGI::td({-align=>'left'}, |
460 | CGI::td({-align=>'left'}, |
| … | |
… | |
| 578 | # Utility methods |
570 | # Utility methods |
| 579 | ############################################################################## |
571 | ############################################################################## |
| 580 | sub submission_error { |
572 | sub submission_error { |
| 581 | my $self = shift; |
573 | my $self = shift; |
| 582 | my $msg = join( " ", @_); |
574 | my $msg = join( " ", @_); |
| 583 | $self->{submitError}= $msg; #CGI::b(HTML::Entities::encode($msg)); |
575 | $self->{submitError} .= CGI::br().$msg; #CGI::b(HTML::Entities::encode($msg)); |
| 584 | # qq{Please hit the "<B>Back</B>" button on your browser to |
576 | # qq{Please hit the "<B>Back</B>" button on your browser to |
| 585 | # try again, or notify your web master |
577 | # try again, or notify your web master |
| 586 | # if you believe this message is in error. |
578 | # if you believe this message is in error. |
| 587 | # }; |
579 | # }; |
| 588 | return; |
580 | return; |
| … | |
… | |
| 670 | # Takes a delimited file as a parameter and returns an |
662 | # Takes a delimited file as a parameter and returns an |
| 671 | # associative array with the first field as the key. |
663 | # associative array with the first field as the key. |
| 672 | # Blank lines are skipped. White space is removed |
664 | # Blank lines are skipped. White space is removed |
| 673 | my(@dbArray,$key,$dbString); |
665 | my(@dbArray,$key,$dbString); |
| 674 | my %assocArray = (); |
666 | my %assocArray = (); |
| 675 | return |
|
|
| 676 | local(*FILE); |
667 | local(*FILE); |
| 677 | if ($fileName eq 'None') { |
668 | if ($fileName eq 'None') { |
| 678 | # do nothing |
669 | # do nothing |
| 679 | }elsif ( open(FILE, "$filePath") ) { |
670 | } elsif ( open(FILE, "$filePath") ) { |
| 680 | my $index=0; |
671 | my $index=0; |
| 681 | while (<FILE>){ |
672 | while (<FILE>){ |
| 682 | unless ($_ =~ /\S/) {next;} ## skip blank lines |
673 | unless ($_ =~ /\S/) {next;} ## skip blank lines |
| 683 | chomp; |
674 | chomp; |
| 684 | @{$dbArray[$index]} =$self->getRecord($_,$delimiter); |
675 | @{$dbArray[$index]} =$self->getRecord($_,$delimiter); |