[system] / branches / rel-2-3-dev / webwork-modperl / lib / WeBWorK / ContentGenerator / Instructor / SendMail.pm Repository:
ViewVC logotype

Diff of /branches/rel-2-3-dev/webwork-modperl/lib/WeBWorK/ContentGenerator/Instructor/SendMail.pm

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 4933 Revision 4934
388 } elsif ($action eq 'Send Email') { 388 } elsif ($action eq 'Send Email') {
389 $self->{response} = 'send_email'; 389 $self->{response} = 'send_email';
390 390
391 # check that recipients have been selected. 391 # check that recipients have been selected.
392 my @recipients = @{$self->{ra_send_to}}; 392 my @recipients = @{$self->{ra_send_to}};
393 $self->addbadmessage(CGI::p("No recipients selected ")) unless @recipients;
394 # get merge file
395 my $merge_file = ( defined($self->{merge_file}) ) ? $self->{merge_file} : 'None';
396 my $delimiter = ',';
397 my $rh_merge_data = $self->read_scoring_file("$merge_file", "$delimiter");
398 unless (ref($rh_merge_data) ) {
399 $self->addbadmessage(CGI::p("No merge data file"));
400 $self->addbadmessage(CGI::p("Can't read merge file $merge_file. No message sent"));
401 return;
402 } ;
403 if (@recipients) { 393 if (@recipients) {
394 # get merge file
395 my $merge_file = ( defined($self->{merge_file}) ) ? $self->{merge_file} : 'None';
396 my $delimiter = ',';
397 my $rh_merge_data = $self->read_scoring_file("$merge_file", "$delimiter");
398 unless (ref($rh_merge_data) ) {
399 $self->addbadmessage(CGI::p("No merge data file"));
400 $self->addbadmessage(CGI::p("Can't read merge file $merge_file. No message sent"));
401 return;
402 } ;
403 if (@recipients) {
404 $self->{rh_merge_data} = $rh_merge_data; 404 $self->{rh_merge_data} = $rh_merge_data;
405 $self->{smtpServer} = $ce->{mail}->{smtpServer}; 405 $self->{smtpServer} = $ce->{mail}->{smtpServer};
406 my $post_connection_action = sub { 406 my $post_connection_action = sub {
407 my $r = shift; 407 my $r = shift;
408 my $result_message = $self->mail_message_to_recipients(); 408 my $result_message = $self->mail_message_to_recipients();
409 $self->email_notification($result_message); 409 $self->email_notification($result_message);
410 }; 410 };
411 if (MP2) { 411 if (MP2) {
412 $r->connection->pool->cleanup_register($post_connection_action); 412 $r->connection->pool->cleanup_register($post_connection_action);
413 } else { 413 } else {
414 $r->post_connection($post_connection_action); 414 $r->post_connection($post_connection_action);
415 }
415 } 416 }
417 } else {
418 $self->addbadmessage(CGI::p("No recipients selected. Please select one or more recipients from the list below."));
416 } 419 }
417# foreach my $recipient (@recipients) { 420# foreach my $recipient (@recipients) {
418# #warn "FIXME sending email to $recipient"; 421# #warn "FIXME sending email to $recipient";
419# my $ur = $self->{db}->getUser($recipient); #checked 422# my $ur = $self->{db}->getUser($recipient); #checked
420# die "record for user $recipient not found" unless $ur; 423# die "record for user $recipient not found" unless $ur;
475 return CGI::div({class=>"ResultsWithError"}, CGI::p("You are not authorized to send mail to students")) 478 return CGI::div({class=>"ResultsWithError"}, CGI::p("You are not authorized to send mail to students"))
476 unless $authz->hasPermissions($user, "send_mail"); 479 unless $authz->hasPermissions($user, "send_mail");
477 480
478 if ($response eq 'preview') { 481 if ($response eq 'preview') {
479 $self->print_preview($setID); 482 $self->print_preview($setID);
480 } elsif (($response eq 'send_email')){ 483 } elsif ($response eq 'send_email' and $self->{ra_send_to} and @{$self->{ra_send_to}}){
481 my $message = CGI::i("Email is being sent to ". scalar(@{$self->{ra_send_to}})." recipients. You will be notified" 484 my $message = CGI::i("Email is being sent to ". scalar(@{$self->{ra_send_to}})." recipient(s). You will be notified"
482 ." by email when the task is completed. This may take several minutes if the class is large." 485 ." by email when the task is completed. This may take several minutes if the class is large."
483 ); 486 );
484 $self->addgoodmessage($message); 487 $self->addgoodmessage($message);
485 $self->{message} .= $message; 488 $self->{message} .= $message;
486 489

Legend:
Removed from v.4933  
changed lines
  Added in v.4934

aubreyja at gmail dot com
ViewVC Help
Powered by ViewVC 1.0.9