Diff for /loncom/interface/lonfeedback.pm between versions 1.375 and 1.387

version 1.375, 2017/11/08 00:36:56 version 1.387, 2021/12/31 20:34:24
Line 44  use HTML::LCParser(); Line 44  use HTML::LCParser();
 #use HTML::Tidy::libXML;  #use HTML::Tidy::libXML;
 use Apache::lonspeller();  use Apache::lonspeller();
 use Apache::longroup;  use Apache::longroup;
 use Cwd;  use Archive::Zip qw( :ERROR_CODES );
 use LONCAPA qw(:DEFAULT :match);  use LONCAPA qw(:DEFAULT :match);
   
 sub discussion_open {  sub discussion_open {
Line 118  sub list_discussion { Line 118  sub list_discussion {
             $outputtarget = 'export';              $outputtarget = 'export';
         }          }
     }      }
       my ($nofooter,$nodisclink,$nofdbklink);
     if (not &discussion_visible($status)) {      if (not &discussion_visible($status)) {
         if ($mode ne 'board') {          if ($mode ne 'board') {
             &Apache::lonenc::check_encrypt(\$ressymb);               ($nofooter,$nodisclink,$nofdbklink) = &check_menucoll();
             return '<br /><div class="LC_feedback_link">'.&send_message_link($ressymb)."</div>";              if ($nofooter || $nofdbklink) {
                   return '<br />';
               } else {
                   &Apache::lonenc::check_encrypt(\$ressymb);
                   return '<br /><div class="LC_feedback_link">'.&send_message_link($ressymb)."</div>";
               }
         }          }
     }      }
     if ($group ne '' && $mode eq 'board') {      if ($group ne '' && $mode eq 'board') {
Line 130  sub list_discussion { Line 136  sub list_discussion {
         }          }
     }      }
   
     my ($blocked,$blocktext) =       unless ($outputtarget eq 'export') {
         &Apache::loncommon::blocking_status('boards');          ($nofooter,$nodisclink,$nofdbklink) = &check_menucoll();
     if ($blocked) {      }
         $blocktext = '<br /><div class="LC_feedback_link"><span class="LC_feedback_link">'.$blocktext."</span>";  
         &Apache::lonenc::check_encrypt(\$ressymb);      unless ($nofooter) {
         if ($mode ne 'board') {          my ($blocked,$blocktext) = 
             $blocktext.=&send_message_link($ressymb).'</div>';              &Apache::loncommon::blocking_status('boards');
         }else{          if ($blocked) {
             $blocktext.="</div>";              my $footer = '<br /><div class="LC_feedback_link">';
               unless ($nodisclink) {
                   $footer .= '<span class="LC_feedback_link">'.$blocktext.'</span>';
               }
               &Apache::lonenc::check_encrypt(\$ressymb);
               if ($mode ne 'board') {
                   unless ($nofdbklink) {
                       $footer.=&send_message_link($ressymb);
                   }
               }
               $footer.='</div>';
               return $footer;
         }          }
         return $blocktext;   
     }      }
   
     my @bgcols = ("LC_disc_old_item","LC_disc_new_item");      my @bgcols = ("LC_disc_old_item","LC_disc_new_item");
Line 674  END Line 690  END
                                              $newpostsflag,$group,                                               $newpostsflag,$group,
                                              $prevread,$markondisp,$seehidden);                                               $prevread,$markondisp,$seehidden);
             $discussion .= "</table></form>\n";              $discussion .= "</table></form>\n";
         }           }
         if ($outputtarget eq 'export') {          if ($outputtarget eq 'export') {
             if ($manifestok) {              if ($manifestok) {
                 while ($currdepth > 0) {                  while ($currdepth > 0) {
Line 698  END Line 714  END
   
                     if (($env{'user.name'} =~ /^$match_username$/)                      if (($env{'user.name'} =~ /^$match_username$/)
                         && ($env{'user.domain'} =~ /^$match_domain$/)) {                          && ($env{'user.domain'} =~ /^$match_domain$/)) {
                         my $now = time();                           my $now = time();
                         my $imszipfile = '/prtspool/'.                          my $imszipfile = '/prtspool/'.
                                       join('_',$env{'user.name'},$env{'user.domain'},$now).                                        join('_',$env{'user.name'},$env{'user.domain'},$now).
                                       '_'.rand(1000000000).'.zip';                                        '_'.rand(1000000000).'.zip';
                         my $cwd = &getcwd();                           my $zip = Archive::Zip->new();
                           $zip->addTree($tempexport);
                         my $imszip = '/home/httpd/'.$imszipfile;                          my $imszip = '/home/httpd/'.$imszipfile;
                         chdir $tempexport;                          if ($zip->writeToFileNamed($imszip) == AZ_OK) {
                         open(OUTPUT, "zip -r $imszip *  2> /dev/null |");                              $discussion .= &mt('Download the zip file from [_1]Discussion Posting Archive[_2]',
                         close(OUTPUT);  
                         chdir $cwd;  
                         $discussion .= &mt('Download the zip file from [_1]Discussion Posting Archive[_2]',  
                                            '<a href="'.$imszipfile.'">','</a>').'<br />';                                             '<a href="'.$imszipfile.'">','</a>').'<br />';
                           } else {
                               $discussion .=  &mt('Failed to create zip file').'<br />';
                           }
                         if ($copyresult) {                          if ($copyresult) {
                             $discussion .= '<span class="LC_error">'.                              $discussion .= '<span class="LC_error">'.
                                            &mt('The following errors occurred during export:').                                             &mt('The following errors occurred during export:').
Line 773  END Line 790  END
                           &mt('This discussion is closed.').'</span>';                            &mt('This discussion is closed.').'</span>';
         }          }
     } elsif ($outputtarget ne 'tex') {      } elsif ($outputtarget ne 'tex') {
         $discussion.='<div class="LC_feedback_link">';          unless ($nofooter) {
         if (&discussion_open($status) &&              $discussion.='<div class="LC_feedback_link">';
             &Apache::lonnet::allowed('pch',              unless ($nodisclink) {
            $env{'request.course.id'}.                  if (&discussion_open($status) &&
         ($env{'request.course.sec'}?'/'.$env{'request.course.sec'}:''))) {                      &Apache::lonnet::allowed('pch',
             $discussion.= &send_feedback_link($ressymb);                     $env{'request.course.id'}.
             if ($env{'request.role.adv'}) {                  ($env{'request.course.sec'}?'/'.$env{'request.course.sec'}:''))) {
                 my $close = &Apache::lonnet::EXT('resource.0.discussend',$ressymb);                      $discussion.= &send_feedback_link($ressymb);
                 my $canvote = &Apache::lonnet::EXT('resource.0.discussvote',$ressymb);                      if ($env{'request.role.adv'}) {
                 if (defined($close) && $close ne '' && $close < time) {                          my $close = &Apache::lonnet::EXT('resource.0.discussend',$ressymb);
                     if ($canvote eq 'notended') {                          my $canvote = &Apache::lonnet::EXT('resource.0.discussvote',$ressymb);
                         $discussion .= '&nbsp;'.&mt('(Posting and voting closed for [_1] roles)',                          if (defined($close) && $close ne '' && $close < time) {
                                                     &Apache::lonnet::plaintext('st',$crstype));                              if ($canvote eq 'notended') {
                     } else {                                  $discussion .= '&nbsp;'.&mt('(Posting and voting closed for [_1] roles)',
                         $discussion .= '&nbsp;'.&mt('(Closed for [_1] roles)',                                                              &Apache::lonnet::plaintext('st',$crstype));
                                                     &Apache::lonnet::plaintext('st',$crstype));                              } else {
                                   $discussion .= '&nbsp;'.&mt('(Closed for [_1] roles)',
                                                               &Apache::lonnet::plaintext('st',$crstype));
                               }
                           }
                     }                      }
           } else {
                       $discussion.= '<span class="LC_feedback_link">'.&mt('This discussion is closed.').'</span>';
                 }                  }
             }              }
  } else {              unless ($nofdbklink) {
             $discussion.= '<span class="LC_feedback_link">'.&mt('This discussion is closed.').'</span>';          $discussion.= &send_message_link($ressymb);
               }
               $discussion.='</div>';
         }          }
  $discussion.= &send_message_link($ressymb).'</div>';  
     }      }
     return $discussion;      return $discussion;
 }  }
   
   sub check_menucoll {
       my ($nofooter,$nodisclink,$nofdbklink);
       my ($menucoll,$deeplinkmenu,$menuref) = &Apache::loncommon::menucoll_in_effect();
       if ($menucoll) {
           if (ref($menuref) eq 'HASH') {
               if ($menuref->{'foot'} eq 'n') {
                   $nofooter = 1;
               } else {
                   unless ($menuref->{'disc'}) {
                       $nodisclink = 1;
                   }
                   unless ($menuref->{'fdbk'}) {
                       $nofdbklink = 1;
                   }
               }
           }
       }
       return ($nofooter,$nodisclink,$nofdbklink);
   }
   
 sub can_see_hidden {  sub can_see_hidden {
     my ($mode,$ressymb,$feedurl,$group,$cdom,$cnum,$crs) = @_;      my ($mode,$ressymb,$feedurl,$group,$cdom,$cnum,$crs) = @_;
     my $seehidden;      my $seehidden;
Line 1780  sub mail_screen { Line 1824  sub mail_screen {
   
   my %lt = &Apache::lonlocal::texthash(    my %lt = &Apache::lonlocal::texthash(
             'myqu' => 'Question/comment/feedback:',              'myqu' => 'Question/comment/feedback:',
             'title' => 'Title',  
             'reta' => 'Retained attachments',              'reta' => 'Retained attachments',
             'atta' => 'Attachment',              'atta' => 'Attachment',
            );             );
   if($env{'form.editdisc'} || $env{'form.replydisc'}){    if ($env{'form.editdisc'} || $env{'form.replydisc'}){
     %lt = &Apache::lonlocal::texthash(        $lt{'myqu'} = &mt('Post Discussion');
             'myqu' => 'Post Discussion',  
     );  
   }    }
   my $restitle = &get_resource_title($caller_symb,$feedurl);    my $restitle = &get_resource_title($caller_symb,$feedurl);
   my $quote='';    my $quote='';
Line 2062  END Line 2103  END
     } else {      } else {
         $r->print(<<END);          $r->print(<<END);
 <p>  <p>
 $lt{'atta'} $attachmaxtext: <input type="file" name="attachment" class="flUpload" />  $lt{'atta'} $attachmaxtext: <input type="file" name="attachment" class="LC_flUpload" />
 <input type="hidden" id="free_space" value="131072" />  <input type="hidden" id="LC_free_space" value="131072" />
 </p>  </p>
 END  END
     }      }
Line 2839  sub redirect_back { Line 2880  sub redirect_back {
   my $start_page=    my $start_page=
       &Apache::loncommon::start_page('Feedback sent',undef,\%parms);        &Apache::loncommon::start_page('Feedback sent',undef,\%parms);
   my $end_page = &Apache::loncommon::end_page();    my $end_page = &Apache::loncommon::end_page();
     my $windowname = 'loncapaclient';
     if ($env{'request.lti.login'}) {
        $windowname .= 'lti';
     }
   $r->print(<<ENDREDIR);    $r->print(<<ENDREDIR);
 $start_page  $start_page
 <img align="right" src="$logo" />  <img align="right" src="$logo" />
Line 2847  $typestyle Line 2892  $typestyle
 $blog  $blog
 $toolarge  $toolarge
 <font color="red">$status</font>  <font color="red">$status</font>
 <form name="reldt" action="$feedurl" target="loncapaclient">  <form name="reldt" action="$feedurl" target="$windowname">
 $prevtag  $prevtag
 $sorttag  $sorttag
 $statustag  $statustag
Line 3181  sub adddiscuss { Line 3226  sub adddiscuss {
     if (($symb) && ($email)) {      if (($symb) && ($email)) {
         my $now = time;          my $now = time;
         if ($env{'form.editdisc'}) {          if ($env{'form.editdisc'}) {
             $contrib{'ip'}=$ENV{'REMOTE_ADDR'};              $contrib{'ip'}=&Apache::lonnet::get_requestor_ip();
             $contrib{'host'}=$Apache::lonnet::perlvar{'lonHostID'};              $contrib{'host'}=$Apache::lonnet::perlvar{'lonHostID'};
             $contrib{'timestamp'} = $now;              $contrib{'timestamp'} = $now;
             $contrib{'history'} = '';              $contrib{'history'} = '';
Line 3558  END Line 3603  END
     $r->print('<b>'.$subject.'</b>');      $r->print('<b>'.$subject.'</b>');
     $r->print(&Apache::lonhtmlcommon::row_closure());      $r->print(&Apache::lonhtmlcommon::row_closure());
     $r->print(&Apache::lonhtmlcommon::row_title($lt{'adda'}));      $r->print(&Apache::lonhtmlcommon::row_title($lt{'adda'}));
     $r->print('<input type="file" name="addnewattach" class="flUpload" />'      $r->print('<input type="file" name="addnewattach" class="LC_flUpload" />'
         .'<input type="hidden" id="free_space" value="131072" />'          .'<input type="hidden" id="LC_free_space" value="131072" />'
         .'<input type="button" name="upload" value="Upload" '          .'<input type="button" name="upload" value="Upload" '
         .'onclick="this.form.submit()" />  '.$attachmaxtext);          .'onclick="this.form.submit()" />  '.$attachmaxtext);
     if(($idx)||(ref($currnewattach) eq 'ARRAY') && (@{$currnewattach} > 0)){      if(($idx)||(ref($currnewattach) eq 'ARRAY') && (@{$currnewattach} > 0)){
Line 4046  sub handler { Line 4091  sub handler {
   'only_body'   => 1,    'only_body'   => 1,
   'add_entries' => \%onload});    'add_entries' => \%onload});
       my $end_page = &Apache::loncommon::end_page();        my $end_page = &Apache::loncommon::end_page();
         my $windowname = 'loncapaclient';
         if ($env{'request.lti.login'}) {
             $windowname .= 'lti';
         }
       $r->print (<<ENDREDIR);        $r->print (<<ENDREDIR);
 $start_page  $start_page
 <img align="right" src="$logo" />  <img align="right" src="$logo" />
 $textline  $textline
 <form name="reldt" action="$feedurl" target="loncapaclient">  <form name="reldt" action="$feedurl" target="$windowname">
 </form>  </form>
 <br />  <br />
 $end_page  $end_page
Line 4551  ENDREDIR Line 4600  ENDREDIR
   ($env{'request.course.id'} && ($feedurl!~m:^/adm:))    ($env{'request.course.id'} && ($feedurl!~m:^/adm:))
   ||    ||
   ($env{'request.course.id'} && ($symb=~/^bulletin\_\_\_/))    ($env{'request.course.id'} && ($symb=~/^bulletin\_\_\_/))
             ||
             (($env{'request.course.id'}) && ($feedurl =~ /ext\.tool$/))
   ) {    ) {
   &Apache::loncommon::content_type($r,'text/html');    &Apache::loncommon::content_type($r,'text/html');
   $r->send_http_header;    $r->send_http_header;

Removed from v.1.375  
changed lines
  Added in v.1.387


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