Diff for /loncom/interface/lonfeedback.pm between versions 1.133 and 1.149

version 1.133, 2004/11/15 21:35:37 version 1.149, 2005/02/14 01:37:45
Line 68  sub discussion_visible { Line 68  sub discussion_visible {
 }  }
   
 sub list_discussion {  sub list_discussion {
     my ($mode,$status,$ressymb)=@_;      my ($mode,$status,$ressymb,$imsextras)=@_;
     my $outputtarget=$ENV{'form.grade_target'};      my $outputtarget=$ENV{'form.grade_target'};
     if (defined($ENV{'form.export'})) {      if (defined($ENV{'form.export'})) {
  if($ENV{'form.export'}) {   if($ENV{'form.export'}) {
             $outputtarget = 'export';              $outputtarget = 'export';
         }          }
     }          }
       if (defined($imsextras)) {
           if ($$imsextras{'caller'} eq 'imsexport') {
               $outputtarget = 'export';
           }
       }
     if (not &discussion_visible($status)) { return ''; }      if (not &discussion_visible($status)) { return ''; }
     my @bgcols = ("#cccccc","#eeeeee");      my @bgcols = ("#cccccc","#eeeeee");
     my $discussiononly=0;      my $discussiononly=0;
Line 84  sub list_discussion { Line 89  sub list_discussion {
     my $cid=$ENV{'request.course.id'};      my $cid=$ENV{'request.course.id'};
     if ($ENV{'request.course.sec'}) {      if ($ENV{'request.course.sec'}) {
  $crs.='_'.$ENV{'request.course.sec'};   $crs.='_'.$ENV{'request.course.sec'};
     }                       }
     $crs=~s/\_/\//g;      $crs=~s/\_/\//g;
     unless ($ressymb) { $ressymb=&Apache::lonnet::symbread(); }      unless ($ressymb) { $ressymb=&Apache::lonnet::symbread(); }
     unless ($ressymb) { return ''; }      unless ($ressymb) { return ''; }
Line 106  sub list_discussion { Line 111  sub list_discussion {
     my $userpickkey = $ressymb.'_userpick';      my $userpickkey = $ressymb.'_userpick';
     my $toggkey = $ressymb.'_readtoggle';      my $toggkey = $ressymb.'_readtoggle';
     my $readkey = $ressymb.'_read';      my $readkey = $ressymb.'_read';
       $ressymb=$encsymb;
     my %dischash = &Apache::lonnet::get('nohist_'.$ENV{'request.course.id'}.'_discuss',[$lastkey,$showkey,$markkey,$visitkey,$ondispkey,$userpickkey,$toggkey,$readkey],$ENV{'user.domain'},$ENV{'user.name'});      my %dischash = &Apache::lonnet::get('nohist_'.$ENV{'request.course.id'}.'_discuss',[$lastkey,$showkey,$markkey,$visitkey,$ondispkey,$userpickkey,$toggkey,$readkey],$ENV{'user.domain'},$ENV{'user.name'});
     my %discinfo = ();      my %discinfo = ();
     my $showonlyunread = 0;      my $showonlyunread = 0;
Line 122  sub list_discussion { Line 127  sub list_discussion {
     &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['previous','sortposts','rolefilter','statusfilter','sectionpick','totposters']);      &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['previous','sortposts','rolefilter','statusfilter','sectionpick','totposters']);
     my $sortposts = $ENV{'form.sortposts'};      my $sortposts = $ENV{'form.sortposts'};
     my $statusfilter = $ENV{'form.statusfilter'};      my $statusfilter = $ENV{'form.statusfilter'};
     my $sectionpick = $ENV{'form.sectionpick'};      my @sectionpick = ();
       if ($ENV{'form.sectionpick'} =~ /,/) {
           @sectionpick = split/,/,$ENV{'form.sectionpick'};
       } else {
           $sectionpick[0] = $ENV{'form.sectionpick'};
       }
       my @rolefilter = ();
       if ($ENV{'form.rolefilter'} =~ /,/) {
           @rolefilter = split/,/,$ENV{'form.rolefilter'};
       } else {
           $rolefilter[0] = $ENV{'form.rolefilter'};
       }
     my $totposters = $ENV{'form.totposters'};      my $totposters = $ENV{'form.totposters'};
     $previous = $ENV{'form.previous'};      $previous = $ENV{'form.previous'};
     if ($previous > 0) {      if ($previous > 0) {
Line 132  sub list_discussion { Line 148  sub list_discussion {
             $prevread = $dischash{$lastkey};              $prevread = $dischash{$lastkey};
         }          }
     }      }
   &Apache::lonnet::logthis("\n last read r symb ".$lastkey);  
   
 # Get information about students and non-students in course for filtering display of posts  # Get information about students and non-students in course for filtering display of posts
     my %roleshash = ();      my %roleshash = ();
Line 141  sub list_discussion { Line 156  sub list_discussion {
         %roleshash = &Apache::lonnet::dump('nohist_userroles',$ENV{'course.'.$ENV{'request.course.id'}.'.domain'},$ENV{'course.'.$ENV{'request.course.id'}.'.num'});          %roleshash = &Apache::lonnet::dump('nohist_userroles',$ENV{'course.'.$ENV{'request.course.id'}.'.domain'},$ENV{'course.'.$ENV{'request.course.id'}.'.num'});
         foreach (keys %roleshash) {          foreach (keys %roleshash) {
             my ($role,$uname,$udom,$sec) = split/:/,$_;              my ($role,$uname,$udom,$sec) = split/:/,$_;
               if ($role =~ /^cr/) {
                   $role = 'cr';
               }
             my ($end,$start) = split/:/,$roleshash{$_};              my ($end,$start) = split/:/,$roleshash{$_};
             my $now = time;              my $now = time;
             my $status = 'Active';              my $status = 'Active';
             if (($now < $start) || ($end > 0 && $now > $end)) {              if (($now < $start) || ($end > 0 && $now > $end)) {
                 $status = 'Expired';                  $status = 'Expired';
             }              }
             push @{$roleinfo{$uname.':'.$udom}}, $role.':'.$sec.':'.$status;              if ($uname && $udom) { 
                   push @{$roleinfo{$uname.':'.$udom}}, $role.':'.$sec.':'.$status;
               }
         }          }
         my ($classlist) = &Apache::loncoursedata::get_classlist(          my ($classlist) = &Apache::loncoursedata::get_classlist(
                               $ENV{'request.course.id'},                                $ENV{'request.course.id'},
Line 225  sub list_discussion { Line 245  sub list_discussion {
     $discinfo{$visitkey} = $visit;      $discinfo{$visitkey} = $visit;
   
     &Apache::lonnet::put('nohist_'.$ENV{'request.course.id'}.'_discuss',\%discinfo,$ENV{'user.domain'},$ENV{'user.name'});      &Apache::lonnet::put('nohist_'.$ENV{'request.course.id'}.'_discuss',\%discinfo,$ENV{'user.domain'},$ENV{'user.name'});
     &build_posting_display(\%usernamesort,\%subjectsort,\%namesort,\%notshown,\%newitem,\%dischash,\%shown,\%alldiscussion,\%imsitems,\%imsfiles,\%roleinfo,\@discussionitems,\@replies,\@depth,\@posters,\$maxdepth,\$visible,\$newpostsflag,\$current,$status,$viewgrades,$seeid,$prevread,$sortposts,$encsymb,$target,$readkey,$showunmark,$showonlyunread,$totposters,$ENV{'form.rolefilter'},$sectionpick,$statusfilter,$toggkey,$outputtarget);      &build_posting_display(\%usernamesort,\%subjectsort,\%namesort,\%notshown,\%newitem,\%dischash,\%shown,\%alldiscussion,\%imsitems,\%imsfiles,\%roleinfo,\@discussionitems,\@replies,\@depth,\@posters,\$maxdepth,\$visible,\$newpostsflag,\$current,$status,$viewgrades,$seeid,$prevread,$sortposts,$encsymb,$target,$readkey,$showunmark,$showonlyunread,$totposters,\@rolefilter,\@sectionpick,$statusfilter,$toggkey,$outputtarget);
   
     my $discussion='';      my $discussion='';
     my $manifestfile;      my $manifestfile;
Line 310  sub list_discussion { Line 330  sub list_discussion {
         } elsif ($outputtarget eq 'export') {          } elsif ($outputtarget eq 'export') {
 # Create temporary directory if this is an export  # Create temporary directory if this is an export
             my $now = time;              my $now = time;
             $tempexport = $Apache::lonnet::perlvar{'lonDaemons'}.'/tmp/ims_exports';              if ((defined($imsextras)) && ($$imsextras{'caller'} eq 'imsexport')) {
             if (!-e $tempexport) {                  $tempexport = $$imsextras{'tempexport'};
                 mkdir($tempexport,0700);                  if (!-e $tempexport) {
             }                      mkdir($tempexport,0700);
             $tempexport .= '/'.$now;                  }
             if (!-e $tempexport) {                  $tempexport .= '/'.$$imsextras{'count'};
                 mkdir($tempexport,0700);                  if (!-e $tempexport) {
                       mkdir($tempexport,0700);
                   }
               } else {
                   $tempexport = $Apache::lonnet::perlvar{'lonDaemons'}.'/tmp/ims_exports';
                   if (!-e $tempexport) {
                       mkdir($tempexport,0700);
                   }
                   $tempexport .= '/'.$now;
                   if (!-e $tempexport) {
                       mkdir($tempexport,0700);
                   }
                   $tempexport .= '/'.$ENV{'user.domain'}.'_'.$ENV{'user.name'};
             }              }
             $tempexport .= '/'.$ENV{'user.domain'}.'_'.$ENV{'user.name'};  
             if (!-e $tempexport) {              if (!-e $tempexport) {
                 mkdir($tempexport,0700);                  mkdir($tempexport,0700);
             }              }
Line 355  imscp_v1p1.xsd http://www.imsglobal.org/ Line 386  imscp_v1p1.xsd http://www.imsglobal.org/
    }     }
 </script>  </script>
             |;              |;
     #FIXME need a <form back here for indiviaual red toggling      $discussion.='<form name="readchoices" method="post" action="/adm/feedback?chgreads='.$ressymb.'" ><table bgcolor="#AAAAAA" cellpadding="2" cellspacing="2" border="0">';
     $discussion.='<form><table bgcolor="#AAAAAA" cellpadding="2" cellspacing="2" border="0">';  
     $discussion .='<tr><td bgcolor="#DDDDBB" colspan="'.$colspan.'">'.      $discussion .='<tr><td bgcolor="#DDDDBB" colspan="'.$colspan.'">'.
  '<table border="0" width="100%" bgcolor="#DDDDBB"><tr>';   '<table border="0" width="100%" bgcolor="#DDDDBB"><tr>';
     if ($visible>2) {      if ($visible>2) {
  $discussion.='<td align="left">'.   $discussion.='<td align="left">'.
     '<a href="/adm/feedback?threadedon='.$ressymb;      '<a href="/adm/feedback?cmd=threadedon&amp;symb='.$ressymb;
  if ($newpostsflag) {   if ($newpostsflag) {
     $discussion .= '&previous='.$prevread;      $discussion .= '&previous='.$prevread;
  }   }
  $discussion .='">'.&mt('Threaded View').'</a>&nbsp;&nbsp;'.   $discussion .='">'.&mt('Threaded View').'</a>&nbsp;&nbsp;'.
     '<a href="/adm/feedback?threadedoff='.$ressymb;      '<a href="/adm/feedback?cmd=threadedoff&amp;symb='.$ressymb;
  if ($newpostsflag) {   if ($newpostsflag) {
     $discussion .= '&previous='.$prevread;      $discussion .= '&previous='.$prevread;
  }   }
  $discussion .='">'.&mt('Chronological View').'</a>&nbsp;&nbsp;   $discussion .='">'.&mt('Chronological View').'</a>&nbsp;&nbsp;
                               <a href= "/adm/feedback?sortfilter='.$ressymb;                                <a href= "/adm/feedback?cmd=sortfilter&amp;symb='.$ressymb;
                 if ($newpostsflag) {                  if ($newpostsflag) {
                     $discussion .= '&previous='.$prevread;                      $discussion .= '&previous='.$prevread;
                 }                  }
Line 386  imscp_v1p1.xsd http://www.imsglobal.org/ Line 416  imscp_v1p1.xsd http://www.imsglobal.org/
             $discussion .= '">'.&mt('Export').'?</a>&nbsp;&nbsp;</td>';              $discussion .= '">'.&mt('Export').'?</a>&nbsp;&nbsp;</td>';
     if ($newpostsflag) {      if ($newpostsflag) {
  if (!$markondisp) {   if (!$markondisp) {
     $discussion .='<td align="right"><a href="/adm/feedback?markread='.$ressymb.'">'.&mt('Mark NEW posts no longer new').'</a>&nbsp;&nbsp;';      $discussion .='<td align="right"><a href="/adm/feedback?markread=1&amp;symb='.$ressymb.'">'.&mt('Mark NEW posts no longer new').'</a>&nbsp;&nbsp;';
  } else {   } else {
     $discussion .= '<td>&nbsp;</td>';      $discussion .= '<td>&nbsp;</td>';
  }   }
Line 399  imscp_v1p1.xsd http://www.imsglobal.org/ Line 429  imscp_v1p1.xsd http://www.imsglobal.org/
             if ($numhidden > 0) {              if ($numhidden > 0) {
                 my $colspan = $maxdepth+1;                  my $colspan = $maxdepth+1;
                 $discussion.="\n".'<tr><td bgcolor="#CCCCCC" colspan="'.$colspan.'">'.                  $discussion.="\n".'<tr><td bgcolor="#CCCCCC" colspan="'.$colspan.'">'.
                          '<a href="/adm/feedback?allposts='.$ressymb;                           '<a href="/adm/feedback?allposts=1&amp;symb='.$ressymb;
                 if ($newpostsflag) {                  if ($newpostsflag) {
                     $discussion .= '&previous='.$prevread;                      $discussion .= '&previous='.$prevread;
                 }                  }
Line 437  imscp_v1p1.xsd http://www.imsglobal.org/ Line 467  imscp_v1p1.xsd http://www.imsglobal.org/
                  }                   }
             }              }
         } else {          } else {
             $sortposts = 'ascdate';  
             @showposts =  (sort { $a <=> $b } keys %alldiscussion);              @showposts =  (sort { $a <=> $b } keys %alldiscussion);
         }          }
         my $currdepth = 0;          my $currdepth = 0;
         my $firstidx = $alldiscussion{$showposts[0]};          my $firstidx = $alldiscussion{$showposts[0]};
         foreach (@showposts) {          foreach (@showposts) {
             unless (($sortposts eq 'thread') || ($sortposts eq 'ascdate' && $ENV{'environment.threadeddiscussion'}) || ($outputtarget eq 'export')) {              unless (($sortposts eq 'thread') || (($sortposts eq '') && ($ENV{'environment.threadeddiscussion'})) || ($outputtarget eq 'export')) {
                 $alldiscussion{$_} = $_;                  $alldiscussion{$_} = $_;
             }              }
             unless ( ($notshown{$alldiscussion{$_}} eq '1') || ($shown{$alldiscussion{$_}} == 0) ) {              unless ( ($notshown{$alldiscussion{$_}} eq '1') || ($shown{$alldiscussion{$_}} == 0) ) {
Line 483  imscp_v1p1.xsd http://www.imsglobal.org/ Line 512  imscp_v1p1.xsd http://www.imsglobal.org/
         $imsitems{$alldiscussion{$_}}{'isvisible'}.'" identifieref="RES-'.$ressymb.'-'.$alldiscussion{$_}.'">'.          $imsitems{$alldiscussion{$_}}{'isvisible'}.'" identifieref="RES-'.$ressymb.'-'.$alldiscussion{$_}.'">'.
         '<title>'.$imsitems{$alldiscussion{$_}}{'title'}.'</title>';          '<title>'.$imsitems{$alldiscussion{$_}}{'title'}.'</title>';
                         $imsresources .= "\n".                          $imsresources .= "\n".
     '<resource identifier="RES-'.$ressymb.'-'.$alldiscussion{$_}.'" type="webcontent" href="'.$postfilename.'">'.      '<resource identifier="RES-'.$ressymb.'-'.$alldiscussion{$_}.'" type="webcontent" href="'.$postfilename.'">'."\n".
       '<file href="'.$alldiscussion{$_}.'.html">'."\n".        '<file href="'.$postfilename.'">'."\n".
       $imsfiles{$alldiscussion{$_}}{$imsitems{$alldiscussion{$_}}{'currversion'}}."\n".        $imsfiles{$alldiscussion{$_}}{$imsitems{$alldiscussion{$_}}{'currversion'}}."\n".
     '</resource>';      '</resource>';
                     }                      }
Line 541  END Line 570  END
             $discussion .= <<END;              $discussion .= <<END;
                    </font></td>                     </font></td>
                    <td>&nbsp;</td>                     <td>&nbsp;</td>
                    <td>                     <td align="left">
                     <font size="-1"><b><a href="$chglink">$lt{'chgt'}</a>?</font></b>                      <font size="-1"><b><a href="$chglink">$lt{'chgt'}</a>?</font></b>
                    </td>                     </td>
                   </tr>                    </tr>
                  </table>                   </table>
                 </td>                  </td>
 END  END
               if ($sortposts) {
                   my %sort_types = ();
                   my %role_types = ();
                   my %status_types = ();
                   &sort_filter_names(\%sort_types,\%role_types,\%status_types);
   
                   $discussion .= '<td><font size="-1"><b>'.&mt('Sorted by').'</b>: '.$sort_types{$sortposts}.'<br />';
                   if (defined($ENV{'form.totposters'})) {
                       $discussion .= &mt('Posts by').':';
                       if ($totposters > 0) {
                           foreach my $poster (@posters) {
                               $poster =~ s/:/\@/;
                               $discussion .= ' '.$poster.',';
                           }
                           $discussion =~ s/,$//;
                       } else {
                           $discussion .= &mt('None selected');
                       }
                   } else {
                       my $filterchoice ='';
                       if (@sectionpick > 0) {
                           $filterchoice = '<i>'.&mt('sections').'</i>-&nbsp;'.$ENV{'form.sectionpick'};
                           $filterchoice .= '&nbsp;&nbsp;&nbsp; ';
                       }
                       if (@rolefilter > 0) {
                           $filterchoice .= '<i>'.&mt('roles').'</i>-';
                           foreach (@rolefilter) {
                               $filterchoice .= '&nbsp;'.$role_types{$_}.',';
                           }
                           $filterchoice =~ s/,$//;
                           $filterchoice .= '<br />&nbsp;&nbsp&nbsp;&nbsp;&nbsp;&nbsp;&nbsp&nbsp;';
                       }
                       if ($statusfilter) {
                           $filterchoice .= '<i>'.&mt('status').'</i>-&nbsp;'.$status_types{$statusfilter};
                       }
                       if ($filterchoice) {
                           $discussion .= '<b>'.&mt('Filters').'</b>:&nbsp;'.$filterchoice;
                       }
                       $discussion .= '</font></td>';
                   }
               }
             if ($dischash{$toggkey}) {              if ($dischash{$toggkey}) {
                 my $storebutton = &mt('Store read/unread changes');                  my $storebutton = &mt('Store read/unread changes');
                 $discussion.='<td align="right">'.                  $discussion.='<td align="right">'.
Line 562  END Line 632  END
              </td>               </td>
             </tr>              </tr>
            </table>             </table>
            <br /><br />             <br /><br /></form>
    </form>  
 END  END
         }           } 
         if ($outputtarget eq 'export') {          if ($outputtarget eq 'export') {
Line 581  END Line 650  END
 </manifest>  </manifest>
                 |;                  |;
                 close($manifestfile);                  close($manifestfile);
                   if ((defined($imsextras)) && ($$imsextras{'caller'} eq 'imsexport')) {
                       $discussion = $copyresult;
                   } else {
   
 #Create zip file in prtspool  #Create zip file in prtspool
   
                 my $imszipfile = '/prtspool/'.                      my $imszipfile = '/prtspool/'.
                 $ENV{'user.name'}.'_'.$ENV{'user.domain'}.'_'.                      $ENV{'user.name'}.'_'.$ENV{'user.domain'}.'_'.
                      time.'_'.rand(1000000000).'.zip';                           time.'_'.rand(1000000000).'.zip';
     # zip can cause an sh launch which can pass along all of %ENV      # zip can cause an sh launch which can pass along all of %ENV
     # which can be too large for /bin/sh to handle      # which can be too large for /bin/sh to handle
                 my %oldENV=%ENV;                      my %oldENV=%ENV;
                 undef(%ENV);                      undef(%ENV);
                 my $cwd = &getcwd();                       my $cwd = &getcwd(); 
                 my $imszip = '/home/httpd/'.$imszipfile;                      my $imszip = '/home/httpd/'.$imszipfile;
                 chdir $tempexport;                      chdir $tempexport;
                 open(OUTPUT, "zip -r $imszip *  2> /dev/null |");                      open(OUTPUT, "zip -r $imszip *  2> /dev/null |");
                 close(OUTPUT);                      close(OUTPUT);
                 chdir $cwd;                      chdir $cwd;
                 %ENV=%oldENV;                      %ENV=%oldENV;
                 undef(%oldENV);                      undef(%oldENV);
                 $discussion .= 'Download the zip file from <a href="'.$imszipfile.'">Discussion Posting Archive</a><br />';                      $discussion .= 'Download the zip file from <a href="'.$imszipfile.'">Discussion Posting Archive</a><br />';
                 if ($copyresult) {                      if ($copyresult) {
                     $discussion .= 'The following errors occurred during export - <br />'.$copyresult;                          $discussion .= 'The following errors occurred during export - <br />'.$copyresult;
                       }
                 }                  }
             } else {              } else {
                 $discussion .= '<br />Unfortunately you will not be able to retrieve an archive of the discussion posts at this time, because there was a problem creating a manifest file.<br />';                  $discussion .= '<br />Unfortunately you will not be able to retrieve an archive of the discussion posts at this time, because there was a problem creating a manifest file.<br />';
Line 641  to course faculty</font><br /> Line 714  to course faculty</font><br />
 <b>Title:</b>&nbsp;<input type="text" name="subject" value="$subject" size="30" /><br /><br />  <b>Title:</b>&nbsp;<input type="text" name="subject" value="$subject" size="30" /><br /><br />
 <textarea name="comment" cols="80" rows="14" wrap="hard">$comment</textarea>  <textarea name="comment" cols="80" rows="14" wrap="hard">$comment</textarea>
 ENDDISCUSS  ENDDISCUSS
         if ($ENV{'form.origpage'}) {              if ($ENV{'form.origpage'}) {
             $discussion.='<input type="hidden" name="origpage" value="'.$ENV{'form.origpage'}.'" />'."\n";                  $discussion.='<input type="hidden" name="origpage" value="'.$ENV{'form.origpage'}.'" />'."\n";
             foreach (@currnewattach) {                  foreach (@currnewattach) {
                 $discussion.='<input type="hidden" name="currnewattach" value="'.$_.'" />'."\n";                      $discussion.='<input type="hidden" name="currnewattach" value="'.$_.'" />'."\n";
             }                  }
         }              }
         $discussion.="</form>\n";              $discussion.="</form>\n";
         if ($outputtarget ne 'tex') {              if ($outputtarget ne 'tex') {
             $discussion.=&generate_attachments_button('',$attachnum,$ressymb,$now,\@currnewattach,\@currdelold,'',$mode);                  $discussion.=&generate_attachments_button('',$attachnum,$ressymb,$now,\@currnewattach,\@currdelold,'',$mode);
             if (@currnewattach > 0) {                  if (@currnewattach > 0) {
                 $newattachmsg .= '<b>New attachments</b><br />';                      $newattachmsg .= '<b>New attachments</b><br />';
                 if (@currnewattach > 1) {                      if (@currnewattach > 1) {
                     $newattachmsg .= '<ol>';                          $newattachmsg .= '<ol>';
                     foreach my $item (@currnewattach) {                          foreach my $item (@currnewattach) {
                         $item =~ m#.*/([^/]+)$#;                              $item =~ m#.*/([^/]+)$#;
                         $newattachmsg .= '<li><a href="'.$item.'">'.$1.'</a></li>'."\n";                              $newattachmsg .= '<li><a href="'.$item.'">'.$1.'</a></li>'."\n";
                           }
                           $newattachmsg .= '</ol>'."\n";
                       } else {
                           $currnewattach[0] =~ m#.*/([^/]+)$#;
                           $newattachmsg .= '<a href="'.$currnewattach[0].'">'.$1.'</a><br />'."\n";
                     }                      }
                     $newattachmsg .= '</ol>'."\n";  
                 } else {  
                     $currnewattach[0] =~ m#.*/([^/]+)$#;  
                     $newattachmsg .= '<a href="'.$currnewattach[0].'">'.$1.'</a><br />'."\n";  
                 }                  }
             }                  $discussion.=$newattachmsg;
             $discussion.=$newattachmsg;          $discussion.=&generate_preview_button();
     $discussion.=&generate_preview_button();      }
  }  
  }   }
         } else {      } else {
  if (&discussion_open($status) &&          if (&discussion_open($status) &&
     &Apache::lonnet::allowed('pch',              &Apache::lonnet::allowed('pch',
    $ENV{'request.course.id'}.             $ENV{'request.course.id'}.
  ($ENV{'request.course.sec'}?'/'.$ENV{'request.course.sec'}:''))) {          ($ENV{'request.course.sec'}?'/'.$ENV{'request.course.sec'}:''))) {
     if ($outputtarget ne 'tex') {      if ($outputtarget ne 'tex') {
  $discussion.='<table bgcolor="#BBBBBB"><tr><td><a href="/adm/feedback?replydisc='.   $discussion.='<table bgcolor="#BBBBBB"><tr><td><a href="/adm/feedback?replydisc='.
     $ressymb.':::" '.$target.'>'.      $ressymb.':::" '.$target.'>'.
     '<img src="/adm/lonMisc/chat.gif" border="0" />'.      '<img src="'.&Apache::loncommon::lonhttpdurl('/adm/lonMisc/chat.gif').'" border="0" />'.
     &mt('Post Discussion').'</a></td></tr></table>';      &mt('Post Discussion').'</a></td></tr></table>';
     }      }
  }   }
Line 686  ENDDISCUSS Line 759  ENDDISCUSS
   
 sub build_posting_display {  sub build_posting_display {
     my ($usernamesort,$subjectsort,$namesort,$notshown,$newitem,$dischash,$shown,$alldiscussion,$imsitems,$imsfiles,$roleinfo,$discussionitems,$replies,$depth,$posters,$maxdepth,$visible,$newpostsflag,$current,$status,$viewgrades,$seeid,$prevread,$sortposts,$ressymb,$target,$readkey,$showunmark,$showonlyunread,$totposters,$rolefilter,$sectionpick,$statusfilter,$toggkey,$outputtarget) = @_;      my ($usernamesort,$subjectsort,$namesort,$notshown,$newitem,$dischash,$shown,$alldiscussion,$imsitems,$imsfiles,$roleinfo,$discussionitems,$replies,$depth,$posters,$maxdepth,$visible,$newpostsflag,$current,$status,$viewgrades,$seeid,$prevread,$sortposts,$ressymb,$target,$readkey,$showunmark,$showonlyunread,$totposters,$rolefilter,$sectionpick,$statusfilter,$toggkey,$outputtarget) = @_;
   
     my @original=();      my @original=();
     my @index=();      my @index=();
     my $symb=&Apache::lonenc::check_decrypt($ressymb);      my $symb=&Apache::lonenc::check_decrypt($ressymb);
Line 699  sub build_posting_display { Line 771  sub build_posting_display {
         if ($prevread eq '0') {          if ($prevread eq '0') {
             $prevread = $oldest-1;              $prevread = $oldest-1;
         }          }
           my ($skiptest,$rolematch,$roleregexp,$secregexp,$statusregexp);
           if ($sortposts) {
               ($skiptest,$roleregexp,$secregexp,$statusregexp) = &filter_regexp($rolefilter,$sectionpick,$statusfilter);
               $rolematch = $roleregexp.':'.$secregexp.':'.$statusregexp;
           } 
  for (my $id=1;$id<=$contrib{'version'};$id++) {   for (my $id=1;$id<=$contrib{'version'};$id++) {
     my $idx=$id;      my $idx=$id;
             my $posttime = $contrib{$idx.':timestamp'};              my $posttime = $contrib{$idx.':timestamp'};
Line 711  sub build_posting_display { Line 788  sub build_posting_display {
     my $origindex='0.';      my $origindex='0.';
             my $numoldver=0;              my $numoldver=0;
     if ($contrib{$idx.':replyto'}) {      if ($contrib{$idx.':replyto'}) {
                 if ( (($ENV{'environment.threadeddiscussion'}) && (($sortposts eq '') || ($sortposts eq 'ascdate'))) || ($sortposts eq 'thread') || ($outputtarget eq 'export')) {                  if ( (($ENV{'environment.threadeddiscussion'}) && ($sortposts eq '')) || ($sortposts eq 'thread') || ($outputtarget eq 'export')) {
 # this is a follow-up message  # this is a follow-up message
     $original[$idx]=$original[$contrib{$idx.':replyto'}];      $original[$idx]=$original[$contrib{$idx.':replyto'}];
     $$depth[$idx]=$$depth[$contrib{$idx.':replyto'}]+1;      $$depth[$idx]=$$depth[$contrib{$idx.':replyto'}]+1;
Line 906  sub build_posting_display { Line 983  sub build_posting_display {
                 }                  }
                 if ($outputtarget eq 'export' || $message) {                  if ($outputtarget eq 'export' || $message) {
     my $thisindex=$idx;      my $thisindex=$idx;
     if ( (($ENV{'environment.threadeddiscussion'}) && (($sortposts eq '') || ($sortposts eq 'ascdate'))) || ($sortposts eq 'thread') || ($outputtarget eq 'export')) {      if ( (($ENV{'environment.threadeddiscussion'}) && ($sortposts eq '')) || ($sortposts eq 'thread') || ($outputtarget eq 'export')) {
  $thisindex=$origindex.substr('00'.$$replies[$$depth[$idx]],-2,2);   $thisindex=$origindex.substr('00'.$$replies[$$depth[$idx]],-2,2);
     }      }
     $$alldiscussion{$thisindex}=$idx;      $$alldiscussion{$thisindex}=$idx;
Line 947  sub build_posting_display { Line 1024  sub build_posting_display {
                             my $uname = $contrib{$idx.':sendername'};                              my $uname = $contrib{$idx.':sendername'};
                             my $udom = $contrib{$idx.':senderdomain'};                              my $udom = $contrib{$idx.':senderdomain'};
                             my $poster = $uname.':'.$udom;                              my $poster = $uname.':'.$udom;
                             my $rolematch = '';                              if (defined($ENV{'form.totposters'})) {
                             my $skiptest = 1;                                  if ($totposters == 0) {
                             if ($totposters > 0) {                                      $$shown{$idx} = 0;
                                 if (grep/^$poster$/,@{$posters}) {                                  } elsif ($totposters > 0) {
                                     $$shown{$idx} = 1;                                      if (grep/^$poster$/,@{$posters}) {
                                 }                                          $$shown{$idx} = 1;
                             } else {  
                                 if ($rolefilter) {  
                                     if ($rolefilter eq 'all') {  
                                         $rolematch = '([^:]+)';  
                                     } else {  
                                         $rolematch = $rolefilter;  
                                         $skiptest = 0;  
                                     }  
                                 }  
                                 if ($sectionpick) {  
                                     if ($sectionpick eq 'all') {  
                                         $rolematch .= ':([^:]*)';  
                                     } else {  
                                         $rolematch .= ':'.$sectionpick;  
                                         $skiptest = 0;  
                                     }  
                                 }  
                                 if ($statusfilter) {  
                                     if ($statusfilter eq 'all') {  
                                         $rolematch .= ':([^:]+)';  
                                     } else {  
                                         $rolematch .= ':'.$statusfilter;  
                                         $skiptest = 0;  
                                     }                                      }
                                 }                                  }
                               } elsif ($sortposts) {
                                 if ($skiptest) {                                  if ($skiptest) {
                                     $$shown{$idx} = 1;                                      $$shown{$idx} = 1;
                                 } else {                                  } else {
                                     foreach my $role (@{$$roleinfo{$poster}}) {                                      foreach my $role (@{$$roleinfo{$poster}}) {
  &Apache::lonnet::logthis("\n rolematch $rolematch\nrole $role");                                          if ($role =~ /^cc:/) {
                                         if ($role =~ m/^$rolematch$/) {                                              my $cc_regexp = $roleregexp.':[^:]*:'.$statusregexp;
                                               if ($role =~ /$cc_regexp/) {
                                                   $$shown{$idx} = 1;
                                                   last;
                                               }
                                           } elsif ($role =~ /^$rolematch$/) {
                                             $$shown{$idx} = 1;                                              $$shown{$idx} = 1;
                                             last;                                              last;
                                         }                                          }
                                     }                                      }
                                 }                                  }
                               } else {
                                   $$shown{$idx} = 1;
                             }                              }
                         }                          }
                         unless ($$notshown{$idx} == 1) {                          unless ($$notshown{$idx} == 1) {
Line 1038  sub build_posting_display { Line 1100  sub build_posting_display {
     }      }
 }  }
   
   sub filter_regexp {
       my ($rolefilter,$sectionpick,$statusfilter) = @_;
       my ($roleregexp,$secregexp,$statusregexp);
       my $skiptest = 1;
       if (@{$rolefilter} > 0) {
           my @okrolefilter = ();
           foreach (@{$rolefilter}) {
               unless ($_ eq '') {
                   push @okrolefilter, $_;
               }
           }
           if (@okrolefilter > 0) {
               if (grep/^all$/,@okrolefilter) {
                   $roleregexp='[^:]+';
               } else {
                   if (@okrolefilter == 1) {
                       $roleregexp=$okrolefilter[0];
                   } else {
                       $roleregexp='('.join('|',@okrolefilter).')';
                   }
                   $skiptest = 0;
               }
           }
       }
       if (@{$sectionpick} > 0) {
           my @oksectionpick = ();
           foreach (@{$sectionpick}) {
               unless ($_ eq '') {
                    push @oksectionpick, $_;
               }
           }
           if ((@oksectionpick > 0) && (!grep/^all$/,@oksectionpick)) {
               if (@oksectionpick == 1) {
                   $secregexp = $oksectionpick[0];
               } else {
                   $secregexp .= '('.join('|',@oksectionpick).')';
               }
               $skiptest = 0;
           } else {
               $secregexp .= '[^:]*';
           }
       }
       if (defined($statusfilter) && $statusfilter ne '') {
           if ($statusfilter eq 'all') {
               $statusregexp = '[^:]+';
           } else {
               $statusregexp = $statusfilter;
               $skiptest = 0;
           }
       }
       return ($skiptest,$roleregexp,$secregexp,$statusregexp);
   }
   
   
 sub get_post_contents {  sub get_post_contents {
     my ($contrib,$idx,$seeid,$type,$messages,$subjects,$allattachments,$attachtxt,$imsfiles,$screenname,$plainname,$numver) = @_;      my ($contrib,$idx,$seeid,$type,$messages,$subjects,$allattachments,$attachtxt,$imsfiles,$screenname,$plainname,$numver) = @_;
     my $discussion = '';      my $discussion = '';
Line 1477  END Line 1593  END
   
 sub print_display_options {  sub print_display_options {
     my ($r,$symb,$previous,$dispchgA,$dispchgB,$markchg,$toggchg,$feedurl) = @_;      my ($r,$symb,$previous,$dispchgA,$dispchgB,$markchg,$toggchg,$feedurl) = @_;
     &dewrapper(\$feedurl);      &Apache::loncommon::content_type($r,'text/html');
       $r->send_http_header;
   
     my $function = &Apache::loncommon::get_users_function();      my $function = &Apache::loncommon::get_users_function();
     my $tabcolor = &Apache::loncommon::designparm($function.'.tabbg',      my $tabcolor = &Apache::loncommon::designparm($function.'.tabbg',
Line 1658  $lt{'sdpf'}<br/> $lt{'prca'}  <ol><li>$l Line 1775  $lt{'sdpf'}<br/> $lt{'prca'}  <ol><li>$l
 </table>  </table>
 <br />  <br />
 <br />  <br />
   <input type="hidden" name="symb" value="$symb" />
 <input type="hidden" name="previous" value="$previous" />  <input type="hidden" name="previous" value="$previous" />
 <input type="hidden" name="$dispchgA" value=""/>  <input type="hidden" name="$dispchgA" value=""/>
 <input type="hidden" name="$dispchgB" value=""/>  <input type="hidden" name="$dispchgB" value=""/>
Line 1676  END Line 1794  END
 sub print_sortfilter_options {  sub print_sortfilter_options {
     my ($r,$symb,$previous,$feedurl) = @_;      my ($r,$symb,$previous,$feedurl) = @_;
   
     &dewrapper(\$feedurl);      &Apache::loncommon::content_type($r,'text/html');
       $r->send_http_header;
   
       &Apache::lonenc::check_encrypt(\$symb);
     my @sections = ();      my @sections = ();
     my $section_sel = '';      my $section_sel = '';
     my $numsections = 0;      my $numsections = 0;
     my $numvisible = 5;      my $numvisible = 5;
     my ($classlist) = &Apache::loncoursedata::get_classlist(  
                               $ENV{'request.course.id'},  
                               $ENV{'course.'.$ENV{'request.course.id'}.'.domain'},  
                               $ENV{'course.'.$ENV{'request.course.id'}.'.num'});  
                                                                                      
     my $sec_index = &Apache::loncoursedata::CL_SECTION();  
     my $status_index = &Apache::loncoursedata::CL_STATUS();  
     my %sectioncount = ();      my %sectioncount = ();
     while (my ($student,$data) = each %$classlist) {  
         my ($section,$status) = ($data->[$sec_index],      $numsections = &Apache::loncommon::get_sections($ENV{'course.'.$ENV{'request.course.id'}.'.domain'},$ENV{'course.'.$ENV{'request.course.id'}.'.num'},\%sectioncount);
                                  $data->[$status_index]);  
         unless ($section eq '' || $section =~ /^\s*$/) {      if ($ENV{'request.course.sec'} !~ /^\s*$/) {  #Restrict section choice to current section 
             if (!defined($sectioncount{$section})) {          @sections = ('all',$ENV{'request.course.sec'});
                 $sectioncount{$section} = 1;          $numvisible = 2;
                 $numsections ++;  
             } else {  
                 $sectioncount{$section} ++;  
             }  
         }  
     }  
                                                                                      
     if ($ENV{'request.course.sec'} !~ /^\s*$/) {  
         @sections = ($ENV{'request.course.sec'});  
         $numvisible = 1;  
     } else {      } else {
         @sections = sort {$a cmp $b} keys(%sectioncount);          @sections = sort {$a cmp $b} keys(%sectioncount);
         unshift(@sections,'all'); # Put 'all' at the front of the list          unshift(@sections,'all'); # Put 'all' at the front of the list
Line 1726  sub print_sortfilter_options { Line 1830  sub print_sortfilter_options {
         'diop' => 'Display Options',          'diop' => 'Display Options',
         'curr' => 'Current setting ',          'curr' => 'Current setting ',
         'actn' => 'Action',          'actn' => 'Action',
         'prca' => 'Options can be set that control the sort order of the posts, in addition to which posts are displayed.',          'prca' => 'Set options that control the sort order of posts, and/or which posts are displayed.',
         'soor' => 'Sort order',          'soor' => 'Sort order',
         'disp' => 'Specific user roles',          'spur' => 'Specific user roles',
         'actv' => 'Specific role status',          'sprs' => 'Specific role status',
         'spse' => 'Specific sections',          'spse' => 'Specific sections',
         'psub' => 'Pick specific users (by name)',          'psub' => 'Pick specific users (by name)',
         'shal' => 'Show a list of current posters'          'shal' => 'Show a list of current posters'
     );      );
   
       my %sort_types = ();
       my %role_types = ();
       my %status_types = ();
       &sort_filter_names(\%sort_types,\%role_types,\%status_types);
   
     $r->print(<<END);      $r->print(<<END);
 <html>  <html>
 <head>  <head>
 <title>$lt{'diso'}</title>  <title>$lt{'diso'}</title>
 <meta http-equiv="pragma" content="no-cache" />  <meta http-equiv="pragma" content="no-cache" />
   <script type="text/javascript">
   function verifyFilter() {
       var rolenum = 0
       for (var i=0; i<document.modifyshown.rolefilter.length; i++) {
           if (document.modifyshown.rolefilter.options[i].selected == true) {
               rolenum ++
           }
       }
       if (rolenum == 0) {
           document.modifyshown.rolefilter.options[0].selected = true
       }
   
       var secnum = 0
       for (var i=0; i<document.modifyshown.sectionpick.length; i++) {
           if (document.modifyshown.sectionpick.options[i].selected == true) {
               secnum ++
           }
       }
       if (secnum == 0) {
           document.modifyshown.sectionpick.options[0].selected = true
       }
       document.modifyshown.submit();
   }
   </script>
 </head>  </head>
 $bodytag  $bodytag
 <form name="modifyshown" method="post" action="/adm/feedback">  <form name="modifyshown" method="post" action="/adm/feedback">
Line 1748  $bodytag Line 1882  $bodytag
  <tr>   <tr>
   <td><b>$lt{'soor'}</b></td>    <td><b>$lt{'soor'}</b></td>
   <td>&nbsp;</td>    <td>&nbsp;</td>
   <td><b>$lt{'disp'}</b></td>    <td><b>$lt{'sprs'}</b></td>
   <td>&nbsp;</td>    <td>&nbsp;</td>
   <td><b>$lt{'actv'}</b></td>    <td><b>$lt{'spur'}</b></td>
   <td>&nbsp;</td>    <td>&nbsp;</td>
   <td><b>$lt{'spse'}</b></td>    <td><b>$lt{'spse'}</b></td>
   <td>&nbsp;</td>    <td>&nbsp;</td>
   <td><b>$lt{'psub'}</b></td>    <td><b>$lt{'psub'}</b></td>
  </tr>   </tr>
  <tr>   <tr>
   <td>    <td align="center">
    <select name="sortposts">     <select name="sortposts">
     <option value="ascdate" />Date order - oldest first      <option value="ascdate" selected="selected" />$sort_types{'ascdate'}
     <option value="descdate" />Date order - newest first      <option value="descdate" />$sort_types{'descdate'}
     <option value="thread" />Threaded      <option value="thread" />$sort_types{'thread'}
     <option value="subject" />By subject      <option value="subject" />$sort_types{'subject'}
     <option value="username" />By domain and username      <option value="username" />$sort_types{'username'}
     <option value="lastfirst" />By last name, first name      <option value="lastfirst" />$sort_types{'lastfirst'}
    </select>     </select>
   </td>    </td>
   <td>&nbsp;</td>    <td>&nbsp;</td>
   <td>    <td align="center">
    <select name="rolefilter" multiple="true" size="5">     <select name="statusfilter">
     <option value="all" />All users      <option value="all" selected="selected" />$status_types{'all'}
     <option value="st" />Students      <option value="Active" />$status_types{'Active'}
     <option value="cc" />Course Coordinators      <option value="Expired" />$status_types{'Expired'}
     <option value="in" />Instructors  
     <option value="ta" />TAs  
     <option value="pr" />Exam proctors  
     <option value="cr" />Custom roles  
    </select>     </select>
   </td>    </td>
   <td>&nbsp;</td>    <td>&nbsp;</td>
   <td>    <td align="center">
    <select name="statusfilter">     <select name="rolefilter" multiple="true" size="5">
     <option value="all" />Roles of any status      <option value="all" />$role_types{'all'}
     <option value="Active" />Only active roles      <option value="st" />$role_types{'st'}
     <option value="Expired" />Only inactive roles      <option value="cc" />$role_types{'cc'}
       <option value="in" />$role_types{'in'}
       <option value="ta" />$role_types{'ta'}
       <option value="ep" />$role_types{'ep'}
       <option value="ad" />$role_types{'ad'}
       <option value="cr" />$role_types{'cr'}
    </select>     </select>
   </td>    </td>
   <td>&nbsp;</td>    <td>&nbsp;</td>
   <td>    <td align="center">
    <select name="sectionpick" multiple="true" size="$numvisible">     <select name="sectionpick" multiple="true" size="$numvisible">
     $section_sel      $section_sel
    </select>     </select>
Line 1801  $bodytag Line 1936  $bodytag
 <br />  <br />
 <input type="hidden" name="previous" value="$previous" />  <input type="hidden" name="previous" value="$previous" />
 <input type="hidden" name="applysort" value="$symb" />  <input type="hidden" name="applysort" value="$symb" />
 <input type="button" name="sub" value="Store Changes" onClick="javascript:document.modifyshown.submit()" />  <input type="button" name="sub" value="Store Changes" onClick="verifyFilter()" />
 <br />  <br />
 <br />  <br />
 </form>  </form>
Line 1813  END Line 1948  END
 sub print_showposters {  sub print_showposters {
     my ($r,$symb,$previous,$feedurl,$sortposts) = @_;      my ($r,$symb,$previous,$feedurl,$sortposts) = @_;
   
 # backward compatibility (bulletin boards used to be 'wrapped')      &Apache::lonenc::check_encrypt(\$symb);
     my $ressymb=&wrap_symb($symb);  
     my $crs='/'.$ENV{'request.course.id'};      my $crs='/'.$ENV{'request.course.id'};
     if ($ENV{'request.course.sec'}) {      if ($ENV{'request.course.sec'}) {
         $crs.='_'.$ENV{'request.course.sec'};          $crs.='_'.$ENV{'request.course.sec'};
     }      }
     $crs=~s/\_/\//g;      $crs=~s/\_/\//g;
     my $seeid=&Apache::lonnet::allowed('rin',$crs);      my $seeid=&Apache::lonnet::allowed('rin',$crs);
     my %contrib=&Apache::lonnet::restore($ressymb,$ENV{'request.course.id'},      my %contrib=&Apache::lonnet::restore($symb,$ENV{'request.course.id'},
                           $ENV{'course.'.$ENV{'request.course.id'}.'.domain'},                            $ENV{'course.'.$ENV{'request.course.id'}.'.domain'},
                           $ENV{'course.'.$ENV{'request.course.id'}.'.num'});                            $ENV{'course.'.$ENV{'request.course.id'}.'.num'});
     my %namesort = ();      my %namesort = ();
Line 1990  ENDFAILREDIR Line 2124  ENDFAILREDIR
 }  }
   
 sub redirect_back {  sub redirect_back {
   my ($r,$feedurl,$typestyle,$sendsomething,$sendposts,$status,$previous,$sort,$rolefilter,$statusfilter,$secpick,$numpicks) = @_;    my ($r,$feedurl,$typestyle,$sendsomething,$sendposts,$status,$previous,$sort,$rolefilter,$statusfilter,$sectionpick,$numpicks) = @_;
   my $sorttag = '';    my $sorttag = '';
   my $roletag = '';    my $roletag = '';
   my $statustag = '';    my $statustag = '';
Line 1999  sub redirect_back { Line 2133  sub redirect_back {
   my $qrystr = '';    my $qrystr = '';
   my $prevtag = '';    my $prevtag = '';
   
     &Apache::loncommon::content_type($r,'text/html');
     $r->send_http_header;
   
   &dewrapper(\$feedurl);    &dewrapper(\$feedurl);
   if ($feedurl=~/^\/adm\//) { $feedurl.='?register=1' };    if ($feedurl=~/^\/adm\//) { $feedurl.='?register=1' };
   if ($previous > 0) {    if ($previous > 0) {
Line 2018  sub redirect_back { Line 2155  sub redirect_back {
           $feedurl .= '?'.$sortqry;            $feedurl .= '?'.$sortqry;
       }        }
       $sorttag = '<input type="hidden" name="sortposts" value="'.$sort.'" />';        $sorttag = '<input type="hidden" name="sortposts" value="'.$sort.'" />';
       if ( (defined($numpicks)) && ($numpicks > 0) ) {        if (defined($numpicks)) {
           my $userpickqry = 'totposters='.$numpicks;            my $userpickqry = 'totposters='.$numpicks;
           $feedurl .= '&'.$userpickqry;            $feedurl .= '&'.$userpickqry;
           $userpicktag = '<input type="hidden" name="totposters" value="'.$numpicks.'" />';            $userpicktag = '<input type="hidden" name="totposters" value="'.$numpicks.'" />';
       } else {        } else {
           my $roleqry = 'rolefilter='.$rolefilter;            if (ref($sectionpick) eq 'ARRAY') {
           $feedurl .= '&'.$roleqry;                $feedurl .= '&sectionpick=';
           $roletag = '<input type="hidden" name="rolefilter" value="'.$rolefilter.'" />';                $sectag .=  '<input type="hidden" name="sectionpick" value="';
                 foreach (@{$sectionpick}) {
                     $feedurl .= $_.',';
                     $sectag .= $_.',';
                 }
                 $feedurl =~ s/,$//;
                 $sectag =~ s/,$//;
                 $sectag .= '" />';
             } else {
                 $feedurl .= '&sectionpick='.$sectionpick;
                 $sectag = '<input type="hidden" name="sectionpick" value="'.$sectionpick.'" />';
             }
             if (ref($rolefilter) eq 'ARRAY') {
                 $feedurl .= '&rolefilter=';
                 $roletag .=  '<input type="hidden" name="rolefilter" value="';
                 foreach (@{$rolefilter}) {
                     $feedurl .= $_.',';
                     $roletag .= $_.',';
                 }
                 $feedurl =~ s/,$//;
                 $roletag =~ s/,$//;
                 $roletag .= '" />';
             } else {
                 $feedurl .= '&rolefilter='.$rolefilter;
                 $roletag = '<input type="hidden" name="rolefilter" value="'.$rolefilter.'" />';
             }
           $feedurl .= '&statusfilter='.$statusfilter;            $feedurl .= '&statusfilter='.$statusfilter;
           $statustag ='<input type="hidden" name="statusfilter" value="'.$statusfilter.'" />';            $statustag ='<input type="hidden" name="statusfilter" value="'.$statusfilter.'" />';
           $feedurl .= '&sectionpick='.$secpick;  
           $sectag = '<input type="hidden" name="sectionpick" value="'.$secpick.'" />';  
       }        }
   }    }
   $feedurl=&Apache::lonenc::check_encrypt($feedurl);    $feedurl=&Apache::lonenc::check_encrypt($feedurl);
Line 2086  ENDNOREDIRTWO Line 2246  ENDNOREDIRTWO
 }  }
   
 sub screen_header {  sub screen_header {
     my ($feedurl) = @_;      my ($feedurl,$symb) = @_;
     my $msgoptions='';      my $msgoptions='';
     my $discussoptions='';      my $discussoptions='';
     unless (($ENV{'form.replydisc'}) || ($ENV{'form.editdisc'})) {      unless (($ENV{'form.replydisc'}) || ($ENV{'form.editdisc'})) {
Line 2112  sub screen_header { Line 2272  sub screen_header {
  }   }
     }      }
     if ($ENV{'request.course.id'}) {      if ($ENV{'request.course.id'}) {
  if (&discussion_open() &&   if (&discussion_open(undef,$symb) &&
     &Apache::lonnet::allowed('pch',      &Apache::lonnet::allowed('pch',
      $ENV{'request.course.id'}.       $ENV{'request.course.id'}.
      ($ENV{'request.course.sec'}?'/'.$ENV{'request.course.sec'}:''))) {       ($ENV{'request.course.sec'}?'/'.$ENV{'request.course.sec'}:''))) {
Line 2122  sub screen_header { Line 2282  sub screen_header {
     $discussoptions.='<br /><input type="checkbox" name="anondiscuss" onClick="this.form.discuss.checked=false;" /> '.      $discussoptions.='<br /><input type="checkbox" name="anondiscuss" onClick="this.form.discuss.checked=false;" /> '.
  &mt('Anonymous contribution to course discussion of resource').   &mt('Anonymous contribution to course discussion of resource').
  ' <i>('.&mt('name only visible to course faculty').')</i>';   ' <i>('.&mt('name only visible to course faculty').')</i>';
       }          }
     }      }
     if ($msgoptions) { $msgoptions='<h2><img src="/adm/lonMisc/feedback.gif" />'.&mt('Sending Messages').'</h2>'.$msgoptions; }      if ($msgoptions) { $msgoptions='<h2><img src="'.&Apache::loncommon::lonhttpdurl('/adm/lonMisc/feedback.gif').'" />'.&mt('Sending Messages').'</h2>'.$msgoptions; }
     if ($discussoptions) {       if ($discussoptions) { 
  $discussoptions='<h2><img src="/adm/lonMisc/chat.gif" />'.&mt('Discussion Contributions').'</h2>'.$discussoptions; }   $discussoptions='<h2><img src="'.&Apache::loncommon::lonhttpdurl('/adm/lonMisc/chat.gif').'" />'.&mt('Discussion Contributions').'</h2>'.$discussoptions; }
     return $msgoptions.$discussoptions;      return $msgoptions.$discussoptions;
 }  }
   
Line 2398  sub adddiscuss { Line 2558  sub adddiscuss {
   
 sub show_preview {  sub show_preview {
     my $r=shift;      my $r=shift;
       &Apache::loncommon::content_type($r,'text/html');
       $r->send_http_header;
     my $message=&clear_out_html($ENV{'form.comment'});      my $message=&clear_out_html($ENV{'form.comment'});
     $message=~s/\n/\<br \/\>/g;      $message=~s/\n/\<br \/\>/g;
     $message=&Apache::lonspeller::markeduptext($message);      $message=&Apache::lonspeller::markeduptext($message);
Line 2438  sub modify_attachments { Line 2600  sub modify_attachments {
     if ($idx) {      if ($idx) {
         &extract_attachments($attachmenturls,$idx,$numoldver,\$msg,\%attachments,\%currattach,$currdelold);          &extract_attachments($attachmenturls,$idx,$numoldver,\$msg,\%attachments,\%currattach,$currdelold);
     }      }
       &Apache::lonenc::check_encrypt(\$symb);
     $r->print(<<END);      $r->print(<<END);
 <html>  <html>
 <head>  <head>
Line 2718  sub has_discussion { Line 2881  sub has_discussion {
         }          }
     }      }
     return;      return;
 }   }
   
   sub sort_filter_names {
       my ($sort_types,$role_types,$status_types) = @_;
       %{$sort_types} = (
                        ascdate => 'Date order - oldest first',
                        descdate => 'Date order - newest first',
                        thread => 'Threaded',
                        subject => 'By subject',
                        username => 'By domain and username',
                        lastfirst => 'By last name, first name'
                      );
       %{$role_types} = (
                        all => 'All roles',
                        st  => 'Students',
                        cc  => 'Course Coordinators',
                        in  => 'Instructors',
                        ta  => 'TAs',
                        ep  => 'Exam proctors',
                        ad  => 'Administrators',
                        cr  => 'Custom roles'
                      );
       %{$status_types} = (
                        all     => 'Roles of any status',
                        Active => 'Only active roles',
                        Expired => 'Only inactive roles'
                      );
   }
       
 sub handler {  sub handler {
   my $r = shift;    my $r = shift;
Line 2731  sub handler { Line 2921  sub handler {
 # --------------------------- Get query string for limited number of parameters  # --------------------------- Get query string for limited number of parameters
   
   &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},    &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
          ['hide','unhide','deldisc','postdata','preview','replydisc','editdisc','threadedon','threadedoff','onlyunread','allposts','onlyunmark','previous','markread','markonread','markondisp','toggoff','toggon','modifydisp','changes','navtime','navmaps','navurl','sortfilter','sortposts','applysort','rolefilter','statusfilter','sectionpick','posterlist','userpick','attach','origpage','currnewattach','deloldattach','keepold','allversions','export']);           ['hide','unhide','deldisc','postdata','preview','replydisc','editdisc','cmd','symb','onlyunread','allposts','onlyunmark','previous','markread','markonread','markondisp','toggoff','toggon','modifydisp','changes','navtime','navmaps','navurl','sortposts','applysort','rolefilter','statusfilter','sectionpick','posterlist','userpick','attach','origpage','currnewattach','deloldattach','keepold','allversions','export']);
   
   if ($ENV{'form.discsymb'}) {    if ($ENV{'form.discsymb'}) {
       my ($symb,$feedurl) = &get_feedurl_and_clean_symb($ENV{'form.discsymb'});        my ($symb,$feedurl) = &get_feedurl_and_clean_symb($ENV{'form.discsymb'});
       my $readkey = $symb.'_read';        my $readkey = $symb.'_read';
Line 2754  sub handler { Line 2945  sub handler {
           &Apache::lonnet::put('nohist_'.$ENV{'request.course.id'}.'_discuss',            &Apache::lonnet::put('nohist_'.$ENV{'request.course.id'}.'_discuss',
   \%readinghash,$ENV{'user.domain'},$ENV{'user.name'});    \%readinghash,$ENV{'user.domain'},$ENV{'user.name'});
       }        }
       &Apache::loncommon::content_type($r,'text/html');  
       $r->send_http_header;  
       &redirect_back($r,$feedurl,&mt('Marked postings read/unread').'<br />',        &redirect_back($r,$feedurl,&mt('Marked postings read/unread').'<br />',
      '0','0','',$ENV{'form.previous'},'','','',);       '0','0','',$ENV{'form.previous'},'','','',);
       return OK;        return OK;
Line 2764  sub handler { Line 2953  sub handler {
       &Apache::loncommon::content_type($r,'text/html');        &Apache::loncommon::content_type($r,'text/html');
       $r->send_http_header;        $r->send_http_header;
       my $bodytag=&Apache::loncommon::bodytag('Discussion Post Versions');        my $bodytag=&Apache::loncommon::bodytag('Discussion Post Versions');
       $r->print (<<END);        $r->print(<<END);
 <html>  <html>
 <head>  <head>
 <title>Post Versions</title>  <title>Post Versions</title>
Line 2795  END Line 2984  END
       return OK;        return OK;
   }    }
   if ($ENV{'form.posterlist'}) {    if ($ENV{'form.posterlist'}) {
       &Apache::loncommon::content_type($r,'text/html');  
       $r->send_http_header;  
       my ($symb,$feedurl)=&get_feedurl_and_clean_symb($ENV{'form.applysort'});        my ($symb,$feedurl)=&get_feedurl_and_clean_symb($ENV{'form.applysort'});
       &print_showposters($r,$symb,$ENV{'form.previous'},$feedurl,        &print_showposters($r,$symb,$ENV{'form.previous'},$feedurl,
  $ENV{'form.sortposts'});   $ENV{'form.sortposts'});
       return OK;        return OK;
   }    }
   if ($ENV{'form.userpick'}) {    if ($ENV{'form.userpick'}) {
       &Apache::loncommon::content_type($r,'text/html');  
       $r->send_http_header;  
       my @posters = &Apache::loncommon::get_env_multiple('form.stuinfo');        my @posters = &Apache::loncommon::get_env_multiple('form.stuinfo');
       my ($symb,$feedurl)=&get_feedurl_and_clean_symb($ENV{'form.userpick'});        my ($symb,$feedurl)=&get_feedurl_and_clean_symb($ENV{'form.userpick'});
       my $numpicks = @posters;        my $numpicks = @posters;
Line 2818  END Line 3003  END
       return OK;        return OK;
   }    }
   if ($ENV{'form.applysort'}) {    if ($ENV{'form.applysort'}) {
       &Apache::loncommon::content_type($r,'text/html');  
       $r->send_http_header;  
       my ($symb,$feedurl)=&get_feedurl_and_clean_symb($ENV{'form.applysort'});        my ($symb,$feedurl)=&get_feedurl_and_clean_symb($ENV{'form.applysort'});
       &redirect_back($r,$feedurl,&mt('Changed sort/filter').'<br />','0','0',        &redirect_back($r,$feedurl,&mt('Changed sort/filter').'<br />','0','0',
      '',$ENV{'form.previous'},$ENV{'form.sortposts'},       '',$ENV{'form.previous'},$ENV{'form.sortposts'},
      $ENV{'form.rolefilter'},$ENV{'form.statusfilter'},       $ENV{'form.rolefilter'},$ENV{'form.statusfilter'},
      $ENV{'form.secpick'});       $ENV{'form.sectionpick'});
       return OK;        return OK;
   } elsif ($ENV{'form.sortfilter'}) {    } elsif ($ENV{'form.cmd'} eq 'sortfilter') {
       &Apache::loncommon::content_type($r,'text/html');        my ($symb,$feedurl)=&get_feedurl_and_clean_symb($ENV{'form.symb'});
       $r->send_http_header;  
       my ($symb,$feedurl)=&get_feedurl_and_clean_symb($ENV{'form.sortfilter'});  
       &print_sortfilter_options($r,$symb,$ENV{'form.previous'},$feedurl);        &print_sortfilter_options($r,$symb,$ENV{'form.previous'},$feedurl);
       return OK;        return OK;
   } elsif ($ENV{'form.navtime'}) {    } elsif ($ENV{'form.navtime'}) {
Line 2891  $textline Line 3072  $textline
 ENDREDIR  ENDREDIR
       return OK;        return OK;
   } elsif ($ENV{'form.modifydisp'}) {    } elsif ($ENV{'form.modifydisp'}) {
       &Apache::loncommon::content_type($r,'text/html');  
       $r->send_http_header;  
       my ($symb,$feedurl)=&get_feedurl_and_clean_symb($ENV{'form.modifydisp'});        my ($symb,$feedurl)=&get_feedurl_and_clean_symb($ENV{'form.modifydisp'});
       my ($dispchgA,$dispchgB,$markchg,$toggchg) =         my ($dispchgA,$dispchgB,$markchg,$toggchg) = 
   split(/_/,$ENV{'form.changes'});    split(/_/,$ENV{'form.changes'});
Line 2902  ENDREDIR Line 3081  ENDREDIR
   } elsif ($ENV{'form.markondisp'} || $ENV{'form.markonread'} ||    } elsif ($ENV{'form.markondisp'} || $ENV{'form.markonread'} ||
    $ENV{'form.allposts'}   || $ENV{'form.onlyunread'} ||     $ENV{'form.allposts'}   || $ENV{'form.onlyunread'} ||
    $ENV{'form.onlyunmark'} || $ENV{'form.toggoff'}    ||     $ENV{'form.onlyunmark'} || $ENV{'form.toggoff'}    ||
    $ENV{'form.toggon'} ) {     $ENV{'form.toggon'}     || $ENV{'form.markread'}) {
       &Apache::loncommon::content_type($r,'text/html');        my ($symb,$feedurl)=&get_feedurl_and_clean_symb($ENV{'form.symb'});
       $r->send_http_header;        my %discinfo;
       my $feedurl;  
       if ( ($ENV{'form.toggoff'}) || ($ENV{'form.toggon'}) ) {  
 # ------------------------ Modify setting for read/unread toggle for each post   # ------------------------ Modify setting for read/unread toggle for each post 
           my $symb=$ENV{'form.toggoff'}?$ENV{'form.toggoff'}:$ENV{'form.toggon'};        if ($ENV{'form.toggoff'}) { $discinfo{$symb.'_readtoggle'}=0; }
   ($symb,$feedurl)=&get_feedurl_and_clean_symb($symb);        if ($ENV{'form.toggon'})  { $discinfo{$symb.'_readtoggle'}=1; }
           my %discinfo;  
           $discinfo{$symb.'_readtoggle'}=1;  
           if ($ENV{'form.toggoff'}) { $discinfo{$symb.'_readtoggle'}=0; }  
           &Apache::lonnet::put('nohist_'.$ENV{'request.course.id'}.'_discuss',  
      \%discinfo,$ENV{'user.domain'},$ENV{'user.name'});  
       }  
       if (($ENV{'form.markondisp'}) || ($ENV{'form.markonread'})) {  
 # --------- Modify setting for identification of 'NEW' posts in this discussion  # --------- Modify setting for identification of 'NEW' posts in this discussion
           my $symb=$ENV{'form.markondisp'}?$ENV{'form.markondisp'}:$ENV{'form.markonread'};        if ($ENV{'form.markondisp'}) {
   ($symb,$feedurl)=&get_feedurl_and_clean_symb($symb);    $discinfo{$symb.'_lastread'} = time;
           my %discinfo;    $discinfo{$symb.'_markondisp'} = 1;
           my $lastkey = $symb.'_lastread';        }
           my $ondispkey = $symb.'_markondisp';        if ($ENV{'form.markonread'}) {
           if ($ENV{'form.markondisp'}) {    if ( $ENV{'form.previous'} > 0 ) {
               $discinfo{$lastkey} = time;        $discinfo{$symb.'_lastread'} = $ENV{'form.previous'};
               $discinfo{$ondispkey} = 1;    }
           } elsif ($ENV{'form.markonread'}) {    $discinfo{$symb.'_markondisp'} = 0;
               if ( $ENV{'form.previous'} > 0 ) {  
                   $discinfo{$lastkey} = $ENV{'form.previous'};  
               }  
               $discinfo{$ondispkey} = 0;  
           }  
           &Apache::lonnet::put('nohist_'.$ENV{'request.course.id'}.'_discuss',  
      \%discinfo,$ENV{'user.domain'},$ENV{'user.name'});  
       }        }
       if ($ENV{'form.allposts'} || $ENV{'form.onlyunread'} ||  
   $ENV{'form.onlyunmark'}) {  
 # --------------------------------- Modify display setting for this discussion   # --------------------------------- Modify display setting for this discussion 
           my $symb;        if ($ENV{'form.allposts'}) {
           if ($ENV{'form.allposts'}) {    $discinfo{$symb.'_showonlyunread'} = 0;
               $symb = $ENV{'form.allposts'};    $discinfo{$symb.'_showonlyunmark'} = 0;
           } elsif ($ENV{'form.onlyunread'}) {  
               $symb = $ENV{'form.onlyunread'};  
           } else {  
               $symb = $ENV{'form.onlyunmark'};  
           }  
   ($symb,$feedurl)=&get_feedurl_and_clean_symb($symb);  
           my %discinfo;  
           if ($ENV{'form.allposts'}) {  
               $discinfo{$symb.'_showonlyunread'} = 0;  
               $discinfo{$symb.'_showonlyunmark'} = 0;  
           } elsif ($ENV{'form.onlyunread'}) {  
               $discinfo{$symb.'_showonlyunread'} = 1;  
           } else {  
               $discinfo{$symb.'_showonlyunmark'} = 1;  
           }  
           &Apache::lonnet::put('nohist_'.$ENV{'request.course.id'}.'_discuss',  
      \%discinfo,$ENV{'user.domain'},$ENV{'user.name'});  
       }        }
         if ($ENV{'form.onlyunread'}) { $discinfo{$symb.'_showonlyunread'} = 1;  }
         if ($ENV{'form.onlyunmark'}) { $discinfo{$symb.'_showonlyunmark'} = 1;  }
   # ----------------------------------------------------- Mark new posts not NEW 
         if ($ENV{'form.markread'})   { $discinfo{$symb.'_lastread'} = time; }
         &Apache::lonnet::put('nohist_'.$ENV{'request.course.id'}.'_discuss',
      \%discinfo,$ENV{'user.domain'},$ENV{'user.name'});
       my $previous=$ENV{'form.previous'};        my $previous=$ENV{'form.previous'};
       if ($ENV{'form.markondisp'}) { $previous=undef; }        if ($ENV{'form.markondisp'}) { $previous=undef; }
       &redirect_back($r,$feedurl,&mt('Changed display status').'<br />',        &redirect_back($r,$feedurl,&mt('Changed display status').'<br />',
      '0','0','',$previous);       '0','0','',$previous);
       return OK;        return OK;
   } elsif ($ENV{'form.markread'}) {  
 # ----------------------------------------------------- Mark new posts not NEW   
       &Apache::loncommon::content_type($r,'text/html');  
       $r->send_http_header;  
       my ($symb,$feedurl)=&get_feedurl_and_clean_symb($ENV{'form.markread'});  
       &Apache::lonnet::logthis("\n last read w symb ".$symb);  
       my %discinfo;  
       $discinfo{$symb.'_lastread'} = time;  
       &Apache::lonnet::put('nohist_'.$ENV{'request.course.id'}.'_discuss',  
    \%discinfo,$ENV{'user.domain'},$ENV{'user.name'});  
       &redirect_back($r,$feedurl,&mt('Changed reading status').'<br />',  
      '0','0');  
       return OK;  
   } elsif (($ENV{'form.hide'}) || ($ENV{'form.unhide'})) {    } elsif (($ENV{'form.hide'}) || ($ENV{'form.unhide'})) {
 # ----------------------------------------------------------------- Hide/unhide  # ----------------------------------------------------------------- Hide/unhide
       &Apache::loncommon::content_type($r,'text/html');  
       $r->send_http_header;  
   
       my $entry=$ENV{'form.hide'}?$ENV{'form.hide'}:$ENV{'form.unhide'};        my $entry=$ENV{'form.hide'}?$ENV{'form.hide'}:$ENV{'form.unhide'};
       my ($symb,$idx)=split(/\:\:\:/,$entry);        my ($symb,$idx)=split(/\:\:\:/,$entry);
       ($symb,my $feedurl)=&get_feedurl_and_clean_symb($symb);        ($symb,my $feedurl)=&get_feedurl_and_clean_symb($symb);
Line 3019  ENDREDIR Line 3153  ENDREDIR
   
       &redirect_back($r,$feedurl,&mt('Changed discussion status').'<br />',        &redirect_back($r,$feedurl,&mt('Changed discussion status').'<br />',
      '0','0','',$ENV{'form.previous'});       '0','0','',$ENV{'form.previous'});
   } elsif (($ENV{'form.threadedon'}) || ($ENV{'form.threadedoff'})) {        return OK;
       &Apache::loncommon::content_type($r,'text/html');    } elsif ($ENV{'form.cmd'}=~/^(threadedoff|threadedon)$/) {
       $r->send_http_header;        my ($symb,$feedurl)=&get_feedurl_and_clean_symb($ENV{'form.symb'});
       my $symb;        if ($ENV{'form.cmd'} eq 'threadedon') {
       if ($ENV{'form.threadedon'}) {  
   $symb=$ENV{'form.threadedon'};  
   &Apache::lonnet::put('environment',{'threadeddiscussion' => 'on'});    &Apache::lonnet::put('environment',{'threadeddiscussion' => 'on'});
   &Apache::lonnet::appenv('environment.threadeddiscussion' => 'on');    &Apache::lonnet::appenv('environment.threadeddiscussion' => 'on');
       } else {        } else {
   $symb=$ENV{'form.threadedoff'};  
    &Apache::lonnet::del('environment',['threadeddiscussion']);     &Apache::lonnet::del('environment',['threadeddiscussion']);
   &Apache::lonnet::delenv('environment\.threadeddiscussion');    &Apache::lonnet::delenv('environment\.threadeddiscussion');
       }        }
       my ($symb,$feedurl)=&get_feedurl_and_clean_symb($symb);  
       &redirect_back($r,$feedurl,&mt('Changed discussion view mode').'<br />',        &redirect_back($r,$feedurl,&mt('Changed discussion view mode').'<br />',
      '0','0','',$ENV{'form.previous'});       '0','0','',$ENV{'form.previous'});
         return OK;
   } elsif ($ENV{'form.deldisc'}) {    } elsif ($ENV{'form.deldisc'}) {
 # --------------------------------------------------------------- Hide for good  # --------------------------------------------------------------- Hide for good
       &Apache::loncommon::content_type($r,'text/html');  
       $r->send_http_header;  
   
       my ($symb,$idx)=split(/\:\:\:/,$ENV{'form.deldisc'});        my ($symb,$idx)=split(/\:\:\:/,$ENV{'form.deldisc'});
       ($symb,my $feedurl)=&get_feedurl_and_clean_symb($symb);        ($symb,my $feedurl)=&get_feedurl_and_clean_symb($symb);
       my %contrib=&Apache::lonnet::restore($symb,$ENV{'request.course.id'},        my %contrib=&Apache::lonnet::restore($symb,$ENV{'request.course.id'},
                           $ENV{'course.'.$ENV{'request.course.id'}.'.domain'},                            $ENV{'course.'.$ENV{'request.course.id'}.'.domain'},
           $ENV{'course.'.$ENV{'request.course.id'}.'.num'});            $ENV{'course.'.$ENV{'request.course.id'}.'.num'});
     my %newhash=('deleted' => $contrib{'deleted'}.".$idx.");        my %newhash=('deleted' => $contrib{'deleted'}.".$idx.");
     &Apache::lonnet::store(\%newhash,$symb,$ENV{'request.course.id'},        &Apache::lonnet::store(\%newhash,$symb,$ENV{'request.course.id'},
                           $ENV{'course.'.$ENV{'request.course.id'}.'.domain'},     $ENV{'course.'.$ENV{'request.course.id'}.'.domain'},
           $ENV{'course.'.$ENV{'request.course.id'}.'.num'});     $ENV{'course.'.$ENV{'request.course.id'}.'.num'});
     &redirect_back($r,$feedurl,&mt('Changed discussion status').'<br />',        &redirect_back($r,$feedurl,&mt('Changed discussion status').'<br />',
    '0','0','',$ENV{'form.previous'});       '0','0','',$ENV{'form.previous'});
         return OK;
   } elsif ($ENV{'form.preview'}) {    } elsif ($ENV{'form.preview'}) {
 # -------------------------------------------------------- User wants a preview  # -------------------------------------------------------- User wants a preview
       &Apache::loncommon::content_type($r,'text/html');  
       $r->send_http_header;  
       &show_preview($r);        &show_preview($r);
         return OK;
   } elsif ($ENV{'form.attach'}) {    } elsif ($ENV{'form.attach'}) {
 # -------------------------------------------------------- Work on attachments  # -------------------------------------------------------- Work on attachments
       &Apache::loncommon::content_type($r,'text/html');        &Apache::loncommon::content_type($r,'text/html');
Line 3067  ENDREDIR Line 3195  ENDREDIR
           unless (length($ENV{'form.addnewattach'})>131072) {            unless (length($ENV{'form.addnewattach'})>131072) {
               my $subdir = 'feedback/'.$ENV{'form.timestamp'};                my $subdir = 'feedback/'.$ENV{'form.timestamp'};
               my $newattachment=&Apache::lonnet::userfileupload('addnewattach',undef,$subdir);                my $newattachment=&Apache::lonnet::userfileupload('addnewattach',undef,$subdir);
               push @currnewattach, $newattachment;        push @currnewattach, $newattachment;
           }            }
       }        }
       my $attachmenturls;        my $attachmenturls;
Line 3081  ENDREDIR Line 3209  ENDREDIR
       }        }
       &modify_attachments($r,\@currnewattach,\@currdelold,$symb,$idx,        &modify_attachments($r,\@currnewattach,\@currdelold,$symb,$idx,
   $attachmenturls);    $attachmenturls);
         return OK;
   } elsif ($ENV{'form.export'}) {    } elsif ($ENV{'form.export'}) {
       &Apache::loncommon::content_type($r,'text/html');        &Apache::loncommon::content_type($r,'text/html');
       $r->send_http_header;        $r->send_http_header;
Line 3096  ENDREDIR Line 3225  ENDREDIR
       my $bodytag=&Apache::loncommon::bodytag('Resource Feedback and Discussion');        my $bodytag=&Apache::loncommon::bodytag('Resource Feedback and Discussion');
       $r->print($bodytag.$discussion);                                             $r->print($bodytag.$discussion);                                     
       return OK;        return OK;
       #FIXME deleted CHGREADS needs to be readded  
   } else {    } else {
 # ------------------------------------------------------------- Normal feedback  # ------------------------------------------------------------- Normal feedback
       my $feedurl=$ENV{'form.postdata'};        my $feedurl=$ENV{'form.postdata'};
Line 3141  ENDREDIR Line 3269  ENDREDIR
   return OK;    return OK;
       }        }
 # Go ahead with feedback, no ambiguous reference  # Go ahead with feedback, no ambiguous reference
       &Apache::loncommon::content_type($r,'text/html');  
       $r->send_http_header;  
     
       unless (        unless (
   (    (
    ($feedurl=~m:^/res:) && ($feedurl!~m:^/res/adm:)     ($feedurl=~m:^/res:) && ($feedurl!~m:^/res/adm:)
Line 3153  ENDREDIR Line 3278  ENDREDIR
   ||    ||
   ($ENV{'request.course.id'} && ($symb=~/^bulletin\_\_\_/))    ($ENV{'request.course.id'} && ($symb=~/^bulletin\_\_\_/))
   ) {    ) {
     &Apache::loncommon::content_type($r,'text/html');
     $r->send_http_header;
 # Unable to give feedback  # Unable to give feedback
   &no_redirect_back($r,$feedurl);    &no_redirect_back($r,$feedurl);
       }        }
 # --------------------------------------------------- Print login screen header  # --------------------------------------------------- Print login screen header
       unless ($ENV{'form.sendit'}) {        unless ($ENV{'form.sendit'}) {
   my $options=&screen_header($feedurl);    &Apache::loncommon::content_type($r,'text/html');
     $r->send_http_header;
     my $options=&screen_header($feedurl,$symb);
   if ($options) {    if ($options) {
       &mail_screen($r,$feedurl,$options);        &mail_screen($r,$feedurl,$options);
   } else {    } else {

Removed from v.1.133  
changed lines
  Added in v.1.149


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>