--- loncom/interface/lonnotify.pm 2005/08/02 05:03:10 1.1 +++ loncom/interface/lonnotify.pm 2005/10/14 19:10:20 1.6 @@ -31,6 +31,9 @@ use Apache::lonsupportreq; use LONCAPA::Enrollment; use Apache::Constants qw(:common :http); use Apache::lonlocal; +use Mail::Send; +use HTML::TokeParser; +use HTML::Entities; sub handler { my ($r) = @_; @@ -40,31 +43,315 @@ sub handler { if ($r->header_only) { return OK; } -# my $codedom = $env{'request.role.domain'}; - my $cdom = 'northwood5'; - unless (&Apache::lonnet::allowed('psa',$env{'request.role.domain'})) { + my $cdom = $env{'request.role.domain'}; + unless (&Apache::lonnet::allowed('psa',$cdom)) { # Not allowed to broadcast e-mail system-wide $env{'user.error.msg'}="/adm/notify:psa:0:0:Cannot broadcast e-mail systemwide"; return HTTP_NOT_ACCEPTABLE; } + &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'}, + ['command']); my $command = $env{'form.command'}; &Apache::lonhtmlcommon::clear_breadcrumbs(); + my %ltext=&Apache::lonlocal::texthash( + 'note' => 'Notification E-mail', + ); + my $function = &Apache::loncommon::get_users_function(); + my $tablecolor = &Apache::loncommon::designparm($function.'.tabbg'); + my $bodytag = &Apache::loncommon::bodytag('Broadcast e-mail to users'); + my $html=&Apache::lonxml::xmlbegin(); &Apache::lonhtmlcommon::add_breadcrumb ({href=>'/adm/notify', - text=>"Broadcast e-mail"}); + text=>"Broadcast E-mail"}); if ($command eq 'process') { - &print_request_receipt($r,$cdom); + &print_request_receipt($r,$cdom,$tablecolor,$bodytag,$html,\%ltext); } elsif ($command eq 'compose') { - &print_composition_form($r,$cdom); + &print_composition_form($r,$cdom,$tablecolor,$bodytag,$html,\%ltext); + } elsif ($command eq 'pick_target') { + &print_selection_form($r,$cdom,$tablecolor,$bodytag,$html,\%ltext); + } elsif ($command eq 'pick_display') { + &print_display_option_form($r,$cdom,$tablecolor,$bodytag,$html,\%ltext); + } elsif ($command eq 'display') { + &print_display($r,$cdom,$tablecolor,$bodytag,$html,\%ltext); } else { - &print_selection_form($r,$cdom); + &print_front_page($r,$cdom,$tablecolor,$bodytag,$html,\%ltext); } return OK; } +sub print_front_page { + my ($r,$cdom,$tablecolor,$bodytag,$html,$ltext) = @_; + my $breadcrumbs = &Apache::lonhtmlcommon::breadcrumbs + (undef,'Broadcast e-mail to Domain','Broadcast_system_email'); + my $jscript = qq| +function next_page(caller) { + if (caller == 'view') { + document.front.command.value="pick_display" + } + else { + document.front.command.value="pick_target" + } + document.front.submit() +} + |; + my %lt=&Apache::lonlocal::texthash( + 'note' => 'Notification E-mail', + ); + my $output = <<"ENDONE"; +$html +
+