--- loncom/interface/lonnotify.pm 2005/08/02 05:03:10 1.1 +++ loncom/interface/lonnotify.pm 2005/12/09 20:54:26 1.10 @@ -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,347 @@ 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'}; + my $origin = $env{'form.origin'}; + &Apache::lonhtmlcommon::clear_breadcrumbs(); + my %ltext=&Apache::lonlocal::texthash( + 'note' => 'Notification E-mail', + ); + my $function = &Apache::loncommon::get_users_function(); + my $loadcode; + my $tablecolor = &Apache::loncommon::designparm($function.'.tabbg'); + if ((defined($env{'form.origin'})) && ($command eq 'compose' || $command eq 'pick_target' || $command eq 'pick_display')) { + unless ($env{'form.origin'} eq '') { + $loadcode = 'javascript:setFormElements(document.'.$env{'form.command'}.')'; + if (($command eq 'pick_target') && ( + ($origin eq 'compose') || ($origin eq 'process'))) { + if ($env{'form.coursepick'} eq 'category') { + $loadcode .= ';javascript:setCourseCat(document.'.$env{'form.command'}.')'; + } + } + } + } + my $loaditems = ' onLoad="'.$loadcode.'" '; + my $bodytag = &Apache::loncommon::bodytag('Broadcast e-mail to users',$function,$loaditems); + 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,$command,$cdom,$tablecolor,$bodytag,$html,\%ltext); } elsif ($command eq 'compose') { - &print_composition_form($r,$cdom); + &print_composition_form($r,$command,$cdom,$tablecolor,$bodytag,$html,\%ltext); + } elsif ($command eq 'pick_target') { + &print_selection_form($r,$command,$cdom,$tablecolor,$bodytag,$html,\%ltext); + } elsif ($command eq 'pick_display') { + &print_display_option_form($r,$command,$cdom,$tablecolor,$bodytag,$html,\%ltext); + } elsif ($command eq 'display') { + &print_display($r,$command,$cdom,$tablecolor,$bodytag,$html,\%ltext); } else { - &print_selection_form($r,$cdom); + &print_front_page($r,'front',$cdom,$tablecolor,$bodytag,$html,\%ltext); } return OK; } +sub print_front_page { + my ($r,$formname,$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 +
+