Diff for /loncom/interface/lonfeedback.pm between versions 1.86 and 1.96

version 1.86, 2004/06/02 16:41:46 version 1.96, 2004/06/28 16:41:08
Line 37  use Apache::lontexconvert(); Line 37  use Apache::lontexconvert();
 use Apache::lonlocal; # must not have ()  use Apache::lonlocal; # must not have ()
 use Apache::lonhtmlcommon();  use Apache::lonhtmlcommon();
   
 sub list_discussion {  sub discussion_open {
     my ($mode,$status,$symb)=@_;      my ($status)=@_;
 #    &Apache::lonnet::logthis("status is $status");      if (defined($status) &&
     if (!($status eq 'CAN_ANSWER' || $status eq 'CANNOT_ANSWER'   !($status eq 'CAN_ANSWER' || $status eq 'CANNOT_ANSWER'
   || $status eq 'OPEN')) {    || $status eq 'OPEN')) {
  return '';   return 0;
       }
       my $close=&Apache::lonnet::EXT('resource.0.discussend');
       if (defined($close) && $close ne '' && $close < time) {
    return 0;
       }
       return 1;
   }
   
   sub discussion_visible {
       my ($status)=@_;
       if (not &discussion_open($status)) {
    my $hidden=&Apache::lonnet::EXT('resource.0.discusshide');
    if (lc($hidden) eq 'yes' or $hidden eq '' or !defined($hidden))  {
       return 0;
    }
     }      }
       return 1;
   }
   
   sub list_discussion {
       my ($mode,$status,$symb)=@_;
   
       my $outputtarget=$ENV{'form.grade_target'};
       if (not &discussion_visible($status)) { return ''; }
     my @bgcols = ("#cccccc","#eeeeee");      my @bgcols = ("#cccccc","#eeeeee");
     my $discussiononly=0;      my $discussiononly=0;
     if ($mode eq 'board') { $discussiononly=1; }      if ($mode eq 'board') { $discussiononly=1; }
Line 248  sub list_discussion { Line 270  sub list_discussion {
     $sender='<i>'.$screenname.'</i>';      $sender='<i>'.$screenname.'</i>';
  }   }
     }      }
     if (&Apache::lonnet::allowed('pch',      if (&discussion_open($status) &&
    &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'}:''))) {
  $sender.=' <a href="/adm/feedback?replydisc='.   $sender.=' <a href="/adm/feedback?replydisc='.
Line 340  sub list_discussion { Line 363  sub list_discussion {
   
     if ($visible) {      if ($visible) {
 # Print the discusssion  # Print the discusssion
  $discussion.='<table bgcolor="#AAAAAA" cellpadding="2" cellspacing="2" border="0">';   if ($outputtarget ne 'tex') {
  my $colspan=$maxdepth+1;      $discussion.='<table bgcolor="#AAAAAA" cellpadding="2" cellspacing="2" border="0">';
         $discussion .= '<tr bgcolor="#FFFFFF"><td colspan="'.$colspan.'" valign="top">'.      my $colspan=$maxdepth+1;
         '<table border="0" bgcolor="#FFFFFF" width="100%" cellspacing="2" cellpadding="2">'.      $discussion .= '<tr bgcolor="#FFFFFF"><td colspan="'.$colspan.'" valign="top">'.
         '<tr><td align="left"><b>'.$lt{'cuse'}.'</b></td><td>&nbsp;&nbsp;&nbsp;&nbsp;</td><td align="right"><b>'.$lt{'chgt'}.'</b></td></tr>'.   '<table border="0" bgcolor="#FFFFFF" width="100%" cellspacing="2" cellpadding="2">'.
         '<tr><td>'.$lt{'disa'}.':&nbsp;<i>'.$currdisp.'</i></td><td>&nbsp;&nbsp;&nbsp;&nbsp;</td><td align="right"><a href="'.$displink.'">'.$dispchange.'</a></td></tr>'.   '<tr><td align="left"><b>'.$lt{'cuse'}.'</b></td><td>&nbsp;&nbsp;&nbsp;&nbsp;</td><td align="right"><b>'.$lt{'chgt'}.'</b></td></tr>'.
         '<tr><td>'.$lt{'npce'}.':&nbsp;<i>'.$currmark.'</i></td><td>&nbsp;&nbsp;&nbsp;&nbsp;</td><td align="right"><a href="'.$marklink.'">'.$markchange.'</a></td></tr>'.   '<tr><td>'.$lt{'disa'}.':&nbsp;<i>'.$currdisp.'</i></td><td>&nbsp;&nbsp;&nbsp;&nbsp;</td><td align="right"><a href="'.$displink.'">'.$dispchange.'</a></td></tr>'.
         '</table></td></tr>'.   '<tr><td>'.$lt{'npce'}.':&nbsp;<i>'.$currmark.'</i></td><td>&nbsp;&nbsp;&nbsp;&nbsp;</td><td align="right"><a href="'.$marklink.'">'.$markchange.'</a></td></tr>'.
         '<tr><td bgcolor="#DDDDBB" colspan="'.$colspan.'">'.   '</table></td></tr>'.
         '<table border="0" width="100%" bgcolor="#DDDDBB"><tr>';   '<tr><td bgcolor="#DDDDBB" colspan="'.$colspan.'">'.
         if ($visible>2) {   '<table border="0" width="100%" bgcolor="#DDDDBB"><tr>';
     $discussion.='<td align="left">'.      if ($visible>2) {
             '<a href="/adm/feedback?threadedon='.$ressymb;   $discussion.='<td align="left">'.
             if ($newpostsflag) {      '<a href="/adm/feedback?threadedon='.$ressymb;
                 $discussion .= '&previous='.$prevread;   if ($newpostsflag) {
             }      $discussion .= '&previous='.$prevread;
             $discussion .='">'.&mt('Threaded View').'</a>&nbsp;&nbsp;'.   }
             '<a href="/adm/feedback?threadedoff='.$ressymb;   $discussion .='">'.&mt('Threaded View').'</a>&nbsp;&nbsp;'.
             if ($newpostsflag) {      '<a href="/adm/feedback?threadedoff='.$ressymb;
                 $discussion .= '&previous='.$prevread;   if ($newpostsflag) {
             }      $discussion .= '&previous='.$prevread;
             $discussion .='">'.&mt('Chronological View').'</a>&nbsp;&nbsp;</td>';   }
  }    $discussion .='">'.&mt('Chronological View').'</a>&nbsp;&nbsp;</td>';
         if ($newpostsflag) {      } 
             if (!$markondisp) {      if ($newpostsflag) {
                 $discussion .='<td align="right"><a href="/adm/feedback?markread='.$ressymb.'">'.&mt('Mark new posts as read').'</a>&nbsp;&nbsp;';   if (!$markondisp) {
             } else {      $discussion .='<td align="right"><a href="/adm/feedback?markread='.$ressymb.'">'.&mt('Mark new posts as read').'</a>&nbsp;&nbsp;';
                 $discussion .= '<td>&nbsp;</td>';   } else {
             }      $discussion .= '<td>&nbsp;</td>';
         } else {   }
             $discussion .= '<td>&nbsp;</td>';      } else {
         }   $discussion .= '<td>&nbsp;</td>';
         $discussion .= '</tr></table></td></tr>';      }
       $discussion .= '</tr></table></td></tr>';
    } else {
       $discussion.='\vskip 0 mm\noindent\makebox[2 cm][b]{\hrulefill}'.
                            '\textbf{DISCUSSIONS}\makebox[2 cm][b]{\hrulefill}'.
                            '\vskip 0 mm\noindent\textbf{'.$lt{'cuse'}.'}:\vskip 0 mm'.
                            '\noindent\textbf{'.$lt{'disa'}.'}: \textit{'.$currdisp.'}\vskip 0 mm'.
                            '\noindent\textbf{'.$lt{'npce'}.'}: \textit{'.$currmark.'}';
    }
         my $numhidden = keys %notshown;          my $numhidden = keys %notshown;
         if ($numhidden > 0) {          if ($numhidden > 0) {
             my $colspan = $maxdepth+1;              my $colspan = $maxdepth+1;
Line 388  sub list_discussion { Line 418  sub list_discussion {
         }          }
  foreach (sort { $a <=> $b } keys %alldiscussion) {   foreach (sort { $a <=> $b } keys %alldiscussion) {
             unless ($notshown{$alldiscussion{$_}} eq '1') {              unless ($notshown{$alldiscussion{$_}} eq '1') {
         $discussion.="\n<tr>";                  if ($outputtarget ne 'tex') {
       $discussion.="\n<tr>";
    } else {
       $discussion.='\vskip 0 mm\noindent\makebox[2 cm][b]{\hrulefill}';
    }
         my $thisdepth=$depth[$alldiscussion{$_}];          my $thisdepth=$depth[$alldiscussion{$_}];
         for (1..$thisdepth) {                  if ($outputtarget ne 'tex') {
     $discussion.='<td>&nbsp;&nbsp;&nbsp;</td>';      for (1..$thisdepth) {
         }   $discussion.='<td>&nbsp;&nbsp;&nbsp;</td>';
       }
    }
         my $colspan=$maxdepth-$thisdepth+1;          my $colspan=$maxdepth-$thisdepth+1;
                 $discussion.='<td  bgcolor="'.$bgcols[$newitem{$alldiscussion{$_}}].'" colspan="'.$colspan.'">'.                  if ($outputtarget ne 'tex') {
       $discussion.='<td  bgcolor="'.$bgcols[$newitem{$alldiscussion{$_}}].'" colspan="'.$colspan.'">'.
                              $discussionitems[$alldiscussion{$_}].                               $discussionitems[$alldiscussion{$_}].
                      '</td></tr>';                       '</td></tr>';
    } else {
       #cleanup block
       $discussionitems[$alldiscussion{$_}]=~s/<table([^>]*)>/<table TeXwidth="90 mm">/;
       $discussionitems[$alldiscussion{$_}]=~s/<tr([^>]*)><td([^>]*)>/<tr><td TeXwidth="20 mm" align="left">/;
                       my $threadinsert='';
                       if ($thisdepth > 0) {
    $threadinsert='<br /><strong>Reply: '.$thisdepth.'</strong>';
       }
       $discussionitems[$alldiscussion{$_}]=~s/<\/td><td([^>]*)>/$threadinsert<\/td><td TeXwidth="65 mm" align="left">/;
       $discussionitems[$alldiscussion{$_}]=~s/<a([^>]+)>(Hide|Delete|Reply|Submissions)<\/a>//g;
                       $discussionitems[$alldiscussion{$_}]=~s/(<b>|<\/b>|<\/a>|<a([^>]+)>)//g;
       
                       #FIXME xmlparse can't be safely called from inside xmlparse
                       #   due to the global variables that are use, the safe
                       #   space etc. I expect this has unforseen issues that
                       #   need resolving.
       
                       $discussion.=&Apache::lonxml::xmlparse('','tex',$discussionitems[$alldiscussion{$_}]);
    }
     }      }
         }          }
         $discussion.='</table><br /><br />';   if ($outputtarget ne 'tex') {
       $discussion.='</table><br /><br />';
    }
     }      }
     if ($discussiononly) {      if ($discussiononly) {
  $discussion.=(<<ENDDISCUSS);   $discussion.=(<<ENDDISCUSS);
Line 412  sub list_discussion { Line 470  sub list_discussion {
 <font size="1">Note: in anonymous discussion, your name is visible only to  <font size="1">Note: in anonymous discussion, your name is visible only to
 course faculty</font><br />  course faculty</font><br />
 <b>Title:</b>&nbsp;<input type="text" name="subject" value="" size="30" /><br /><br />  <b>Title:</b>&nbsp;<input type="text" name="subject" value="" size="30" /><br /><br />
 <textarea name="comment" cols="60" rows="10" wrap="hard"></textarea>  <textarea name="comment" cols="80" rows="14" wrap="hard"></textarea>
 <p>  <p>
 Attachment (128 KB max size): <input type="file" name="attachment" />  Attachment (128 KB max size): <input type="file" name="attachment" />
 </p>  </p>
 </form>  </form>
 ENDDISCUSS  ENDDISCUSS
       $discussion.=&generate_preview_button();          if ($outputtarget ne 'tex') {
       $discussion.=&generate_preview_button();
    }
     } else {      } else {
  if (&Apache::lonnet::allowed('pch',   if (&discussion_open($status) &&
       &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'}:''))) {
     $discussion.='<table bgcolor="#BBBBBB"><tr><td><a href="/adm/feedback?replydisc='.      if ($outputtarget ne 'tex') {
  $symb.':::" '.$target.'>'.   $discussion.='<table bgcolor="#BBBBBB"><tr><td><a href="/adm/feedback?replydisc='.
  '<img src="/adm/lonMisc/chat.gif" border="0" />'.      $symb.':::" '.$target.'>'.
  &mt('Post Discussion').'</a></td></tr></table>';      '<img src="/adm/lonMisc/chat.gif" border="0" />'.
       &mt('Post Discussion').'</a></td></tr></table>';
       }
  }   }
     }      }
    return $discussion;     return $discussion;
Line 460  sub mail_screen { Line 523  sub mail_screen {
   }    }
   my $latexHelp=&Apache::loncommon::helpLatexCheatsheet();    my $latexHelp=&Apache::loncommon::helpLatexCheatsheet();
   my $htmlheader=&Apache::lonhtmlcommon::htmlareaheaders();    my $htmlheader=&Apache::lonhtmlcommon::htmlareaheaders();
     my $onsubmit='';
     if ((&Apache::lonhtmlcommon::htmlareabrowser()) &&
         (!&Apache::lonhtmlcommon::htmlareablocked())) {
         $onsubmit='document.mailform.onsubmit();';
     }
   my $send=&mt('Send');    my $send=&mt('Send');
   $r->print(<<ENDDOCUMENT);    $r->print(<<ENDDOCUMENT);
 <html>  <html>
Line 503  $htmlheader Line 571  $htmlheader
         }          }
   
         if (rec) {          if (rec) {
     document.mailform.onsubmit();              $onsubmit
     document.mailform.submit();      document.mailform.submit();
         } else {          } else {
             alert('Please check a feedback type.');              alert('Please check a feedback type.');
Line 527  $quote Line 595  $quote
 $latexHelp  $latexHelp
 Title: <input type="text" name="subject" size="30" value="$subject" /></p>  Title: <input type="text" name="subject" size="30" value="$subject" /></p>
 <p>  <p>
 <textarea name="comment" cols="60" rows="10" wrap="hard">  <textarea name="comment" id="comment" cols="60" rows="10" wrap="hard">
 </textarea></p>  </textarea></p>
 <p>  <p>
 Attachment (128 KB max size): <input type="file" name="attachment" />  Attachment (128 KB max size): <input type="file" name="attachment" />
Line 539  Attachment (128 KB max size): <input typ Line 607  Attachment (128 KB max size): <input typ
 </form>  </form>
 ENDDOCUMENT  ENDDOCUMENT
 $r->print(&generate_preview_button().  $r->print(&generate_preview_button().
 &Apache::lonhtmlcommon::htmlareaactive().  &Apache::lonhtmlcommon::htmlareaselectactive('comment').
 '</body></html>');  '</body></html>');
 }  }
   
Line 643  sub screen_header { Line 711  sub screen_header {
  }   }
     }      }
     if ($ENV{'request.course.id'}) {      if ($ENV{'request.course.id'}) {
  if (&Apache::lonnet::allowed('pch',   if (&discussion_open() &&
       &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'}:''))) {
     $discussoptions='<input type="checkbox" name="discuss" onClick="this.form.anondiscuss.checked=false;" '.      $discussoptions='<input type="checkbox" name="discuss" onClick="this.form.anondiscuss.checked=false;" '.
Line 675  sub resource_output { Line 744  sub resource_output {
   
 sub clear_out_html {  sub clear_out_html {
   my ($message,$override)=@_;    my ($message,$override)=@_;
     unless (&Apache::lonhtmlcommon::htmlareablocked()) { return $message; }
   my $cid=$ENV{'request.course.id'};    my $cid=$ENV{'request.course.id'};
   if (($ENV{"course.$cid.allow_limited_html_in_feedback"} =~ m/yes/i) ||    if (($ENV{"course.$cid.allow_limited_html_in_feedback"} =~ m/yes/i) ||
       ($override)) {        ($override)) {
       # allows <B> <I> <P> <A> <LI> <OL> <UL> <EM> <BR> <TT> <STRONG>         # allows <B> <I> <P> <A> <LI> <OL> <UL> <EM> <BR> <TT> <STRONG> 
       # <BLOCKQUOTE> <DIV .*> <DIV> <IMG>        # <BLOCKQUOTE> <DIV .*> <DIV> <IMG> <M> <SPAN> <H1> <H2> <H3> <H4> <SUB>
         # <SUP>
       my %html=(B=>1, I=>1, P=>1, A=>1, LI=>1, OL=>1, UL=>1, EM=>1,        my %html=(B=>1, I=>1, P=>1, A=>1, LI=>1, OL=>1, UL=>1, EM=>1,
  BR=>1, TT=>1, STRONG=>1, BLOCKQUOTE=>1, DIV=>1, IMG=>1,   BR=>1, TT=>1, STRONG=>1, BLOCKQUOTE=>1, DIV=>1, IMG=>1,
                 M=>1);                  M=>1, SUB=>1, SUP=>1, SPAN=>1, 
    H1=>1, H2=>1, H3=>1, H4=>1, H5=>1);
   
       $message =~ s/\<(\/?\s*(\w+)[^\>\<]*)/        $message =~ s/\<(\/?\s*(\w+)[^\>\<]*)/
   {($html{uc($2)}&&(length($1)<1000))?"\<$1":"\&lt;$1"}/ge;    {($html{uc($2)}&&(length($1)<1000))?"\<$1":"\&lt;$1"}/ge;
Line 816  sub send_msg { Line 888  sub send_msg {
 sub adddiscuss {  sub adddiscuss {
     my ($symb,$email,$anon,$attachmenturl,$subject)=@_;      my ($symb,$email,$anon,$attachmenturl,$subject)=@_;
     my $status='';      my $status='';
     if (&Apache::lonnet::allowed('pch',$ENV{'request.course.id'}.      if (&discussion_open() &&
    &Apache::lonnet::allowed('pch',$ENV{'request.course.id'}.
         ($ENV{'request.course.sec'}?'/'.$ENV{'request.course.sec'}:''))) {          ($ENV{'request.course.sec'}?'/'.$ENV{'request.course.sec'}:''))) {
   
     my %contrib=('message'      => $email,      my %contrib=('message'      => $email,
Line 883  sub generate_preview_button { Line 956  sub generate_preview_button {
 <input type="hidden" name="subject">  <input type="hidden" name="subject">
 <input type="hidden" name="comment" />  <input type="hidden" name="comment" />
 <input type="button" value="$pre"  <input type="button" value="$pre"
 onClick="this.form.comment.value=document.mailform.comment.value;this.form.subject.value=document.mailform.subject.value;this.form.submit();" />  onClick="document.mailform.onsubmit();this.form.comment.value=document.mailform.comment.value;this.form.subject.value=document.mailform.subject.value;this.form.submit();" />
 </form>  </form>
 ENDPREVIEW  ENDPREVIEW
 }  }

Removed from v.1.86  
changed lines
  Added in v.1.96


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