--- loncom/interface/lonfeedback.pm	2006/04/23 03:50:54	1.194
+++ loncom/interface/lonfeedback.pm	2006/05/09 20:54:55	1.201
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # Feedback
 #
-# $Id: lonfeedback.pm,v 1.194 2006/04/23 03:50:54 albertel Exp $
+# $Id: lonfeedback.pm,v 1.201 2006/05/09 20:54:55 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -726,7 +726,7 @@ ENDDISCUSS
             if ($outputtarget ne 'tex') {
                 $discussion.=&generate_attachments_button('',$attachnum,$ressymb,$now,\@currnewattach,\@currdelold,'',$mode);
                 if (@currnewattach > 0) {
-                    $newattachmsg .= '<b>New attachments</b><br />';
+                    $newattachmsg .= '<br /><b>New attachments</b><br />';
                     if (@currnewattach > 1) {
                         $newattachmsg .= '<ol>';
                         foreach my $item (@currnewattach) {
@@ -1328,12 +1328,15 @@ sub mail_screen {
   my $attachnum = 0;
   my $anonchk = (<<END);
   function anonchk() {
-     if (document.mailform.anondiscuss.checked == true) {
-          document.attachment.anondiscuss.value = '1'
-     }
-     if (document.mailform.discuss.checked == true) {
-          document.attachment.discuss.value = '1'
-     }
+      for (var i=0; i < document.mailform.discuss.length; i++) {
+	  if (document.mailform.discuss[i].checked) {
+	      document.attachment.discuss.value = 
+		  document.mailform.discuss[i].value;
+	  }
+      }
+      if (document.mailform.blog.checked) {
+	  document.attachment.blog.value = 1;
+      }
      return
    }
 END
@@ -1341,13 +1344,15 @@ END
   if (exists($env{'form.origpage'})) {
       $anonscript = (<<END);
   function setposttype() {
-      var anondisc = $env{'form.anondiscuss'};
-      var disc = $env{'form.discuss'};
-      if (anondisc == 1) {
-          document.mailform.anondiscuss.checked = true
+      var disc = "$env{'form.discuss'}";
+      for (var i=0; i < document.mailform.discuss.length; i++) {
+	  if (disc == document.mailform.discuss[i].value) {
+	      document.mailform.discuss[i].checked = 1;
+	  }
       }
-      if (disc == 1) {
-          document.mailform.discuss.checked = true
+      var blog = "$env{'form.blog'}";
+      if (blog == 1) {
+          document.mailform.blog.checked=1;
       }
       return
   }
@@ -1422,12 +1427,10 @@ END
   function setposttype () {
       var currtype = $anonflag
       if (currtype == 1) {
-          document.mailform.elements.discuss.checked = false
-          document.mailform.elements.anondiscuss.checked = true
+          document.mailform.elements.discuss.value = 'anon'
       }
       if (currtype == 0) {
-          document.mailform.elements.anondiscuss.checked = false
-          document.mailform.elements.discuss.checked = true
+          document.mailform.elements.discuss.value = 'nonanon'
       }
       return
   }
@@ -1473,12 +1476,9 @@ END
           } 
         }
         if (typeof(document.mailform.elements.discuss)!="undefined") {
-          if (document.mailform.elements.discuss.checked) {
-             rec=1;
-          } 
-        }
-        if (typeof(document.mailform.elements.anondiscuss)!="undefined") {
-          if (document.mailform.elements.anondiscuss.checked) {
+	  // anon versus nonanon discussion
+          if (document.mailform.elements.discuss[0].checked 
+	      || document.mailform.elements.discuss[1].checked) {
              rec=1;
           } 
         }
@@ -1494,7 +1494,7 @@ END
 	    }
 	    document.mailform.submit();
         } else {
-            alert('Please check a feedback type.');
+            alert('Please select a feedback type.');
 	}
     }
     $anonchk
@@ -1583,7 +1583,7 @@ END
         $r->print(&generate_attachments_button($postidx,$attachnum,$ressymb,$now,\@currnewattach,\@currdelold,$numoldver));
         if ($attachnum > 0) {
             if (@currnewattach > 0) {
-                $newattachmsg .= '<b>New attachments</b><br />';
+                $newattachmsg .= '<br /><b>New attachments</b><br />';
                 if (@currnewattach > 1) {
                     $newattachmsg .= '<ol>';
                     foreach my $item (@currnewattach) {
@@ -1758,41 +1758,41 @@ $start_page
 <form name="modifydisp" method="POST" action="/adm/feedback">
 $lt{'sdpf'}<br/> $lt{'prca'}  <ol><li>$lt{'whpo'}</li><li>$lt{'unwh'}</li><li>$lt{'wipa'}</li></ol>
 <br />
-<table border="0" cellpadding="0" cellspacing="0">
- <tr>
-  <td width="100%" bgcolor="#000000">
-   <table width="100%" border="0" cellpadding="1" cellspacing="0">
-    <tr>
-     <td width="100%" bgcolor="#000000">
-      <table border="0" cellpadding="3" cellspacing="1" bgcolor="#FFFFFF">
-       <tr bgcolor="$tabcolor">
-        <td><b>$lt{'pref'}</b></td>
-        <td><b>$lt{'curr'}</b></td>
-        <td><b>$lt{'actn'}?</b></td>
+END
+    $r->print(&Apache::loncommon::start_data_table());
+    $r->print(<<END);
+       <tr>
+        <th>$lt{'pref'}</td>
+        <th>$lt{'curr'}</td>
+        <th>$lt{'actn'}?</td>
        </tr>
-       <tr bgcolor="#dddddd">
+END
+    $r->print(&Apache::loncommon::start_data_table_row());
+    $r->print(<<END);
        <td>$lt{'disa'}</td>
        <td>$lt{$discdisp}</td>
        <td><label><input type="checkbox" name="discdisp" onClick="discdispChk('0')" />&nbsp;$lt{'chgt'} "$dispchangeA"</label>
            <br />
            <label><input type="checkbox" name="discdisp" onClick="discdispChk('1')" />&nbsp;$lt{'chgt'} "$dispchangeB"</label>
        </td>
-      </tr><tr bgcolor="#eeeeee">
+END
+    $r->print(&Apache::loncommon::end_data_table_row());
+    $r->print(&Apache::loncommon::start_data_table_row());
+    $r->print(<<END);
        <td>$lt{'npmr'}</td>
        <td>$lt{$discmark}</td>
        <td><label><input type="checkbox" name="discmark" />$lt{'chgt'} "$markchange"</label></td>
-      </tr><tr bgcolor="#dddddd">
+END
+    $r->print(&Apache::loncommon::end_data_table_row());
+    $r->print(&Apache::loncommon::start_data_table_row());
+    $r->print(<<END);
        <td>$lt{'dotm'}</td>
        <td>$lt{$disctogg}</td>
        <td><label><input type="checkbox" name="disctogg" onClick="discdispChk('2')" />$lt{'chgt'} "$toggchange"</label></td>
-      </tr>
-     </table>
-    </td>
-   </tr>
-  </table>
- </td>
-</tr>
-</table>
+END
+    $r->print(&Apache::loncommon::end_data_table_row());
+    $r->print(&Apache::loncommon::end_data_table());
+    $r->print(<<END);
 <br />
 <br />
 <input type="hidden" name="symb" value="$symb" />
@@ -1817,23 +1817,21 @@ sub print_sortfilter_options {
     $r->send_http_header;
 
     &Apache::lonenc::check_encrypt(\$symb);
-    my @sections = ();
+    my @sections;
     my $section_sel = '';
-    my $numsections = 0;
     my $numvisible = 5;
-    my %sectioncount = ();
-
-    $numsections = &Apache::loncommon::get_sections($env{'course.'.$env{'request.course.id'}.'.domain'},$env{'course.'.$env{'request.course.id'}.'.num'},\%sectioncount);
+    my %sectioncount = &Apache::loncommon::get_sections();
 
     if ($env{'request.course.sec'} !~ /^\s*$/) {  #Restrict section choice to current section 
         @sections = ('all',$env{'request.course.sec'});
         $numvisible = 2;
     } else {
         @sections = sort {$a cmp $b} keys(%sectioncount);
-        unshift(@sections,'all'); # Put 'all' at the front of the list
-        if ($numsections < 4) {
-            $numvisible = $numsections + 1;
+        if (scalar(@sections) < 4) {
+            $numvisible = scalar(@sections) + 1;
         }
+        unshift(@sections,'all'); # Put 'all' at the front of the list
+
     }
     foreach (@sections) {
         $section_sel .= "  <option value=\"$_\" />$_\n";
@@ -2015,19 +2013,17 @@ sub print_showposters {
     }
 
     my $start_page = &Apache::loncommon::start_page('Discussion options');
-
+    my $table_start =&Apache::loncommon::start_data_table();
     $r->print(<<END);
 $start_page
  <form name="pickpostersform" method="post">
-  <table border="0">
-   <tr>
-    <td bgcolor="#777777">
-     <table border="0" cellpadding="3">
-      <tr bgcolor="#e6ffff">
-       <td><b>No.</b></td>
-       <td><b>Select</b></td>
-       <td><b>Fullname</b><font color="#999999">(Username/domain)</font></td>
-       <td><b>Posts</td>
+ <br />
+    $table_start
+      <tr>
+       <th>No.</th>
+       <th>Select</th>
+       <th>Fullname<font color="#999999">(Username/domain)</font></th>
+       <th>Posts</th>
       </tr>
 END
     my $count = 0;
@@ -2039,18 +2035,19 @@ END
                     next;
                 } else {
                     $count ++;
-                    $r->print('<tr bgcolor="#ffffe6"><td align="right">'.$count.'</td><td align="center"><label><input name="stuinfo" type="checkbox" value="'.$_.'" /></td><td>'.$last.', '.$first.' ('.$uname.','.$udom.')</label></td><td>'.$postcounts{$_}.'</td></tr>');
+                    $r->print(&Apache::loncommon::start_data_table_row().
+			      '<td align="right">'.$count.'</td>
+                               <td align="center"><label><input name="stuinfo" type="checkbox" value="'.$_.'" /></td>
+                               <td>'.$last.', '.$first.' ('.$uname.','.$udom.')</label></td>
+                               <td>'.$postcounts{$_}.'</td>'.
+			      &Apache::loncommon::end_data_table_row());
                 }
             }
         }
     }
-
+    $r->print(&Apache::loncommon::end_data_table());
     my $end_page   = &Apache::loncommon::end_page();
     $r->print(<<END);
-     </table>
-    </td>
-   </tr>
-  </table>
 <br />
 <input type="hidden" name="sortposts" value="$sortposts" />
 <input type="hidden" name="userpick" value="$symb" />
@@ -2207,7 +2204,11 @@ sub redirect_back {
   }
   $feedurl=&Apache::lonenc::check_encrypt($feedurl);
   my $logo=&Apache::loncommon::lonhttpdurl('/adm/lonIcons/lonlogos.gif');
-  my %onload = ('onload' => "if (window.name!='loncapaclient') { this.document.reldt.submit(); self.window.close(); }");
+  my %onload;
+  if ($env{'environment.remote'} ne 'off') {
+      $onload{'onload'} =
+	  "if (window.name!='loncapaclient') { this.document.reldt.submit(); self.window.close(); }";
+  }
   my $start_page=
       &Apache::loncommon::start_page('New posts marked as read',undef,
 				     {'redirect'    => [2,$feedurl],
@@ -2238,9 +2239,15 @@ sub no_redirect_back {
   my ($r,$feedurl) = @_;
   my $nofeed=&mt('Sorry, no feedback possible on this resource  ...');
  
+  my %onload;
+  if ($env{'environment.remote'} ne 'off') {
+      $onload{'onload'} = 
+	  "if (window.name!='loncapaclient') { self.window.close(); }";
+  }
+
   my %body_options = ('only_body'   => 1,
 		      'bgcolor'     => '#FFFFFF',
-		      'add_entries' => {'onload' => "if (window.name!='loncapaclient') { self.window.close(); }"});
+		      'add_entries' => \%onload,);
 
   if ($feedurl !~ m{^/adm/feedback}) { 
       $body_options{'rediect'} = [2,$feedurl];
@@ -2295,10 +2302,9 @@ sub screen_header {
 	    &Apache::lonnet::allowed('pch',
 				     $env{'request.course.id'}.
 				     ($env{'request.course.sec'}?'/'.$env{'request.course.sec'}:''))) {
-	    $discussoptions='<label><input type="checkbox" name="discuss" onClick="this.form.anondiscuss.checked=false;" '.
-		($env{'form.replydisc'}?' checked="1"':'').' /> '.
+	    $discussoptions='<label><input type="radio" name="discuss" value="nonanon" checked="checked" /> '.
 		&mt('Contribution to course discussion of resource');
-	    $discussoptions.='</label><br /><label><input type="checkbox" name="anondiscuss" onClick="this.form.discuss.checked=false;" /> '.
+	    $discussoptions.='</label><br /><label><input type="radio" name="discuss" value="anon" /> '.
 		&mt('Anonymous contribution to course discussion of resource').
 		' <i>('.&mt('name only visible to course faculty').')</i></label> '.
 		'<a href="/adm/preferences?action=changescreenname">'.&mt('Change Screenname').'</a>';
@@ -2697,6 +2703,7 @@ END
 	&Apache::loncommon::end_page();
 				       
     $r->print(<<END);
+$start_page
 <form name="modattachments" method="post" enctype="multipart/form-data" action="/adm/feedback?attach=$symb">
  <table border="2">
   <tr>
@@ -2736,7 +2743,6 @@ END
 <input type="hidden" name="idx" value="$env{'form.idx'}" />
 <input type="hidden" name="numoldver" value="$env{'form.numoldver'}" />
 <input type="hidden" name="origpage" value="$env{'form.origpage'}" />
-<input type="hidden" name="anondiscuss" value="$env{'form.anondiscuss'}" />
 <input type="hidden" name="blog" value="$env{'form.blog'}" />
 <input type="hidden" name="discuss" value="$env{'form.discuss'}" />
 END
@@ -2802,7 +2808,6 @@ this.form.submit();" />
 <input type="hidden" name="subject" />
 <input type="hidden" name="comment" />
 <input type="hidden" name="blog" value = "0" />
-<input type="hidden" name="anondiscuss" value = "0" />
 <input type="hidden" name="discuss" value = "0" />
 <input type="hidden" name="numoldver" value="$numoldver" />
 ENDATTACH
@@ -3114,7 +3119,12 @@ sub handler {
       &Apache::loncommon::content_type($r,'text/html');
       $r->send_http_header;
       my $logo=&Apache::loncommon::lonhttpdurl('/adm/lonIcons/lonlogos.gif');
-      my %onload = ('onload' => "if (window.name!='loncapaclient') { this.document.reldt.submit(); self.window.close(); }");
+      my %onload;
+      if ($env{'environment.remote'} ne 'off') {
+	  $onload{'onload'} =
+	      "if (window.name!='loncapaclient') { this.document.reldt.submit(); self.window.close(); }";
+      }
+
       my $start_page=
 	  &Apache::loncommon::start_page('New posts marked as read',undef,
 					 {'redirect'    => [2,$feedurl],
@@ -3253,7 +3263,7 @@ ENDREDIR
 # -------------------------------------------------------- Work on attachments
       &Apache::loncommon::content_type($r,'text/html');
       $r->send_http_header;
-      &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['subject','comment','addnewattach','delnewattach','timestamp','numoldver','idx','anondiscuss','discuss','blog']);
+      &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['subject','comment','addnewattach','delnewattach','timestamp','numoldver','idx','discuss','blog']);
       my (@currnewattach,@currdelold,@keepold);
       &process_attachments(\@currnewattach,\@currdelold,\@keepold);
       if (exists($env{'form.addnewattach.filename'})) {
@@ -3422,7 +3432,7 @@ ENDREDIR
       my $numpost=0;
       if ($env{'form.discuss'} || $env{'form.anondiscuss'}) {
 	  my $subject = &clear_out_html($env{'form.subject'},undef,1);
-	  my $anonmode=(defined($env{'form.anondiscuss'}));
+	  my $anonmode=($env{'form.discuss'} eq 'anon' || $env{'form.anondiscuss'} );
 	  $typestyle.=&adddiscuss($symb,$message,$anonmode,$attachmenturl,
 				  $subject);
 	  $numpost++;