Diff for /loncom/interface/lonfeedback.pm between versions 1.195 and 1.203

version 1.195, 2006/05/08 22:07:31 version 1.203, 2006/05/10 22:47:22
Line 726  ENDDISCUSS Line 726  ENDDISCUSS
             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 .= '<br /><b>New attachments</b><br />';
                     if (@currnewattach > 1) {                      if (@currnewattach > 1) {
                         $newattachmsg .= '<ol>';                          $newattachmsg .= '<ol>';
                         foreach my $item (@currnewattach) {                          foreach my $item (@currnewattach) {
Line 1328  sub mail_screen { Line 1328  sub mail_screen {
   my $attachnum = 0;    my $attachnum = 0;
   my $anonchk = (<<END);    my $anonchk = (<<END);
   function anonchk() {    function anonchk() {
      if (document.mailform.anondiscuss.checked == true) {        for (var i=0; i < document.mailform.discuss.length; i++) {
           document.attachment.anondiscuss.value = '1'    if (document.mailform.discuss[i].checked) {
      }        document.attachment.discuss.value = 
      if (document.mailform.discuss.checked == true) {    document.mailform.discuss[i].value;
           document.attachment.discuss.value = '1'    }
      }        }
         if (document.mailform.blog.checked) {
     document.attachment.blog.value = 1;
         }
      return       return
    }     }
 END  END
Line 1341  END Line 1344  END
   if (exists($env{'form.origpage'})) {    if (exists($env{'form.origpage'})) {
       $anonscript = (<<END);        $anonscript = (<<END);
   function setposttype() {    function setposttype() {
       var anondisc = $env{'form.anondiscuss'};        var disc = "$env{'form.discuss'}";
       var disc = $env{'form.discuss'};        for (var i=0; i < document.mailform.discuss.length; i++) {
       if (anondisc == 1) {    if (disc == document.mailform.discuss[i].value) {
           document.mailform.anondiscuss.checked = true        document.mailform.discuss[i].checked = 1;
     }
       }        }
       if (disc == 1) {        var blog = "$env{'form.blog'}";
           document.mailform.discuss.checked = true        if (blog == 1) {
             document.mailform.blog.checked=1;
       }        }
       return        return
   }    }
Line 1414  END Line 1419  END
                   $parentmsg = $contrib{$idx.':replyto'};                    $parentmsg = $contrib{$idx.':replyto'};
               }                }
               unless (exists($env{'form.origpage'})) {                unless (exists($env{'form.origpage'})) {
                   my $anonflag = 0;                    my $anonflag = 'nonanon';
                   if ($contrib{$idx.':anonymous'}) {                    if ($contrib{$idx.':anonymous'}) {
                       $anonflag = 1;                        $anonflag = 'anon';
                   }                    }
                   $anonscript = (<<END);                    $anonscript = (<<END);
   function setposttype () {    function setposttype () {
       var currtype = $anonflag        var currtype = "$anonflag";
       if (currtype == 1) {        for (var i=0; i<document.mailform.discuss.length; i++) {
           document.mailform.elements.discuss.checked = false    if (document.mailform.elements.discuss[i].value == currtype ) {
           document.mailform.elements.anondiscuss.checked = true        document.mailform.elements.discuss[i].checked=1;
       }    } 
       if (currtype == 0) {  
           document.mailform.elements.anondiscuss.checked = false  
           document.mailform.elements.discuss.checked = true  
       }        }
       return        return
   }    }
Line 1452  END Line 1454  END
 //<!--  //<!--
     function gosubmit() {      function gosubmit() {
         var rec=0;          var rec=0;
         if (typeof(document.mailform.elements.author)!="undefined") {  
           if (document.mailform.elements.author.checked) {  
              rec=1;  
           }   
         }  
         if (typeof(document.mailform.elements.question)!="undefined") {  
           if (document.mailform.elements.question.checked) {  
              rec=1;  
           }   
         }  
         if (typeof(document.mailform.elements.course)!="undefined") {  
           if (document.mailform.elements.course.checked) {  
              rec=1;  
           }   
         }  
         if (typeof(document.mailform.elements.policy)!="undefined") {  
           if (document.mailform.elements.policy.checked) {  
              rec=1;  
           }   
         }  
         if (typeof(document.mailform.elements.discuss)!="undefined") {          if (typeof(document.mailform.elements.discuss)!="undefined") {
           if (document.mailform.elements.discuss.checked) {      if (typeof(document.mailform.elements.discuss.length) == "undefined") {
              rec=1;   if (document.mailform.elements.discuss.checked ) {
           }       rec=1;
         }   }
         if (typeof(document.mailform.elements.anondiscuss)!="undefined") {      } else {
           if (document.mailform.elements.anondiscuss.checked) {   for (var i=0; i<document.mailform.elements.discuss.length; i++) {
              rec=1;      if (document.mailform.elements.discuss[i].checked ) {
           }    rec=1;
         }      } 
    }
       }
    }
         if (typeof(document.mailform.elements.blog)!="undefined") {          if (typeof(document.mailform.elements.blog)!="undefined") {
           if (document.mailform.elements.blog.checked) {            if (document.mailform.elements.blog.checked) {
              rec=1;               rec=1;
Line 1494  END Line 1479  END
     }      }
     document.mailform.submit();      document.mailform.submit();
         } else {          } else {
             alert('Please check a feedback type.');              alert('Please select a feedback type.');
  }   }
     }      }
     $anonchk      $anonchk
Line 1583  END Line 1568  END
         $r->print(&generate_attachments_button($postidx,$attachnum,$ressymb,$now,\@currnewattach,\@currdelold,$numoldver));          $r->print(&generate_attachments_button($postidx,$attachnum,$ressymb,$now,\@currnewattach,\@currdelold,$numoldver));
         if ($attachnum > 0) {          if ($attachnum > 0) {
             if (@currnewattach > 0) {              if (@currnewattach > 0) {
                 $newattachmsg .= '<b>New attachments</b><br />';                  $newattachmsg .= '<br /><b>New attachments</b><br />';
                 if (@currnewattach > 1) {                  if (@currnewattach > 1) {
                     $newattachmsg .= '<ol>';                      $newattachmsg .= '<ol>';
                     foreach my $item (@currnewattach) {                      foreach my $item (@currnewattach) {
Line 1817  sub print_sortfilter_options { Line 1802  sub print_sortfilter_options {
     $r->send_http_header;      $r->send_http_header;
   
     &Apache::lonenc::check_encrypt(\$symb);      &Apache::lonenc::check_encrypt(\$symb);
     my @sections = ();      my @sections;
     my $section_sel = '';      my $section_sel = '';
     my $numsections = 0;  
     my $numvisible = 5;      my $numvisible = 5;
     my %sectioncount = ();      my %sectioncount = &Apache::loncommon::get_sections();
   
     $numsections = &Apache::loncommon::get_sections($env{'course.'.$env{'request.course.id'}.'.domain'},$env{'course.'.$env{'request.course.id'}.'.num'},\%sectioncount);  
   
     if ($env{'request.course.sec'} !~ /^\s*$/) {  #Restrict section choice to current section       if ($env{'request.course.sec'} !~ /^\s*$/) {  #Restrict section choice to current section 
         @sections = ('all',$env{'request.course.sec'});          @sections = ('all',$env{'request.course.sec'});
         $numvisible = 2;          $numvisible = 2;
     } 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          if (scalar(@sections) < 4) {
         if ($numsections < 4) {              $numvisible = scalar(@sections) + 1;
             $numvisible = $numsections + 1;  
         }          }
           unshift(@sections,'all'); # Put 'all' at the front of the list
   
     }      }
     foreach (@sections) {      foreach (@sections) {
         $section_sel .= "  <option value=\"$_\" />$_\n";          $section_sel .= "  <option value=\"$_\" />$_\n";
Line 2015  sub print_showposters { Line 1998  sub print_showposters {
     }      }
   
     my $start_page = &Apache::loncommon::start_page('Discussion options');      my $start_page = &Apache::loncommon::start_page('Discussion options');
       my $table_start =&Apache::loncommon::start_data_table();
     $r->print(<<END);      $r->print(<<END);
 $start_page  $start_page
  <form name="pickpostersform" method="post">   <form name="pickpostersform" method="post">
   <table border="0">   <br />
    <tr>      $table_start
     <td bgcolor="#777777">        <tr>
      <table border="0" cellpadding="3">         <th>No.</th>
       <tr bgcolor="#e6ffff">         <th>Select</th>
        <td><b>No.</b></td>         <th>Fullname<font color="#999999">(Username/domain)</font></th>
        <td><b>Select</b></td>         <th>Posts</th>
        <td><b>Fullname</b><font color="#999999">(Username/domain)</font></td>  
        <td><b>Posts</td>  
       </tr>        </tr>
 END  END
     my $count = 0;      my $count = 0;
Line 2039  END Line 2020  END
                     next;                      next;
                 } else {                  } else {
                     $count ++;                      $count ++;
                     $r->print('<tr bgcolor="#ffffe6"><td align="right">'.$count.'</td><td align="center"><label><input name="stuinfo" type="checkbox" value="'.$_.'" /></td><td>'.$last.', '.$first.' ('.$uname.','.$udom.')</label></td><td>'.$postcounts{$_}.'</td></tr>');                      $r->print(&Apache::loncommon::start_data_table_row().
         '<td align="right">'.$count.'</td>
                                  <td align="center"><label><input name="stuinfo" type="checkbox" value="'.$_.'" /></td>
                                  <td>'.$last.', '.$first.' ('.$uname.','.$udom.')</label></td>
                                  <td>'.$postcounts{$_}.'</td>'.
         &Apache::loncommon::end_data_table_row());
                 }                  }
             }              }
         }          }
     }      }
       $r->print(&Apache::loncommon::end_data_table());
     my $end_page   = &Apache::loncommon::end_page();      my $end_page   = &Apache::loncommon::end_page();
     $r->print(<<END);      $r->print(<<END);
      </table>  
     </td>  
    </tr>  
   </table>  
 <br />  <br />
 <input type="hidden" name="sortposts" value="$sortposts" />  <input type="hidden" name="sortposts" value="$sortposts" />
 <input type="hidden" name="userpick" value="$symb" />  <input type="hidden" name="userpick" value="$symb" />
Line 2207  sub redirect_back { Line 2189  sub redirect_back {
   }    }
   $feedurl=&Apache::lonenc::check_encrypt($feedurl);    $feedurl=&Apache::lonenc::check_encrypt($feedurl);
   my $logo=&Apache::loncommon::lonhttpdurl('/adm/lonIcons/lonlogos.gif');    my $logo=&Apache::loncommon::lonhttpdurl('/adm/lonIcons/lonlogos.gif');
   my %onload = ('onload' => "if (window.name!='loncapaclient') { this.document.reldt.submit(); self.window.close(); }");    my %onload;
     if ($env{'environment.remote'} ne 'off') {
         $onload{'onload'} =
     "if (window.name!='loncapaclient') { this.document.reldt.submit(); self.window.close(); }";
     }
   my $start_page=    my $start_page=
       &Apache::loncommon::start_page('New posts marked as read',undef,        &Apache::loncommon::start_page('New posts marked as read',undef,
      {'redirect'    => [2,$feedurl],       {'redirect'    => [2,$feedurl],
Line 2238  sub no_redirect_back { Line 2224  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 %onload;
     if ($env{'environment.remote'} ne 'off') {
         $onload{'onload'} = 
     "if (window.name!='loncapaclient') { self.window.close(); }";
     }
   
   my %body_options = ('only_body'   => 1,    my %body_options = ('only_body'   => 1,
       'bgcolor'     => '#FFFFFF',        'bgcolor'     => '#FFFFFF',
       'add_entries' => {'onload' => "if (window.name!='loncapaclient') { self.window.close(); }"});        'add_entries' => \%onload,);
   
   if ($feedurl !~ m{^/adm/feedback}) {     if ($feedurl !~ m{^/adm/feedback}) { 
       $body_options{'rediect'} = [2,$feedurl];        $body_options{'rediect'} = [2,$feedurl];
Line 2269  sub screen_header { Line 2261  sub screen_header {
     unless (($env{'form.replydisc'}) || ($env{'form.editdisc'})) {      unless (($env{'form.replydisc'}) || ($env{'form.editdisc'})) {
  if (($feedurl=~/^\/res\//) && ($feedurl!~/^\/res\/adm/) && ($env{'user.adv'})) {   if (($feedurl=~/^\/res\//) && ($feedurl!~/^\/res\/adm/) && ($env{'user.adv'})) {
     $msgoptions=       $msgoptions= 
  '<p><label><input type="checkbox" name="author" /> '.   '<p><label><input type="radio" name="discuss" value="author" /> '.
  &mt('Feedback to resource author').'</label></p>';   &mt('Feedback to resource author').'</label></p>';
  }   }
  if (&feedback_available(1)) {   if (&feedback_available(1)) {
     $msgoptions.=      $msgoptions.=
  '<p><label><input type="checkbox" name="question" /> '.   '<p><label><input type="radio" name="discuss" value="question" /> '.
  &mt('Question about resource content').'</label></p>';   &mt('Question about resource content').'</label></p>';
  }   }
  if (&feedback_available(0,1)) {   if (&feedback_available(0,1)) {
     $msgoptions.=      $msgoptions.=
  '<p><label><input type="checkbox" name="course" /> '.   '<p><label><input type="radio" name="discuss" value="course" /> '.
  &mt('Question/Comment/Feedback about course content').   &mt('Question/Comment/Feedback about course content').
  '</label></p>';   '</label></p>';
  }   }
  if (&feedback_available(0,0,1)) {   if (&feedback_available(0,0,1)) {
     $msgoptions.=      $msgoptions.=
  '<p><label><input type="checkbox" name="policy" /> '.   '<p><label><input type="radio" name="discuss" value="policy" /> '.
  &mt('Question/Comment/Feedback about course policy').   &mt('Question/Comment/Feedback about course policy').
  '</label></p>';   '</label></p>';
  }   }
Line 2295  sub screen_header { Line 2287  sub screen_header {
     &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'}:''))) {
     $discussoptions='<label><input type="checkbox" name="discuss" onClick="this.form.anondiscuss.checked=false;" '.      $discussoptions='<label><input type="radio" name="discuss" value="nonanon" checked="checked" /> '.
  ($env{'form.replydisc'}?' checked="1"':'').' /> '.  
  &mt('Contribution to course discussion of resource');   &mt('Contribution to course discussion of resource');
     $discussoptions.='</label><br /><label><input type="checkbox" name="anondiscuss" onClick="this.form.discuss.checked=false;" /> '.      $discussoptions.='</label><br /><label><input type="radio" name="discuss" value="anon" /> '.
  &mt('Anonymous contribution to course discussion of resource').   &mt('Anonymous contribution to course discussion of resource').
  ' <i>('.&mt('name only visible to course faculty').')</i></label> '.   ' <i>('.&mt('name only visible to course faculty').')</i></label> '.
  '<a href="/adm/preferences?action=changescreenname">'.&mt('Change Screenname').'</a>';   '<a href="/adm/preferences?action=changescreenname">'.&mt('Change Screenname').'</a>';
Line 2422  sub decide_receiver { Line 2413  sub decide_receiver {
   my ($feedurl,$author,$question,$course,$policy,$defaultflag) = @_;    my ($feedurl,$author,$question,$course,$policy,$defaultflag) = @_;
   my $typestyle='';    my $typestyle='';
   my %to=();    my %to=();
   if ($env{'form.author'}||$author) {    if ($env{'form.discuss'} eq 'author' ||$author) {
     $typestyle.='Submitting as Author Feedback<br />';      $typestyle.='Submitting as Author Feedback<br />';
     $feedurl=~/^\/res\/(\w+)\/(\w+)\//;      $feedurl=~/^\/res\/(\w+)\/(\w+)\//;
     $to{$2.':'.$1}=1;      $to{$2.':'.$1}=1;
   }    }
   if ($env{'form.question'}||$question) {    if ($env{'form.discuss'} eq 'question' ||$question) {
     $typestyle.='Submitting as Question<br />';      $typestyle.=&mt('Submitting as Question').'<br />';
     foreach (split(/\,/,      foreach (split(/\,/,
    $env{'course.'.$env{'request.course.id'}.'.question.email'})     $env{'course.'.$env{'request.course.id'}.'.question.email'})
      ) {       ) {
Line 2436  sub decide_receiver { Line 2427  sub decide_receiver {
         if ($rec) { $to{$rec}=1; }          if ($rec) { $to{$rec}=1; }
     }       } 
   }    }
   if ($env{'form.course'}||$course) {    if ($env{'form.discuss'} eq 'course' ||$course) {
     $typestyle.='Submitting as Comment<br />';      $typestyle.=&mt('Submitting as Comment').'<br />';
     foreach (split(/\,/,      foreach (split(/\,/,
    $env{'course.'.$env{'request.course.id'}.'.comment.email'})     $env{'course.'.$env{'request.course.id'}.'.comment.email'})
      ) {       ) {
Line 2445  sub decide_receiver { Line 2436  sub decide_receiver {
         if ($rec) { $to{$rec}=1; }          if ($rec) { $to{$rec}=1; }
     }       } 
   }    }
   if ($env{'form.policy'}||$policy) {    if ($env{'form.discuss'} eq 'policy' ||$policy) {
     $typestyle.='Submitting as Policy Feedback<br />';      $typestyle.=&mt('Submitting as Policy Feedback').'<br />';
     foreach (split(/\,/,      foreach (split(/\,/,
    $env{'course.'.$env{'request.course.id'}.'.policy.email'})     $env{'course.'.$env{'request.course.id'}.'.policy.email'})
      ) {       ) {
Line 2697  END Line 2688  END
  &Apache::loncommon::end_page();   &Apache::loncommon::end_page();
                 
     $r->print(<<END);      $r->print(<<END);
   $start_page
 <form name="modattachments" method="post" enctype="multipart/form-data" action="/adm/feedback?attach=$symb">  <form name="modattachments" method="post" enctype="multipart/form-data" action="/adm/feedback?attach=$symb">
  <table border="2">   <table border="2">
   <tr>    <tr>
Line 2736  END Line 2728  END
 <input type="hidden" name="idx" value="$env{'form.idx'}" />  <input type="hidden" name="idx" value="$env{'form.idx'}" />
 <input type="hidden" name="numoldver" value="$env{'form.numoldver'}" />  <input type="hidden" name="numoldver" value="$env{'form.numoldver'}" />
 <input type="hidden" name="origpage" value="$env{'form.origpage'}" />  <input type="hidden" name="origpage" value="$env{'form.origpage'}" />
 <input type="hidden" name="anondiscuss" value="$env{'form.anondiscuss'}" />  
 <input type="hidden" name="blog" value="$env{'form.blog'}" />  <input type="hidden" name="blog" value="$env{'form.blog'}" />
 <input type="hidden" name="discuss" value="$env{'form.discuss'}" />  <input type="hidden" name="discuss" value="$env{'form.discuss'}" />
 END  END
Line 2802  this.form.submit();" /> Line 2793  this.form.submit();" />
 <input type="hidden" name="subject" />  <input type="hidden" name="subject" />
 <input type="hidden" name="comment" />  <input type="hidden" name="comment" />
 <input type="hidden" name="blog" value = "0" />  <input type="hidden" name="blog" value = "0" />
 <input type="hidden" name="anondiscuss" value = "0" />  
 <input type="hidden" name="discuss" value = "0" />  <input type="hidden" name="discuss" value = "0" />
 <input type="hidden" name="numoldver" value="$numoldver" />  <input type="hidden" name="numoldver" value="$numoldver" />
 ENDATTACH  ENDATTACH
Line 3114  sub handler { Line 3104  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 $logo=&Apache::loncommon::lonhttpdurl('/adm/lonIcons/lonlogos.gif');        my $logo=&Apache::loncommon::lonhttpdurl('/adm/lonIcons/lonlogos.gif');
       my %onload = ('onload' => "if (window.name!='loncapaclient') { this.document.reldt.submit(); self.window.close(); }");        my %onload;
         if ($env{'environment.remote'} ne 'off') {
     $onload{'onload'} =
         "if (window.name!='loncapaclient') { this.document.reldt.submit(); self.window.close(); }";
         }
   
       my $start_page=        my $start_page=
   &Apache::loncommon::start_page('New posts marked as read',undef,    &Apache::loncommon::start_page('New posts marked as read',undef,
  {'redirect'    => [2,$feedurl],   {'redirect'    => [2,$feedurl],
Line 3253  ENDREDIR Line 3248  ENDREDIR
 # -------------------------------------------------------- Work on attachments  # -------------------------------------------------------- Work on attachments
       &Apache::loncommon::content_type($r,'text/html');        &Apache::loncommon::content_type($r,'text/html');
       $r->send_http_header;        $r->send_http_header;
       &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['subject','comment','addnewattach','delnewattach','timestamp','numoldver','idx','anondiscuss','discuss','blog']);        &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['subject','comment','addnewattach','delnewattach','timestamp','numoldver','idx','discuss','blog']);
       my (@currnewattach,@currdelold,@keepold);        my (@currnewattach,@currdelold,@keepold);
       &process_attachments(\@currnewattach,\@currdelold,\@keepold);        &process_attachments(\@currnewattach,\@currdelold,\@keepold);
       if (exists($env{'form.addnewattach.filename'})) {        if (exists($env{'form.addnewattach.filename'})) {
Line 3420  ENDREDIR Line 3415  ENDREDIR
 # Discussion? Store that.  # Discussion? Store that.
   
       my $numpost=0;        my $numpost=0;
       if ($env{'form.discuss'} || $env{'form.anondiscuss'}) {        if ($env{'form.discuss'} =~/^(?:non|)anon$/ 
     || $env{'form.anondiscuss'}) {
   my $subject = &clear_out_html($env{'form.subject'},undef,1);    my $subject = &clear_out_html($env{'form.subject'},undef,1);
   my $anonmode=(defined($env{'form.anondiscuss'}));    my $anonmode=($env{'form.discuss'} eq 'anon' || $env{'form.anondiscuss'} );
   $typestyle.=&adddiscuss($symb,$message,$anonmode,$attachmenturl,    $typestyle.=&adddiscuss($symb,$message,$anonmode,$attachmenturl,
   $subject);    $subject);
   $numpost++;    $numpost++;

Removed from v.1.195  
changed lines
  Added in v.1.203


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