[LON-CAPA-cvs] cvs: loncom /interface lonnotify.pm

albertel lon-capa-cvs@mail.lon-capa.org
Thu, 16 Mar 2006 20:27:31 -0000


albertel		Thu Mar 16 15:27:31 2006 EDT

  Modified files:              
    /loncom/interface	lonnotify.pm 
  Log:
  - moving body tag production into the page starting routine
  
  
Index: loncom/interface/lonnotify.pm
diff -u loncom/interface/lonnotify.pm:1.13 loncom/interface/lonnotify.pm:1.14
--- loncom/interface/lonnotify.pm:1.13	Thu Mar 16 15:13:06 2006
+++ loncom/interface/lonnotify.pm	Thu Mar 16 15:27:26 2006
@@ -58,36 +58,23 @@
     &Apache::lonhtmlcommon::clear_breadcrumbs();
 
     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);
+
     &Apache::lonhtmlcommon::add_breadcrumb
         ({href=>'/adm/notify',
           text=>"Broadcast E-mail"});
     if ($command eq 'process') {
-        &print_request_receipt($r,$command,$cdom,$tablecolor,$bodytag);
+        &print_request_receipt($r,$command,$cdom,$tablecolor);
     } elsif ($command eq 'compose') {
-        &print_composition_form($r,$command,$cdom,$tablecolor,$bodytag);
+        &print_composition_form($r,$command,$cdom,$tablecolor);
     } elsif ($command eq 'pick_target') {
-        &print_selection_form($r,$command,$cdom,$tablecolor,$bodytag);
+        &print_selection_form($r,$command,$cdom,$tablecolor);
     } elsif ($command eq 'pick_display') {
-        &print_display_option_form($r,$command,$cdom,$tablecolor,$bodytag);
+        &print_display_option_form($r,$command,$cdom,$tablecolor);
     } elsif ($command eq 'display') {
-        &print_display($r,$command,$cdom,$tablecolor,$bodytag);
+        &print_display($r,$command,$cdom,$tablecolor);
     } else {
-        &print_front_page($r,'front',$cdom,$tablecolor,$bodytag);
+        &print_front_page($r,'front',$cdom,$tablecolor);
     }
     return OK;
 }
@@ -98,12 +85,34 @@
 }
 
 sub start_page {
-    my ($jscript,$bodytag,$bread_title,$formname) = @_;
+    my ($jscript,$bread_title,$formname) = @_;
 
     my $html = &Apache::lonxml::xmlbegin();
 
     my $head = &Apache::loncommon::head('Notification E-mail',$jscript);
 
+    my $loadcode;
+    if ((defined($env{'form.origin'})) 
+	&& ($env{'form.command'} eq 'compose' 
+	    || $env{'form.command'} eq 'pick_target' 
+	    || $env{'form.command'} eq 'pick_display')) {
+        if ($env{'form.origin'} ne '') {
+            $loadcode = 'javascript:setFormElements(document.'.$env{'form.command'}.')';
+            if (($env{'form.command'} eq 'pick_target') 
+		&& (($env{'form.origin'} eq 'compose')
+		    || ($env{'form.origin'} eq 'process'))) {
+                if ($env{'form.coursepick'} eq 'category') {
+                    $loadcode .= ';javascript:setCourseCat(document.'.$env{'form.command'}.')';
+                }
+            }
+        }
+    }
+    
+    $loadcode = ' onLoad="'.$loadcode.'" '; 
+    my $bodytag = 
+	&Apache::loncommon::bodytag('Broadcast e-mail to users', undef,
+				    $loadcode);
+
     my $breadcrumbs =
 	&Apache::lonhtmlcommon::breadcrumbs(undef,$bread_title,
 					    'Broadcast_system_email');
@@ -124,7 +133,7 @@
 }
 
 sub print_front_page {
-    my ($r,$formname,$cdom,$tablecolor,$bodytag) = @_;
+    my ($r,$formname,$cdom,$tablecolor) = @_;
 
     my $jscript = qq|
 function next_page(caller) {
@@ -138,7 +147,7 @@
 }
     |; 
 
-    my $output = &start_page(&add_script($jscript), $bodytag,
+    my $output = &start_page(&add_script($jscript),
 			     'Broadcast e-mail to Domain', $formname);
 
     $output .= '<input type="hidden" name="command" />';
@@ -157,7 +166,7 @@
 }
 
 sub print_display_option_form {
-    my ($r,$formname,$cdom,$tablecolor,$bodytag) = @_;
+    my ($r,$formname,$cdom,$tablecolor) = @_;
     &Apache::lonhtmlcommon::add_breadcrumb({text=>"Display options"});
 
     my $table_width = '';
@@ -190,7 +199,7 @@
     );
     my $jscript = &Apache::lonhtmlcommon::set_form_elements(\%elements);
 
-    my $output = &start_page(&add_script($jscript), $bodytag,
+    my $output = &start_page(&add_script($jscript),
 			     'Broadcast e-mail display options', $formname);
 
     $output .= &Apache::lonhtmlcommon::start_pick_box($table_width);
@@ -225,7 +234,7 @@
 }
 
 sub print_display {
-    my ($r,$formname,$cdom,$tablecolor,$bodytag) = @_;
+    my ($r,$formname,$cdom,$tablecolor) = @_;
     &Apache::lonhtmlcommon::add_breadcrumb
          ({href=>"javascript:goBack('pick_display')",
           text=>"Display options"},
@@ -256,7 +265,7 @@
 
 ENDSCRIPT
 
-    my $output = &start_page(&add_script($jscript), $bodytag,
+    my $output = &start_page(&add_script($jscript),
 			     'Display Broadcast e-mail', $formname);
 
     foreach my $msgid (keys(%sentmail)) {
@@ -371,7 +380,7 @@
 }
 
 sub print_selection_form {
-    my ($r,$formname,$cdom,$tablecolor,$bodytag) = @_;
+    my ($r,$formname,$cdom,$tablecolor) = @_;
     my %coursecodes = ();
     my %codes = ();
     my @codetitles = ();
@@ -457,7 +466,7 @@
 
 
     my $output = &start_page(&add_script($jscript).$cb_jscript,
-			     $bodytag, 'Choose e-mail audience', $formname);
+			     'Choose e-mail audience', $formname);
 
     $output .= &Apache::lonhtmlcommon::start_pick_box($table_width);
     my @roles = ('ow','cc','in','ta','ep','st','cr');
@@ -483,7 +492,7 @@
 }
 
 sub print_composition_form {
-    my ($r,$formname,$cdom,$tablecolor,$bodytag) = @_;
+    my ($r,$formname,$cdom,$tablecolor) = @_;
     &Apache::lonhtmlcommon::add_breadcrumb
         ({href=>"javascript:goBack('pick_target')",
           text=>"Select Audience"},
@@ -508,7 +517,7 @@
                    );
     $jscript .= &Apache::lonhtmlcommon::set_form_elements(\%elements);
 
-    $r->print(&start_page(&add_script($jscript), $bodytag,
+    $r->print(&start_page(&add_script($jscript),
 			  'Broadcast e-mail to users', $formname));
 
     my $coursefilter = $env{'form.coursepick'};
@@ -657,7 +666,7 @@
 
 
 sub print_request_receipt {
-    my ($r,$formname,$dom,$tablecolor,$bodytag) =@_;
+    my ($r,$formname,$dom,$tablecolor) =@_;
     my @recipients = &Apache::loncommon::get_env_multiple('form.recipient');
     my $subject = $env{'form.subject'};
     my $message = $env{'form.message'};
@@ -680,8 +689,8 @@
           text=>"Outcome"});
 
 
-    my $output = &start_page(&add_script($jscript), $bodytag,
-			     'E-mail Delivery', $formname);
+    my $output = &start_page(&add_script($jscript), 'E-mail Delivery',
+			     $formname);
 
     $output .= &Apache::lonhtmlcommon::start_pick_box();
     my @deliveries = ();