--- loncom/interface/lonnotify.pm 2005/12/10 00:46:34 1.11 +++ loncom/interface/lonnotify.pm 2006/03/16 20:09:35 1.12 @@ -56,9 +56,7 @@ sub handler { 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'); @@ -75,30 +73,59 @@ sub handler { } 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"}); if ($command eq 'process') { - &print_request_receipt($r,$command,$cdom,$tablecolor,$bodytag,$html,\%ltext); + &print_request_receipt($r,$command,$cdom,$tablecolor,$bodytag); } elsif ($command eq 'compose') { - &print_composition_form($r,$command,$cdom,$tablecolor,$bodytag,$html,\%ltext); + &print_composition_form($r,$command,$cdom,$tablecolor,$bodytag); } elsif ($command eq 'pick_target') { - &print_selection_form($r,$command,$cdom,$tablecolor,$bodytag,$html,\%ltext); + &print_selection_form($r,$command,$cdom,$tablecolor,$bodytag); } elsif ($command eq 'pick_display') { - &print_display_option_form($r,$command,$cdom,$tablecolor,$bodytag,$html,\%ltext); + &print_display_option_form($r,$command,$cdom,$tablecolor,$bodytag); } elsif ($command eq 'display') { - &print_display($r,$command,$cdom,$tablecolor,$bodytag,$html,\%ltext); + &print_display($r,$command,$cdom,$tablecolor,$bodytag); } else { - &print_front_page($r,'front',$cdom,$tablecolor,$bodytag,$html,\%ltext); + &print_front_page($r,'front',$cdom,$tablecolor,$bodytag); } return OK; } +sub add_script { + my ($js) = @_; + return ''; +} + +sub start_page { + my ($jscript,$bodytag,$bread_title,$formname) = @_; + + my $html = &Apache::lonxml::xmlbegin(); + + my $head = &Apache::loncommon::head('Notification E-mail',$jscript); + + my $breadcrumbs = + &Apache::lonhtmlcommon::breadcrumbs(undef,$bread_title, + 'Broadcast_system_email'); + my $output = <<"ENDONE"; +$html +$head +$bodytag +$breadcrumbs +
+
+ENDONE + + return $output; +} + +sub end_page { + return '
'.&Apache::loncommon::end_page(); +} + 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 ($r,$formname,$cdom,$tablecolor,$bodytag) = @_; + my $jscript = qq| function next_page(caller) { if (caller == 'view') { @@ -110,23 +137,11 @@ function next_page(caller) { document.front.submit() } |; - my %lt=&Apache::lonlocal::texthash( - 'note' => 'Notification E-mail', - ); - my $output = <<"ENDONE"; -$html - - LON-CAPA $lt{'note'} - - -$bodytag -$breadcrumbs -
-ENDONE - $output .= '
'. - ''; + + my $output = &start_page(&add_script($jscript), $bodytag, + 'Broadcast e-mail to Domain', $formname); + + $output .= ''; $output .= &Apache::lonhtmlcommon::start_pick_box(); $output .= ''. '
'. @@ -135,29 +150,23 @@ ENDONE 'Display e-mail sent by Domain Coordinators in this domain'. '
'; $output .= &Apache::lonhtmlcommon::end_pick_box(); - $output .= qq( -
- -); + $output .= &end_page(); + $r->print($output); return; } sub print_display_option_form { - my ($r,$formname,$cdom,$tablecolor,$bodytag,$html,$ltext) = @_; - &Apache::lonhtmlcommon::add_breadcrumb - ({text=>"Display options"}); - my $breadcrumbs = &Apache::lonhtmlcommon::breadcrumbs - (undef,'Broadcast e-mail display options','Broadcast_system_email'); + my ($r,$formname,$cdom,$tablecolor,$bodytag) = @_; + &Apache::lonhtmlcommon::add_breadcrumb({text=>"Display options"}); + my $table_width = ''; my $col_width = '200'; my $cmd = 'display'; my $submit_text = 'Display e-mail'; my @roles = ('dc'); my $now = time; - my %lt=&Apache::lonlocal::texthash( - 'note' => 'Notification E-mail', - ); + my $startdateform = &Apache::lonhtmlcommon::date_setter($formname, 'startdate', $now); @@ -180,19 +189,10 @@ sub print_display_option_form { sender => 'checkbox', ); my $jscript = &Apache::lonhtmlcommon::set_form_elements(\%elements); - my $output = <<"ENDONE"; -$html - - LON-CAPA $lt{'note'} - - -$bodytag -$breadcrumbs -
-
-ENDONE + + my $output = &start_page(&add_script($jscript), $bodytag, + 'Broadcast e-mail display options', $formname); + $output .= &Apache::lonhtmlcommon::start_pick_box($table_width); $output .= &Apache::lonhtmlcommon::row_title($col_width,$tablecolor,&mt('Date range')); $output .= '
Earliest to display: '. @@ -228,13 +228,12 @@ ENDONE } sub print_display { - my ($r,$formname,$cdom,$tablecolor,$bodytag,$html,$ltext) = @_; + my ($r,$formname,$cdom,$tablecolor,$bodytag) = @_; &Apache::lonhtmlcommon::add_breadcrumb ({href=>"javascript:goBack('pick_display')", text=>"Display options"}, {text=>"E-mail display"}); - my $breadcrumbs = &Apache::lonhtmlcommon::breadcrumbs - (undef,'Display Broadcast e-mail','Broadcast_system_email'); + my $table_width = ''; my $col_width = '200'; my $rowColor1 = "#ffffff"; @@ -259,19 +258,9 @@ function goBack(target) { } ENDSCRIPT - my $output = <<"ENDONE"; -$html - - LON-CAPA $$ltext{'note'} - - -$bodytag -$breadcrumbs -
- -ENDONE + + my $output = &start_page(&add_script($jscript), $bodytag, + 'Display Broadcast e-mail', $formname); foreach my $msgid (keys(%sentmail)) { my %content = &Apache::lonmsg::unpackagemsg($sentmail{$msgid}); @@ -388,7 +377,7 @@ ENDONE } sub print_selection_form { - my ($r,$formname,$cdom,$tablecolor,$bodytag,$html,$ltext) = @_; + my ($r,$formname,$cdom,$tablecolor,$bodytag) = @_; my %coursecodes = (); my %codes = (); my @codetitles = (); @@ -404,7 +393,6 @@ sub print_selection_form { my $table_width = '100%'; my $col_width = '200'; my %lt=&Apache::lonlocal::texthash( - 'note' => 'Notification E-mail', 'buil' => 'Building valid e-mail address from username, if missing from preferences:', 'kerb' => 'Kerberos: enter default for each realm used in the domain, with comma separation of entries', 'infs' => 'Internal, Filesystem and Local authentication: enter single default.', @@ -423,8 +411,6 @@ sub print_selection_form { } } - my $breadcrumbs = &Apache::lonhtmlcommon::breadcrumbs - (undef,'Choose e-mail audience','Broadcast_system_email'); my $cb_jscript = &Apache::loncommon::coursebrowser_javascript($cdom); my %elements = ( @@ -474,20 +460,11 @@ function setCourseCat(formname) { } |; } - my $output = <<"ENDONE"; -$html - - LON-CAPA $lt{'note'} - -$cb_jscript - -$bodytag -$breadcrumbs -
- -ENDONE + + + my $output = &start_page(&add_script($jscript).$cb_jscript, + $bodytag, 'Choose e-mail audience', $formname); + $output .= &Apache::lonhtmlcommon::start_pick_box($table_width); my @roles = ('ow','cc','in','ta','ep','st','cr'); my %longtypes = (); @@ -515,7 +492,7 @@ ENDONE } sub print_composition_form { - my ($r,$formname,$cdom,$tablecolor,$bodytag,$html,$ltext) = @_; + my ($r,$formname,$cdom,$tablecolor,$bodytag) = @_; &Apache::lonhtmlcommon::add_breadcrumb ({href=>"javascript:goBack('pick_target')", text=>"Select Audience"}, @@ -527,11 +504,8 @@ function goBack(target) { document.$formname.submit(); } |; - my $breadcrumbs = (&Apache::lonhtmlcommon::breadcrumbs - (undef,'Broadcast e-mail to users','Broadcast_system_email')); my %lt=&Apache::lonlocal::texthash( - 'note' => 'Notification E-mail', 'nore' => 'No recipients identified', 'emad' => 'e-mail address', ); @@ -543,17 +517,9 @@ function goBack(target) { ); $jscript .= &Apache::lonhtmlcommon::set_form_elements(\%elements); - $r->print(< - LON-CAPA $lt{'note'} - - -$bodytag $breadcrumbs -
-ENDONE + $r->print(&start_page(&add_script($jscript), $bodytag, + 'Broadcast e-mail to users', $formname)); + my $coursefilter = $env{'form.coursepick'}; my %courses = (); if ($coursefilter eq 'all') { @@ -646,7 +612,7 @@ ENDONE } } } - my $output = ''."\n"; + my $output; if ($totalrecip > 0) { $output .= &Apache::lonhtmlcommon::start_pick_box($table_width); @@ -700,7 +666,7 @@ ENDONE sub print_request_receipt { - my ($r,$formname,$dom,$tablecolor,$bodytag,$html,$ltext) =@_; + my ($r,$formname,$dom,$tablecolor,$bodytag) =@_; my @recipients = &Apache::loncommon::get_env_multiple('form.recipient'); my $subject = $env{'form.subject'}; my $message = $env{'form.message'}; @@ -711,6 +677,7 @@ function goBack(target) { document.$formname.submit(); } ENDSCRIPT + &Apache::lonhtmlcommon::add_breadcrumb ({href=>"javascript:goBack('pick_target')", text=>"Select audience"}); @@ -720,21 +687,11 @@ ENDSCRIPT &Apache::lonhtmlcommon::add_breadcrumb ({href=>"/adm/notify?command=process", text=>"Outcome"}); - my $breadcrumbs = &Apache::lonhtmlcommon::breadcrumbs - (undef,'E-mail Delivery','Broadcast_system_email'); - my $output = < - LON-CAPA Notification E-mail - - -$bodytag -$breadcrumbs -
- -ENDONE + + + my $output = &start_page(&add_script($jscript), $bodytag, + 'E-mail Delivery', $formname); + $output .= &Apache::lonhtmlcommon::start_pick_box(); my @deliveries = (); &broadcast_email(\@recipients,$subject,$from,$message,\@deliveries); @@ -780,7 +737,7 @@ ENDONE } sub broadcast_email { - my ($recipients,$subject,$from,$message,$deliveries,$ltext)=@_; + my ($recipients,$subject,$from,$message,$deliveries)=@_; # Should implement staggered delivery for large numbers of recipients?. foreach my $user (@{$recipients}) { my $msg = new Mail::Send; @@ -827,7 +784,7 @@ sub get_user_info { } sub form_elements { - my ($longtypes,$authtypes,$ltext) = @_; + my ($longtypes,$authtypes) = @_; %{$longtypes} = ( active => 'Currently has access', previous => 'Previously had access', @@ -844,7 +801,7 @@ sub form_elements { } sub store_mail { - my ($subject,$message,$domain,$recipients,$attachmenturl,$ltext) = @_; + my ($subject,$message,$domain,$recipients,$attachmenturl) = @_; my $msgid; ($msgid,$message) = &Apache::lonmsg::packagemsg($subject,$message,undef,undef, $attachmenturl,$recipients,undef,undef,'dcmail');