Diff for /loncom/interface/lonfeedback.pm between versions 1.116 and 1.132

version 1.116, 2004/08/17 14:27:19 version 1.132, 2004/11/14 07:54:41
Line 36  use Apache::loncommon(); Line 36  use Apache::loncommon();
 use Apache::lontexconvert();  use Apache::lontexconvert();
 use Apache::lonlocal; # must not have ()  use Apache::lonlocal; # must not have ()
 use Apache::lonhtmlcommon();  use Apache::lonhtmlcommon();
   use Apache::lonnavmaps;
   use Apache::lonenc();
 use HTML::LCParser();  use HTML::LCParser();
 use Apache::lonspeller();  use Apache::lonspeller();
 use Cwd;  use Cwd;
   
 sub discussion_open {  sub discussion_open {
     my ($status)=@_;      my ($status,$symb)=@_;
     if (defined($status) &&      if (defined($status) &&
  !($status eq 'CAN_ANSWER' || $status eq 'CANNOT_ANSWER'   !($status eq 'CAN_ANSWER' || $status eq 'CANNOT_ANSWER'
   || $status eq 'OPEN')) {    || $status eq 'OPEN')) {
  return 0;   return 0;
     }      }
     my $close=&Apache::lonnet::EXT('resource.0.discussend');      my $close=&Apache::lonnet::EXT('resource.0.discussend',$symb);
     if (defined($close) && $close ne '' && $close < time) {      if (defined($close) && $close ne '' && $close < time) {
  return 0;   return 0;
     }      }
Line 59  sub discussion_visible { Line 61  sub discussion_visible {
     if (not &discussion_open($status)) {      if (not &discussion_open($status)) {
  my $hidden=&Apache::lonnet::EXT('resource.0.discusshide');   my $hidden=&Apache::lonnet::EXT('resource.0.discusshide');
  if (lc($hidden) eq 'yes' or $hidden eq '' or !defined($hidden))  {   if (lc($hidden) eq 'yes' or $hidden eq '' or !defined($hidden))  {
     return 0;      if (!$ENV{'request.role.adv'}) { return 0; }
  }   }
     }      }
     return 1;      return 1;
Line 98  sub list_discussion { Line 100  sub list_discussion {
             $ressymb=~s|(bulletin___\d+___)|$1adm/wrapper|;              $ressymb=~s|(bulletin___\d+___)|$1adm/wrapper|;
         }          }
     }      }
       $ressymb=&Apache::lonenc::check_encrypt($ressymb);
 # Get discussion display settings for this discussion  # Get discussion display settings for this discussion
     my $lastkey = $ressymb.'_lastread';      my $lastkey = $ressymb.'_lastread';
     my $showkey = $ressymb.'_showonlyunread';      my $showkey = $ressymb.'_showonlyunread';
Line 165  sub list_discussion { Line 167  sub list_discussion {
     }      }
   
 # Get discussion display default settings for user  # Get discussion display default settings for user
     my %userenv = &Apache::lonnet::get('environment',['discdisplay','discmarkread'],$ENV{'user.domain'},$ENV{'user.name'});      if ($ENV{'environment.discdisplay'} eq 'unread') {
     my $discdisplay=$userenv{'discdisplay'};  
     if ($discdisplay eq 'unread') {  
         $showonlyunread = 1;          $showonlyunread = 1;
     }      }
     my $discmarkread=$userenv{'discmarkread'};      if ($ENV{'environment.discmarkread'} eq 'ondisp') {
     if ($discmarkread eq 'ondisp') {  
         $markondisp = 1;          $markondisp = 1;
     }      }
   
 # Override user's default if user specified display setting for this discussion  # Override user's default if user specified display setting for this discussion
     if (defined($dischash{$ondispkey})) {      if (defined($dischash{$ondispkey})) {
         $markondisp = $dischash{$ondispkey};          unless ($dischash{$ondispkey} eq '') {
               $markondisp = $dischash{$ondispkey};
           }
     }      }
     if ($markondisp) {      if ($markondisp) {
         $discinfo{$lastkey} = time;          $discinfo{$lastkey} = time;
     }      }
   
     if (defined($dischash{$showkey})) {      if (defined($dischash{$showkey})) {
         $showonlyunread = $dischash{$showkey};          unless ($dischash{$showkey} eq '') {
               $showonlyunread = $dischash{$showkey};
           }
     }      }
   
     if (defined($dischash{$markkey})) {      if (defined($dischash{$markkey})) {
         $showunmark = $dischash{$markkey};          unless ($dischash{$markkey} eq '') {
               $showunmark = $dischash{$markkey};
           }
     }      }
   
     if (defined($dischash{$visitkey})) {      if (defined($dischash{$visitkey})) {
         $visit = $dischash{$visitkey};          unless ($dischash{$visitkey} eq '') {
               $visit = $dischash{$visitkey};
           }
     }      }
     $visit ++;      $visit ++;
   
Line 324  sub list_discussion { Line 331  sub list_discussion {
 # open manifest file  # open manifest file
             my $manifest = '/imsmanifest.xml';              my $manifest = '/imsmanifest.xml';
             my $manifestfilename = $tempexport.$manifest;              my $manifestfilename = $tempexport.$manifest;
             print STDERR "manifestfilename is $manifestfilename\n";  
             if ($manifestfile = Apache::File->new('>'.$manifestfilename)) {              if ($manifestfile = Apache::File->new('>'.$manifestfilename)) {
                 $manifestok=1;                  $manifestok=1;
                 print $manifestfile qq|                  print $manifestfile qq|
Line 355  imscp_v1p1.xsd http://www.imsglobal.org/ Line 361  imscp_v1p1.xsd http://www.imsglobal.org/
    }     }
 </script>  </script>
             |;              |;
     $discussion.='<form name="readchoices" method="post" action="/adm/feedback?chgreads='.$symb.'"><table bgcolor="#AAAAAA" cellpadding="2" cellspacing="2" border="0">';      $discussion.='<form name="readchoices" method="post" action="/adm/feedback?chgreads='.$ressymb.'"><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) {
Line 446  imscp_v1p1.xsd http://www.imsglobal.org/ Line 452  imscp_v1p1.xsd http://www.imsglobal.org/
                 $alldiscussion{$_} = $_;                  $alldiscussion{$_} = $_;
             }              }
             unless ( ($notshown{$alldiscussion{$_}} eq '1') || ($shown{$alldiscussion{$_}} == 0) ) {              unless ( ($notshown{$alldiscussion{$_}} eq '1') || ($shown{$alldiscussion{$_}} == 0) ) {
                 unless ($outputtarget eq 'tex' && $outputtarget eq 'export') {                  if ($outputtarget ne 'tex' && $outputtarget ne 'export') {
     $discussion.="\n<tr>";      $discussion.="\n<tr>";
  }   }
         my $thisdepth=$depth[$alldiscussion{$_}];          my $thisdepth=$depth[$alldiscussion{$_}];
                 unless ($outputtarget eq 'tex' || $outputtarget eq 'export') {                  if ($outputtarget ne 'tex' && $outputtarget ne 'export') {
     for (1..$thisdepth) {      for (1..$thisdepth) {
  $discussion.='<td>&nbsp;&nbsp;&nbsp;</td>';   $discussion.='<td>&nbsp;&nbsp;&nbsp;</td>';
     }      }
Line 474  imscp_v1p1.xsd http://www.imsglobal.org/ Line 480  imscp_v1p1.xsd http://www.imsglobal.org/
                     my $postfilename = $alldiscussion{$_}.'-'.$imsitems{$alldiscussion{$_}}{'timestamp'}.'.html';                      my $postfilename = $alldiscussion{$_}.'-'.$imsitems{$alldiscussion{$_}}{'timestamp'}.'.html';
                     if ($manifestok) {                      if ($manifestok) {
                         if (($depth[$alldiscussion{$_}] <= $currdepth) && ($alldiscussion{$_} != $firstidx)) {                          if (($depth[$alldiscussion{$_}] <= $currdepth) && ($alldiscussion{$_} != $firstidx)) {
                             print STDERR "depth is $depth[$alldiscussion{$_}], currdepth is $currdepth, idx is $alldiscussion{$_}, firstidx is $firstidx\n";  
                             print $manifestfile '  </item>'."\n";                              print $manifestfile '  </item>'."\n";
                         }                          }
                         $currdepth = $depth[$alldiscussion{$_}];                          $currdepth = $depth[$alldiscussion{$_}];
Line 600  END Line 605  END
                 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 - '.$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 618  END Line 623  END
         my $subject = '';          my $subject = '';
         if ($ENV{'form.origpage'}) {          if ($ENV{'form.origpage'}) {
             &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['addnewattach','deloldattach','delnewattach','timestamp','idx','subject','comment']);              &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['addnewattach','deloldattach','delnewattach','timestamp','idx','subject','comment']);
             $subject = &HTML::Entities::encode($ENV{'form.subject'},'<>&"');              $subject = &Apache::lonnet::unescape($ENV{'form.subject'});
             $comment = &HTML::Entities::encode($ENV{'form.comment'},'<>&"');              $comment = &Apache::lonnet::unescape($ENV{'form.comment'});
             my @keepold = ();              my @keepold = ();
             &process_attachments(\@currnewattach,\@currdelold,\@keepold);              &process_attachments(\@currnewattach,\@currdelold,\@keepold);
             if (@currnewattach > 0) {              if (@currnewattach > 0) {
                 $attachnum += @currnewattach;                  $attachnum += @currnewattach;
             }              }
         }          }
  $discussion.=(<<ENDDISCUSS);   if (&discussion_open($status)) {
       $discussion.=(<<ENDDISCUSS);
 <form action="/adm/feedback" method="post" name="mailform" enctype="multipart/form-data">  <form action="/adm/feedback" method="post" name="mailform" enctype="multipart/form-data">
 <input type="submit" name="discuss" value="Post Discussion" />  <input type="submit" name="discuss" value="Post Discussion" />
 <input type="submit" name="anondiscuss" value="Post Anonymous Discussion" />  <input type="submit" name="anondiscuss" value="Post Anonymous Discussion" />
Line 665  ENDDISCUSS Line 671  ENDDISCUSS
             $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',
Line 672  ENDDISCUSS Line 679  ENDDISCUSS
  ($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='.
     $symb.':::" '.$target.'>'.      $ressymb.':::" '.$target.'>'.
     '<img src="/adm/lonMisc/chat.gif" border="0" />'.      '<img src="/adm/lonMisc/chat.gif" border="0" />'.
     &mt('Post Discussion').'</a></td></tr></table>';      &mt('Post Discussion').'</a></td></tr></table>';
     }      }
Line 1046  sub get_post_contents { Line 1053  sub get_post_contents {
            return $discussion;             return $discussion;
        }          } 
     }      }
     $$screenname=&Apache::loncommon::screenname(  #    $$screenname=&Apache::loncommon::screenname(
                                         $$contrib{$idx.':sendername'},  #                                        $$contrib{$idx.':sendername'},
                                         $$contrib{$idx.':senderdomain'});  #                                        $$contrib{$idx.':senderdomain'});
     $$plainname=&Apache::loncommon::nickname(  #    $$plainname=&Apache::loncommon::nickname(
                                         $$contrib{$idx.':sendername'},  #                                        $$contrib{$idx.':sendername'},
                                         $$contrib{$idx.':senderdomain'});  #                                        $$contrib{$idx.':senderdomain'});
       ($$screenname,$$plainname)=($$contrib{$idx.':screenname'},
    $$contrib{$idx.':plainname'});
     my $sender=&Apache::loncommon::aboutmewrapper(      my $sender=&Apache::loncommon::aboutmewrapper(
                                  $$plainname,                                   $$plainname,
                                  $$contrib{$idx.':sendername'},                                   $$contrib{$idx.':sendername'},
Line 1149  sub replicate_attachments { Line 1158  sub replicate_attachments {
                     $i ++;                      $i ++;
                 }                  }
                 my ($content,$rtncode);                  my ($content,$rtncode);
                 print STDERR "File to replicate is $$attachrefs{$id}{'filename'} in $1,$2\n";  
                 my $uploadreply = &Apache::lonnet::getuploaded('GET',$$attachrefs{$id}{'filename'},$1,$2,$content,$rtncode);                  my $uploadreply = &Apache::lonnet::getuploaded('GET',$$attachrefs{$id}{'filename'},$1,$2,$content,$rtncode);
                 if ($uploadreply eq 'ok') {                  if ($uploadreply eq 'ok') {
                      my $attachcopy;                      my $attachcopy;
                      if ($attachcopy = Apache::File->new('>'.$destination)) {                      if ($attachcopy = Apache::File->new('>'.$destination)) {
                          print $attachcopy $content;                          print $attachcopy $content;
                          close($attachcopy);                          close($attachcopy);
                      } else {                      } else {
                          $response .= 'Error copying a file attachment to IMS package: '.$!.'<br />'."\n";                          $response .= 'Error copying file attachment - '.$5.' to IMS package: '.$!.'<br />'."\n";
                      }                      }
                 } else {                  } else {
                     print STDERR "return code from lonnet was $rtncode\n";                      &Apache::lonnet::logthis("Replication of attachment failed when building IMS export of discussion posts - domain: $1, course: $2, file: $$attachrefs{$id}{'filename'} -error: $rtncode");
                       $response .= 'Error copying file attachment - '.$5.' to IMS package: '.$rtncode.'<br />'."\n";
                 }                  }
             }              }
         }          }
     }      }
       return $response;
 }  }
   
 sub mail_screen {  sub mail_screen {
Line 1306  END Line 1316  END
   }    }
   
   if ($ENV{'form.origpage'}) {    if ($ENV{'form.origpage'}) {
       $subject = $ENV{'form.subject'};        $subject = &Apache::lonnet::unescape($ENV{'form.subject'});
       $comment = $ENV{'form.comment'};        $comment = &Apache::lonnet::unescape($ENV{'form.comment'});
       &process_attachments(\@currnewattach,\@currdelold,\@keepold);        &process_attachments(\@currnewattach,\@currdelold,\@keepold);
   }    }
   my $latexHelp=&Apache::loncommon::helpLatexCheatsheet();    my $latexHelp=&Apache::loncommon::helpLatexCheatsheet();
Line 1355  $htmlheader Line 1365  $htmlheader
         }          }
   
         if (rec) {          if (rec) {
             if (typeof(document.mailform.onsubmit)!='undefined') {              if (typeof(document.mailform.onsubmit)=='function') {
  document.mailform.onsubmit();   document.mailform.onsubmit();
     }      }
     document.mailform.submit();      document.mailform.submit();
Line 1977  sub get_post_attachments { Line 1987  sub get_post_attachments {
     return;      return;
 }  }
   
 sub build_ims_export {  
     my ($r,$symb,$previous,$feedurl) = @_;  
  # backward compatibility (bulletin boards used to be 'wrapped')  
     if ($feedurl=~m|^/adm/wrapper/adm/.*/bulletinboard$|) {  
         $feedurl=~s|^/adm/wrapper||;  
     }  
     my %contrib=&Apache::lonnet::restore($symb,$ENV{'request.course.id'},  
                           $ENV{'course.'.$ENV{'request.course.id'}.'.domain'},  
                           $ENV{'course.'.$ENV{'request.course.id'}.'.num'});  
     my @depth=();  
     my %alldiscussion=();  
     my @discussionitems=();  
     my %usernamesort = ();  
     my %subjectsort = ();  
     my %namesort = ();  
     my %notshown = ();  
     my %newitem = ();  
     my %dischash = ();  
     my %shown = ();  
     my %roleinfo = ();  
     my @posters=();  
     my $maxdepth=0;  
     my $visible=0;  
     my $newpostsflag=0;  
     my $status;  
     my $viewgrades;  
     my $seeid;  
     my $prevread;  
     my $sortposts;  
     my $ressymb;  
     my $target;  
     my $readkey;  
     my $showunmark;  
     my $showonlyunread;  
   
 }  
   
   
   
 sub fail_redirect {;  sub fail_redirect {;
   my ($r,$feedurl) = @_;    my ($r,$feedurl) = @_;
   if ($feedurl=~/^\/adm\//) { $feedurl.='?register=1' };    if ($feedurl=~/^\/adm\//) { $feedurl.='?register=1' };
Line 2028  sub fail_redirect {; Line 1999  sub fail_redirect {;
 <body bgcolor="#FFFFFF">  <body bgcolor="#FFFFFF">
 <img align="right" src="/adm/lonIcons/lonlogos.gif" />  <img align="right" src="/adm/lonIcons/lonlogos.gif" />
 <b>Sorry, no recipients  ...</b>  <b>Sorry, no recipients  ...</b>
   <br /><a href="$feedurl">Continue</a>
 </body>  </body>
 </html>  </html>
 ENDFAILREDIR  ENDFAILREDIR
Line 2078  sub redirect_back { Line 2050  sub redirect_back {
           $sectag = '<input type="hidden" name="sectionpick" value="'.$secpick.'" />';            $sectag = '<input type="hidden" name="sectionpick" value="'.$secpick.'" />';
       }        }
   }    }
     $feedurl=&Apache::lonenc::check_encrypt($feedurl);
   $r->print (<<ENDREDIR);    $r->print (<<ENDREDIR);
 <html>  <html>
 <head>  <head>
Line 2098  $roletag Line 2071  $roletag
 $sectag  $sectag
 $userpicktag  $userpicktag
 </form>  </form>
   <br /><a href="$feedurl">Continue</a>
 </body>  </body>
 </html>  </html>
 ENDREDIR  ENDREDIR
Line 2106  ENDREDIR Line 2080  ENDREDIR
 sub no_redirect_back {  sub no_redirect_back {
   my ($r,$feedurl) = @_;    my ($r,$feedurl) = @_;
   my $nofeed=&mt('Sorry, no feedback possible on this resource  ...');    my $nofeed=&mt('Sorry, no feedback possible on this resource  ...');
     my $continue=&mt('Continue');
   $r->print (<<ENDNOREDIR);    $r->print (<<ENDNOREDIR);
 <html>  <html>
 <head><title>Feedback not sent</title>  <head><title>Feedback not sent</title>
Line 2113  sub no_redirect_back { Line 2088  sub no_redirect_back {
 ENDNOREDIR  ENDNOREDIR
   
   if ($feedurl!~/^\/adm\/feedback/) {     if ($feedurl!~/^\/adm\/feedback/) { 
     $r->print('<meta HTTP-EQUIV="Refresh" CONTENT="2; url='.$feedurl.'">');        $r->print('<meta HTTP-EQUIV="Refresh" CONTENT="2; url='.
    &Apache::lonenc::check_encrypt($feedurl).'">');
   }    }
       $feedurl=&Apache::lonenc::check_encrypt($feedurl);
   $r->print (<<ENDNOREDIRTWO);    $r->print (<<ENDNOREDIRTWO);
 </head>  </head>
 <body bgcolor="#FFFFFF" onLoad='if (window.name!="loncapaclient") { self.close(); }'>  <body bgcolor="#FFFFFF" onLoad='if (window.name!="loncapaclient") { self.close(); }'>
 <img align="right" src="/adm/lonIcons/lonlogos.gif" />  <img align="right" src="/adm/lonIcons/lonlogos.gif" />
 <b>$nofeed</b>  <b>$nofeed</b>
   <br /><a href="$feedurl">$continue</a>
 </body>  </body>
 </html>  </html>
 ENDNOREDIRTWO  ENDNOREDIRTWO
Line 2212  sub clear_out_html { Line 2189  sub clear_out_html {
 sub assemble_email {  sub assemble_email {
   my ($feedurl,$message,$prevattempts,$usersaw,$useranswer)=@_;    my ($feedurl,$message,$prevattempts,$usersaw,$useranswer)=@_;
   my $email=<<"ENDEMAIL";    my $email=<<"ENDEMAIL";
 Refers to <a href="$feedurl">$feedurl</a>  
   
 $message  $message
 ENDEMAIL  ENDEMAIL
     my $citations=<<"ENDCITE";      my $citations=<<"ENDCITE";
Line 2330  sub send_msg { Line 2305  sub send_msg {
 sub adddiscuss {  sub adddiscuss {
     my ($symb,$email,$anon,$attachmenturl,$subject)=@_;      my ($symb,$email,$anon,$attachmenturl,$subject)=@_;
     my $status='';      my $status='';
     if (&discussion_open() &&      my $realsymb;
       if ($symb=~/^bulletin___/) {
    my $filename=(&Apache::lonnet::decode_symb($symb))[2];
    $filename=~s|^adm/wrapper/||;
    $realsymb=&Apache::lonnet::symbread($filename);
       }
       if (&discussion_open(undef,$realsymb) &&
  &Apache::lonnet::allowed('pch',$ENV{'request.course.id'}.   &Apache::lonnet::allowed('pch',$ENV{'request.course.id'}.
         ($ENV{'request.course.sec'}?'/'.$ENV{'request.course.sec'}:''))) {          ($ENV{'request.course.sec'}?'/'.$ENV{'request.course.sec'}:''))) {
   
Line 2359  sub adddiscuss { Line 2340  sub adddiscuss {
             $contrib{'history'} = '';              $contrib{'history'} = '';
             my $numoldver = 0;              my $numoldver = 0;
             my ($oldsymb,$oldidx)=split(/\:\:\:/,$ENV{'form.editdisc'});              my ($oldsymb,$oldidx)=split(/\:\:\:/,$ENV{'form.editdisc'});
       &Apache::lonenc::check_decrypt(\$oldsymb);
             $oldsymb=~s|(bulletin___\d+___)adm/wrapper/|$1|;              $oldsymb=~s|(bulletin___\d+___)adm/wrapper/|$1|;
 # get timestamp for last post and history  # get timestamp for last post and history
             my %oldcontrib=&Apache::lonnet::restore($oldsymb,$ENV{'request.course.id'},              my %oldcontrib=&Apache::lonnet::restore($oldsymb,$ENV{'request.course.id'},
Line 2453  sub generate_preview_button { Line 2435  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="if (typeof(document.mailform.onsubmit)!='undefined') {document.mailform.onsubmit();};this.form.comment.value=document.mailform.comment.value;this.form.subject.value=document.mailform.subject.value;this.form.submit();" />  onClick="if (typeof(document.mailform.onsubmit)=='function') {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
 }  }
   
 sub modify_attachments {  sub modify_attachments {
     my ($r,$currnewattach,$currdelold,$symb,$idx,$attachmenturls)=@_;      my ($r,$currnewattach,$currdelold,$symb,$idx,$attachmenturls)=@_;
     my $subject=&clear_out_html($ENV{'form.subject'});      my $orig_subject = &Apache::lonnet::unescape($ENV{'form.subject'});
       my $subject=&clear_out_html($orig_subject);
     $subject=~s/\n/\<br \/\>/g;      $subject=~s/\n/\<br \/\>/g;
     $subject=&Apache::lontexconvert::msgtexconverted($subject);      $subject=&Apache::lontexconvert::msgtexconverted($subject);
     my $timestamp=$ENV{'form.timestamp'};      my $timestamp=$ENV{'form.timestamp'};
Line 2489  $bodytag Line 2472  $bodytag
  <table border="2">   <table border="2">
   <tr>    <tr>
    <td>     <td>
     <b>Subject:</b>$subject</b><br /><br />      <b>Subject:</b> $subject</b><br /><br />
 END  END
     if ($idx) {      if ($idx) {
         if ($attachmenturls) {          if ($attachmenturls) {
Line 2596  sub generate_attachments_button { Line 2579  sub generate_attachments_button {
     my $response = (<<END);      my $response = (<<END);
 <form name="attachment" action="/adm/feedback?attach=$ressymb" method="post">  <form name="attachment" action="/adm/feedback?attach=$ressymb" method="post">
 Click to add/remove attachments:&nbsp;<input type="button" value="$att"  Click to add/remove attachments:&nbsp;<input type="button" value="$att"
 onClick="this.form.subject.value=document.mailform.subject.value;this.form.comment.value=document.mailform.comment.value;  onClick="if (typeof(document.mailform.onsubmit)=='function') {document.mailform.onsubmit();};this.form.comment.value=escape(document.mailform.comment.value);this.form.subject.value=escape(document.mailform.subject.value);
 END  END
     unless ($mode eq 'board') {      unless ($mode eq 'board') {
         $response .= 'javascript:anonchk();';          $response .= 'javascript:anonchk();';
Line 2736  sub construct_attachmenturl { Line 2719  sub construct_attachmenturl {
     }      }
     return $newattachmenturl;       return $newattachmenturl; 
 }  }
   
   sub has_discussion {
       my $resourcesref = shift;
       my $navmap = Apache::lonnavmaps::navmap->new();
       my @allres=$navmap->retrieveResources();
       foreach my $resource (@allres) {
           if ($resource->hasDiscussion()) {
               my $ressymb;
               if ($resource->symb() =~ m-(___adm/\w+/\w+)/(\d+)/bulletinboard$-) {
                   $ressymb = 'bulletin___'.$2.$1.'/'.$2.'/bulletinboard';
               } else {
                   $ressymb = $resource->symb();
               }
               push @{$resourcesref}, $ressymb;
           }
       }
       return;
   } 
       
 sub handler {  sub handler {
   my $r = shift;    my $r = shift;
Line 2748  sub handler { Line 2749  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','navmaps','navurl','sortfilter','sortposts','applysort','rolefilter','statusfilter','sectionpick','posterlist','userpick','attach','origpage','currnewattach','deloldattach','keepold','allversions','export']);           ['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']);
   if ($ENV{'form.discsymb'}) {    if ($ENV{'form.discsymb'}) {
       my $symb = $ENV{'form.discsymb'};        my $symb = $ENV{'form.discsymb'};
       my $readkey = $symb.'_read';        my $readkey = $symb.'_read';
Line 2800  END Line 2801  END
       my $seeid=&Apache::lonnet::allowed('rin',$crs);        my $seeid=&Apache::lonnet::allowed('rin',$crs);
       my ($symb,$idx)=split(/\:\:\:/,$ENV{'form.allversions'});        my ($symb,$idx)=split(/\:\:\:/,$ENV{'form.allversions'});
       my $ressymb=$symb;        my $ressymb=$symb;
         &Apache::lonenc::check_decrypt(\$ressymb);
       unless ($ressymb =~ m|bulletin___\d+___adm/wrapper|) {        unless ($ressymb =~ m|bulletin___\d+___adm/wrapper|) {
           $ressymb=~s|(bulletin___\d+___)|$1adm/wrapper|;            $ressymb=~s|(bulletin___\d+___)|$1adm/wrapper|;
       }        }
Line 2841  END Line 2843  END
       my $previous=$ENV{'form.previous'};        my $previous=$ENV{'form.previous'};
 # backward compatibility (bulletin boards used to be 'wrapped')  # backward compatibility (bulletin boards used to be 'wrapped')
       my $ressymb=$symb;        my $ressymb=$symb;
         &Apache::lonenc::check_decrypt(\$ressymb);
       unless ($ressymb =~ m|bulletin___\d+___adm/wrapper|) {        unless ($ressymb =~ m|bulletin___\d+___adm/wrapper|) {
           $ressymb=~s|(bulletin___\d+___)|$1adm/wrapper|;            $ressymb=~s|(bulletin___\d+___)|$1adm/wrapper|;
       }        }
Line 2895  END Line 2898  END
       }        }
       &print_sortfilter_options($r,$symb,$previous,$feedurl);        &print_sortfilter_options($r,$symb,$previous,$feedurl);
       return OK;        return OK;
   } elsif ($ENV{'form.navmaps'}) {    } elsif ($ENV{'form.navtime'}) {
       my %discinfo = ();        my %discinfo = ();
       my @resources = ();        my @resources = ();
       if ($ENV{'form.navmaps'} =~ /:/) {        if (defined($ENV{'form.navmaps'})) {
           @resources = split/:/,$ENV{'form.navmaps'};            if ($ENV{'form.navmaps'} =~ /:/) {
                 @resources = split/:/,$ENV{'form.navmaps'};
             } else {
                 @resources = ("$ENV{'form.navmaps'}");
             }
       } else {        } else {
           @resources = ("$ENV{'form.navmaps'}");            &has_discussion(\@resources);
       }        }
       my $numitems = @resources;        my $numitems = @resources;
       my $feedurl = '/adm/navmaps';        my $feedurl = '/adm/navmaps';
Line 2910  END Line 2917  END
       }        }
       my %lt = &Apache::lonlocal::texthash(        my %lt = &Apache::lonlocal::texthash(
           'mnpa' => 'Marked "New" posts as read in a total of',            'mnpa' => 'Marked "New" posts as read in a total of',
           'robb' => 'resources/bulletin boards.'            'robb' => 'resources/bulletin boards.',
             'twnp' => 'There are currently no resources or bulletin boards with unread discussion postings.'
       );               );       
       foreach (@resources) {        foreach (@resources) {
 # backward compatibility (bulletin boards used to be 'wrapped')  # backward compatibility (bulletin boards used to be 'wrapped')
           my $ressymb=$_;            my $ressymb=$_;
     &Apache::lonenc::check_decrypt(\$ressymb);
           if ($ressymb =~ m/bulletin___\d+___/) {            if ($ressymb =~ m/bulletin___\d+___/) {
               unless ($ressymb =~ m|bulletin___\d+___adm/wrapper|) {                unless ($ressymb =~ m|bulletin___\d+___adm/wrapper|) {
                   $ressymb=~s|(bulletin___\d+___)|$1adm/wrapper/|;                    $ressymb=~s|(bulletin___\d+___)|$1adm/wrapper/|;
               }                }
           }            }
           my $lastkey = $ressymb.'_lastread';            my $lastkey = $ressymb.'_lastread';
           $discinfo{$lastkey} = time;            $discinfo{$lastkey} = $ENV{'form.navtime'};
         }
         my $textline = "<b>$lt{'mnpa'} $numitems $lt{'robb'}</b>";
         if ($numitems > 0) {
             &Apache::lonnet::put('nohist_'.$ENV{'request.course.id'}.'_discuss',\%discinfo,$ENV{'user.domain'},$ENV{'user.name'});
         } else {
             $textline = "<b>$lt{'twnp'}</b>";
       }        }
       &Apache::lonnet::put('nohist_'.$ENV{'request.course.id'}.'_discuss',\%discinfo,$ENV{'user.domain'},$ENV{'user.name'});  
       &Apache::loncommon::content_type($r,'text/html');        &Apache::loncommon::content_type($r,'text/html');
       $r->send_http_header;        $r->send_http_header;
       $r->print (<<ENDREDIR);        $r->print (<<ENDREDIR);
Line 2935  END Line 2949  END
 </head>  </head>
 <body bgcolor="#FFFFFF" onLoad='if (window.name!="loncapaclient") { this.document.reldt.submit(); self.close(); }'>  <body bgcolor="#FFFFFF" onLoad='if (window.name!="loncapaclient") { this.document.reldt.submit(); self.close(); }'>
 <img align="right" src="/adm/lonIcons/lonlogos.gif" />  <img align="right" src="/adm/lonIcons/lonlogos.gif" />
 <b>$lt{'mnpa'} $numitems $lt{'robb'}</b>  $textline
 <form name="reldt" action="$feedurl" target="loncapaclient">  <form name="reldt" action="$feedurl" target="loncapaclient">
 </form>  </form>
   <br /><a href="$feedurl">Continue</a>
 </body>  </body>
 </html>  </html>
 ENDREDIR  ENDREDIR
Line 2966  ENDREDIR Line 2981  ENDREDIR
           my $symb=$ENV{'form.toggoff'}?$ENV{'form.toggoff'}:$ENV{'form.toggon'};            my $symb=$ENV{'form.toggoff'}?$ENV{'form.toggoff'}:$ENV{'form.toggon'};
           my $ressymb = $symb;            my $ressymb = $symb;
           ($map,$ind,$url)=&Apache::lonnet::decode_symb($symb);            ($map,$ind,$url)=&Apache::lonnet::decode_symb($symb);
     &Apache::lonenc::check_decrypt(\$ressymb);
           unless ($ressymb =~ m|bulletin___\d+___adm/wrapper|) {            unless ($ressymb =~ m|bulletin___\d+___adm/wrapper|) {
               $ressymb=~s|(bulletin___\d+___)|$1adm/wrapper|;                $ressymb=~s|(bulletin___\d+___)|$1adm/wrapper|;
           }            }
Line 2983  ENDREDIR Line 2999  ENDREDIR
           my $symb=$ENV{'form.markondisp'}?$ENV{'form.markondisp'}:$ENV{'form.markonread'};            my $symb=$ENV{'form.markondisp'}?$ENV{'form.markondisp'}:$ENV{'form.markonread'};
           my $ressymb = $symb;            my $ressymb = $symb;
           ($map,$ind,$url)=&Apache::lonnet::decode_symb($symb);            ($map,$ind,$url)=&Apache::lonnet::decode_symb($symb);
     &Apache::lonenc::check_decrypt(\$ressymb);
           unless ($ressymb =~ m|bulletin___\d+___adm/wrapper|) {            unless ($ressymb =~ m|bulletin___\d+___adm/wrapper|) {
               $ressymb=~s|(bulletin___\d+___)|$1adm/wrapper|;                $ressymb=~s|(bulletin___\d+___)|$1adm/wrapper|;
           }            }
Line 3012  ENDREDIR Line 3029  ENDREDIR
           }            }
           my $ressymb = $symb;            my $ressymb = $symb;
           ($map,$ind,$url)=&Apache::lonnet::decode_symb($symb);            ($map,$ind,$url)=&Apache::lonnet::decode_symb($symb);
     &Apache::lonenc::check_decrypt(\$ressymb);
           unless ($ressymb =~ m|bulletin___\d+___adm/wrapper|) {            unless ($ressymb =~ m|bulletin___\d+___adm/wrapper|) {
               $ressymb=~s|(bulletin___\d+___)|$1adm/wrapper|;                $ressymb=~s|(bulletin___\d+___)|$1adm/wrapper|;
           }            }
Line 3039  ENDREDIR Line 3057  ENDREDIR
       my $symb=$ENV{'form.markread'};        my $symb=$ENV{'form.markread'};
       my $ressymb = $symb;        my $ressymb = $symb;
       my ($map,$ind,$url)=&Apache::lonnet::decode_symb($symb);        my ($map,$ind,$url)=&Apache::lonnet::decode_symb($symb);
         &Apache::lonenc::check_decrypt(\$ressymb);
       unless ($ressymb =~ m|bulletin___\d+___adm/wrapper|) {        unless ($ressymb =~ m|bulletin___\d+___adm/wrapper|) {
           $ressymb=~s|(bulletin___\d+___)|$1adm/wrapper|;            $ressymb=~s|(bulletin___\d+___)|$1adm/wrapper|;
       }        }
Line 3189  ENDREDIR Line 3208  ENDREDIR
           $status=$Apache::inputtags::status[-1];            $status=$Apache::inputtags::status[-1];
       }        }
       my $discussion = &list_discussion($mode,$status,$symb);         my $discussion = &list_discussion($mode,$status,$symb); 
 #      &build_ims_export($r,$symb,$previous,$feedurl);  
       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;
Line 3222  ENDREDIR Line 3240  ENDREDIR
           $feedurl=&Apache::lonnet::clutter($url);            $feedurl=&Apache::lonnet::clutter($url);
       }        }
   }    }
     &Apache::lonenc::check_decrypt(\$symb);
   my $goahead=1;    my $goahead=1;
   if ($feedurl=~/\.(problem|exam|quiz|assess|survey|form)$/) {    if ($feedurl=~/\.(problem|exam|quiz|assess|survey|form)$/) {
       unless ($symb) { $goahead=0; }        unless ($symb) { $goahead=0; }
Line 3279  ENDREDIR Line 3298  ENDREDIR
           } elsif ($ENV{'form.origpage'}) {            } elsif ($ENV{'form.origpage'}) {
               $symb = $ENV{'form.symb'};                $symb = $ENV{'form.symb'};
           }            }
     &Apache::lonenc::check_decrypt(\$symb);
           my @currnewattach = ();            my @currnewattach = ();
           my @deloldattach = ();            my @deloldattach = ();
           my @keepold = ();            my @keepold = ();

Removed from v.1.116  
changed lines
  Added in v.1.132


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