Diff for /loncom/interface/lonfeedback.pm between versions 1.182 and 1.206

version 1.182, 2006/03/04 00:59:53 version 1.206, 2006/06/29 22:20:22
Line 43  use Apache::lonrss(); Line 43  use Apache::lonrss();
 use HTML::LCParser();  use HTML::LCParser();
 use Apache::lonspeller();  use Apache::lonspeller();
 use Cwd;  use Cwd;
   use lib '/home/httpd/lib/perl/';
   use LONCAPA;
   
 sub discussion_open {  sub discussion_open {
     my ($status,$symb)=@_;      my ($status,$symb)=@_;
Line 394  imscp_v1p1.xsd http://www.imsglobal.org/ Line 396  imscp_v1p1.xsd http://www.imsglobal.org/
     $discussion.='<form name="readchoices" method="post" action="/adm/feedback?chgreads='.$ressymb.'" ><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>';
     my $escsymb=&Apache::lonnet::escape($ressymb);      my $escsymb=&escape($ressymb);
     if ($visible>2) {      if ($visible>2) {
  $discussion.='<td align="left">'.   $discussion.='<td align="left">'.
     '<a href="/adm/feedback?cmd=threadedon&amp;symb='.$escsymb;      '<a href="/adm/feedback?cmd=threadedon&amp;symb='.$escsymb;
Line 694  END Line 696  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 = &Apache::lonnet::unescape($env{'form.subject'});              $subject = &unescape($env{'form.subject'});
             $comment = &Apache::lonnet::unescape($env{'form.comment'});              $comment = &unescape($env{'form.comment'});
             my @keepold = ();              my @keepold = ();
             &process_attachments(\@currnewattach,\@currdelold,\@keepold);              &process_attachments(\@currnewattach,\@currdelold,\@keepold);
             if (@currnewattach > 0) {              if (@currnewattach > 0) {
Line 726  ENDDISCUSS Line 728  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 744  ENDDISCUSS Line 746  ENDDISCUSS
     }      }
  }   }
     } else {      } else {
    $discussion.='<table bgcolor="#BBBBBB"><tr><td>';
         if (&discussion_open($status) &&          if (&discussion_open($status) &&
             &Apache::lonnet::allowed('pch',              &Apache::lonnet::allowed('pch',
            $env{'request.course.id'}.             $env{'request.course.id'}.
         ($env{'request.course.sec'}?'/'.$env{'request.course.sec'}:''))) {          ($env{'request.course.sec'}?'/'.$env{'request.course.sec'}:''))) {
     if ($outputtarget ne 'tex') {      if ($outputtarget ne 'tex') {
  $discussion.='<table bgcolor="#BBBBBB"><tr><td><a href="/adm/feedback?replydisc='.   $discussion.='<a href="/adm/feedback?replydisc='.
     &Apache::lonnet::escape($ressymb).':::" '.$target.'>'.      &escape($ressymb).':::" '.$target.'>'.
     '<img src="'.&Apache::loncommon::lonhttpdurl('/adm/lonMisc/chat.gif').'" border="0" />'.      '<img src="'.&Apache::loncommon::lonhttpdurl('/adm/lonMisc/chat.gif').'" border="0" />'.
     &mt('Post Discussion').'</a></td></tr></table>';      &mt('Post Discussion').'</a><br />';
     }              }
  }   }
    $discussion.='<a href="/adm/feedback?sendmessageonly=1&symb='.
       &escape($ressymb).
       '"><img src="'.&Apache::loncommon::lonhttpdurl('/adm/lonMisc/feedback.gif').'" border="0" />'.
       &mt('Send Message').'</a></td></tr></table>';
     }      }
     return $discussion;      return $discussion;
 }  }
Line 764  sub build_posting_display { Line 771  sub build_posting_display {
     my @original=();      my @original=();
     my @index=();      my @index=();
     my $symb=&Apache::lonenc::check_decrypt($ressymb);      my $symb=&Apache::lonenc::check_decrypt($ressymb);
     my $escsymb=&Apache::lonnet::escape($ressymb);      my $escsymb=&escape($ressymb);
     my %contrib=&Apache::lonnet::restore($symb,$env{'request.course.id'},      my %contrib=&Apache::lonnet::restore($symb,$env{'request.course.id'},
   $env{'course.'.$env{'request.course.id'}.'.domain'},    $env{'course.'.$env{'request.course.id'}.'.domain'},
   $env{'course.'.$env{'request.course.id'}.'.num'});    $env{'course.'.$env{'request.course.id'}.'.num'});
Line 1253  END Line 1260  END
         }          }
     }      }
     if ($type eq 'allversions') {      if ($type eq 'allversions') {
         $discussion.=('</ul></body></html>');          $discussion.='</ul>';
         return $discussion;          return $discussion;
     } else {      } else {
         return;          return;
Line 1303  sub mail_screen { Line 1310  sub mail_screen {
   if (exists($env{'form.origpage'})) {    if (exists($env{'form.origpage'})) {
       &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['subject','comment','currnewattach','addnewattach','deloldattach','delnewattach','timestamp','idx','anondiscuss','discuss','blog']);        &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['subject','comment','currnewattach','addnewattach','deloldattach','delnewattach','timestamp','idx','anondiscuss','discuss','blog']);
   }    }
   my $bodytag=&Apache::loncommon::bodytag('Resource Feedback and Discussion',  
                                           '','onLoad="window.focus();setposttype();"');  
   my $title=&Apache::lonnet::gettitle($feedurl);    my $title=&Apache::lonnet::gettitle($feedurl);
   if (!$title) { $title = $feedurl; }    if (!$title) { $title = $feedurl; }
   my $quote='';    my $quote='';
Line 1324  sub mail_screen { Line 1330  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 1337  END Line 1346  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 1410  END Line 1421  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 1437  END Line 1445  END
   }    }
   
   if ($env{'form.origpage'}) {    if ($env{'form.origpage'}) {
       $subject = &Apache::lonnet::unescape($env{'form.subject'});        $subject = &unescape($env{'form.subject'});
       $comment = &Apache::lonnet::unescape($env{'form.comment'});        $comment = &unescape($env{'form.comment'});
       &process_attachments(\@currnewattach,\@currdelold,\@keepold);        &process_attachments(\@currnewattach,\@currdelold,\@keepold);
   }    }
   my $latexHelp=&Apache::loncommon::helpLatexCheatsheet();    my $latexHelp=&Apache::loncommon::helpLatexCheatsheet();
   my $htmlheader=&Apache::lonhtmlcommon::htmlareaheaders();  
   my $send=&mt('Send');    my $send=&mt('Send');
   my $html=&Apache::lonxml::xmlbegin();    my $js= <<END;
   $r->print(<<END);  
 $html  
 <head>  
 <title>The LearningOnline Network with CAPA</title>  
 <meta http-equiv="pragma" content="no-cache"></meta>  
 $htmlheader  
 <script type="text/javascript">  <script type="text/javascript">
 //<!--  //<!--
     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 1497  $htmlheader Line 1481  $htmlheader
     }      }
     document.mailform.submit();      document.mailform.submit();
         } else {          } else {
             alert('Please check a feedback type.');              alert('Please select a feedback type.');
  }   }
     }      }
     $anonchk      $anonchk
     $anonscript      $anonscript
 //-->  //-->
 </script>  </script>
 </head>  END
 $bodytag  
     my %onload = ('onload' => 'window.focus();setposttype();');
     my $start_page=
         &Apache::loncommon::start_page('Resource Feedback and Discussion',$js,
        {'add_entries' => \%onload});
   
     $r->print(<<END);
   $start_page
 <h2><tt>$title</tt></h2>  <h2><tt>$title</tt></h2>
 <form action="/adm/feedback" method="post" name="mailform"  <form action="/adm/feedback" method="post" name="mailform"
 enctype="multipart/form-data">  enctype="multipart/form-data">
Line 1579  END Line 1570  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 1602  END Line 1593  END
     }      }
     $r->print(&generate_preview_button().      $r->print(&generate_preview_button().
               &Apache::lonhtmlcommon::htmlareaselectactive('comment').                &Apache::lonhtmlcommon::htmlareaselectactive('comment').
               '</body></html>');        &Apache::loncommon::end_page());
   
 }  }
   
 sub print_display_options {  sub print_display_options {
Line 1613  sub print_display_options { Line 1605  sub print_display_options {
     my $function = &Apache::loncommon::get_users_function();      my $function = &Apache::loncommon::get_users_function();
     my $tabcolor = &Apache::loncommon::designparm($function.'.tabbg',      my $tabcolor = &Apache::loncommon::designparm($function.'.tabbg',
                                                     $env{'user.domain'});                                                      $env{'user.domain'});
     my $bodytag=&Apache::loncommon::bodytag('Discussion options',  
                                           '','');  
   
     my %lt = &Apache::lonlocal::texthash(      my %lt = &Apache::lonlocal::texthash(
         'dido' => 'Discussion display options',  
         'pref' => 'Display Preference',          'pref' => 'Display Preference',
         'curr' => 'Current setting ',          'curr' => 'Current setting ',
         'actn' => 'Action',          'actn' => 'Action',
Line 1675  sub print_display_options { Line 1664  sub print_display_options {
         $currtogg = $lt{'toggon'};          $currtogg = $lt{'toggon'};
         $disctogg = 'toggon';          $disctogg = 'toggon';
     }      }
     my $html=&Apache::lonxml::xmlbegin();  
     $r->print(<<END);      my $js = <<END;
 $html  <script type="text/javascript">
 <head>  
 <title>$lt{'dido'}</title>  
 <meta http-equiv="pragma" content="no-cache" />  
 <script>  
 function discdispChk(caller) {  function discdispChk(caller) {
     var disctogg = '$toggchg'      var disctogg = '$toggchg'
     if (caller == 0) {      if (caller == 0) {
Line 1748  function setDisp() { Line 1733  function setDisp() {
     }      }
 }  }
 </script>  </script>
 </head>  END
 $bodytag  
 <form name="modifydisp" method="post" action="/adm/feedback">  
       my $start_page =
    &Apache::loncommon::start_page('Discussion display options',$js);
       my $end_page =
    &Apache::loncommon::end_page();
       $r->print(<<END);
   $start_page
   <form name="modifydisp" method="POST" action="/adm/feedback">
 $lt{'sdpf'}<br/> $lt{'prca'}  <ol><li>$lt{'whpo'}</li><li>$lt{'unwh'}</li><li>$lt{'wipa'}</li></ol>  $lt{'sdpf'}<br/> $lt{'prca'}  <ol><li>$lt{'whpo'}</li><li>$lt{'unwh'}</li><li>$lt{'wipa'}</li></ol>
 <br />  <br />
 <table border="0" cellpadding="0" cellspacing="0">  END
  <tr>      $r->print(&Apache::loncommon::start_data_table());
   <td width="100%" bgcolor="#000000">      $r->print(<<END);
    <table width="100%" border="0" cellpadding="1" cellspacing="0">         <tr>
     <tr>          <th>$lt{'pref'}</td>
      <td width="100%" bgcolor="#000000">          <th>$lt{'curr'}</td>
       <table border="0" cellpadding="3" cellspacing="1" bgcolor="#FFFFFF">          <th>$lt{'actn'}?</td>
        <tr bgcolor="$tabcolor">  
         <td><b>$lt{'pref'}</b></td>  
         <td><b>$lt{'curr'}</b></td>  
         <td><b>$lt{'actn'}?</b></td>  
        </tr>         </tr>
        <tr bgcolor="#dddddd">  END
       $r->print(&Apache::loncommon::start_data_table_row());
       $r->print(<<END);
        <td>$lt{'disa'}</td>         <td>$lt{'disa'}</td>
        <td>$lt{$discdisp}</td>         <td>$lt{$discdisp}</td>
        <td><label><input type="checkbox" name="discdisp" onClick="discdispChk('0')" />&nbsp;$lt{'chgt'} "$dispchangeA"</label>         <td><label><input type="checkbox" name="discdisp" onClick="discdispChk('0')" />&nbsp;$lt{'chgt'} "$dispchangeA"</label>
            <br />             <br />
            <label><input type="checkbox" name="discdisp" onClick="discdispChk('1')" />&nbsp;$lt{'chgt'} "$dispchangeB"</label>             <label><input type="checkbox" name="discdisp" onClick="discdispChk('1')" />&nbsp;$lt{'chgt'} "$dispchangeB"</label>
        </td>         </td>
       </tr><tr bgcolor="#eeeeee">  END
       $r->print(&Apache::loncommon::end_data_table_row());
       $r->print(&Apache::loncommon::start_data_table_row());
       $r->print(<<END);
        <td>$lt{'npmr'}</td>         <td>$lt{'npmr'}</td>
        <td>$lt{$discmark}</td>         <td>$lt{$discmark}</td>
        <td><label><input type="checkbox" name="discmark" />$lt{'chgt'} "$markchange"</label></td>         <td><label><input type="checkbox" name="discmark" />$lt{'chgt'} "$markchange"</label></td>
       </tr><tr bgcolor="#dddddd">  END
       $r->print(&Apache::loncommon::end_data_table_row());
       $r->print(&Apache::loncommon::start_data_table_row());
       $r->print(<<END);
        <td>$lt{'dotm'}</td>         <td>$lt{'dotm'}</td>
        <td>$lt{$disctogg}</td>         <td>$lt{$disctogg}</td>
        <td><label><input type="checkbox" name="disctogg" onClick="discdispChk('2')" />$lt{'chgt'} "$toggchange"</label></td>         <td><label><input type="checkbox" name="disctogg" onClick="discdispChk('2')" />$lt{'chgt'} "$toggchange"</label></td>
       </tr>  END
      </table>      $r->print(&Apache::loncommon::end_data_table_row());
     </td>      $r->print(&Apache::loncommon::end_data_table());
    </tr>      $r->print(<<END);
   </table>  
  </td>  
 </tr>  
 </table>  
 <br />  <br />
 <br />  <br />
 <input type="hidden" name="symb" value="$symb" />  <input type="hidden" name="symb" value="$symb" />
Line 1800  $lt{'sdpf'}<br/> $lt{'prca'}  <ol><li>$l Line 1792  $lt{'sdpf'}<br/> $lt{'prca'}  <ol><li>$l
 <br />  <br />
 <br />  <br />
 </form>  </form>
 </body>  $end_page
 </html>  
 END  END
     return;      return;
 }  }
Line 1813  sub print_sortfilter_options { Line 1804  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 1838  sub print_sortfilter_options { Line 1827  sub print_sortfilter_options {
     my $function = &Apache::loncommon::get_users_function();      my $function = &Apache::loncommon::get_users_function();
     my $tabcolor = &Apache::loncommon::designparm($function.'.tabbg',      my $tabcolor = &Apache::loncommon::designparm($function.'.tabbg',
                                                     $env{'user.domain'});                                                      $env{'user.domain'});
     my $bodytag=&Apache::loncommon::bodytag('Discussion options',  
                                           '','');  
     my %lt = &Apache::lonlocal::texthash(      my %lt = &Apache::lonlocal::texthash(
         'diso' => 'Discussion sorting and filtering options',  
         'diop' => 'Display Options',          'diop' => 'Display Options',
         'curr' => 'Current setting ',          'curr' => 'Current setting ',
         'actn' => 'Action',          'actn' => 'Action',
Line 1858  sub print_sortfilter_options { Line 1844  sub print_sortfilter_options {
     my %role_types = ();      my %role_types = ();
     my %status_types = ();      my %status_types = ();
     &sort_filter_names(\%sort_types,\%role_types,\%status_types);      &sort_filter_names(\%sort_types,\%role_types,\%status_types);
     my $html=&Apache::lonxml::xmlbegin();  
     $r->print(<<END);      my $js = <<END;
 $html  
 <head>  
 <title>$lt{'diso'}</title>  
 <meta http-equiv="pragma" content="no-cache" />  
 <script type="text/javascript">  <script type="text/javascript">
 function verifyFilter() {  function verifyFilter() {
     var rolenum = 0      var rolenum = 0
Line 1888  function verifyFilter() { Line 1870  function verifyFilter() {
     document.modifyshown.submit();      document.modifyshown.submit();
 }  }
 </script>  </script>
 </head>  END
 $bodytag  
 <form name="modifyshown" method="post" action="/adm/feedback">      my $start_page=
    &Apache::loncommon::start_page('Discussion options',$js);
       my $end_page=
    &Apache::loncommon::end_page();
   
       $r->print(<<END);
   $start_page
   <form name="modifyshown" method="POST" action="/adm/feedback">
 <b>$lt{'diso'}</b><br/> $lt{'prca'}  <b>$lt{'diso'}</b><br/> $lt{'prca'}
 <br /><br />  <br /><br />
 <table border="0">  <table border="0">
Line 1955  $bodytag Line 1944  $bodytag
 <br />  <br />
 <br />  <br />
 </form>  </form>
 </body>  $end_page
 </html>  
 END  END
 }  }
   
Line 1978  sub print_showposters { Line 1966  sub print_showposters {
                           $env{'course.'.$env{'request.course.id'}.'.num'});                            $env{'course.'.$env{'request.course.id'}.'.num'});
     my %namesort = ();      my %namesort = ();
     my %postcounts = ();      my %postcounts = ();
     my %lt=&Apache::lonlocal::texthash(  
                      'diso' => 'Discussion filtering options',  
     );  
     my $bodytag=&Apache::loncommon::bodytag('Discussion options',  
                                           '','');  
     if ($contrib{'version'}) {      if ($contrib{'version'}) {
         for (my $idx=1;$idx<=$contrib{'version'};$idx++) {          for (my $idx=1;$idx<=$contrib{'version'};$idx++) {
             my $hidden=($contrib{'hidden'}=~/\.$idx\./);              my $hidden=($contrib{'hidden'}=~/\.$idx\./);
Line 2014  sub print_showposters { Line 1998  sub print_showposters {
             }              }
         }          }
     }      }
     my $html=&Apache::lonxml::xmlbegin();  
       my $start_page = &Apache::loncommon::start_page('Discussion options');
       my $table_start =&Apache::loncommon::start_data_table();
     $r->print(<<END);      $r->print(<<END);
 $html  $start_page
 <head>  
 <title>$lt{'diso'}</title>  
 <meta http-equiv="pragma" content="no-cache" />  
 </head>  
 $bodytag  
  <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 2043  END Line 2022  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();
     $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" />
 <input type="button" name="store" value="Display posts" onClick="javascript:document.pickpostersform.submit()" />  <input type="button" name="store" value="Display posts" onClick="javascript:document.pickpostersform.submit()" />
 </form>  </form>
 </body>  $end_page
 </html>  
 END  END
 }  }
   
Line 2067  sub get_post_versions { Line 2048  sub get_post_versions {
     my ($versions,$incoming,$htmldecode,$numver) = @_;      my ($versions,$incoming,$htmldecode,$numver) = @_;
     if ($incoming =~ /^<version num="0">/) {      if ($incoming =~ /^<version num="0">/) {
         my $p = HTML::LCParser->new(\$incoming);          my $p = HTML::LCParser->new(\$incoming);
         my $done = 0;                                                                                 my $done = 0; 
   
         while ( (my $token = $p->get_tag("version")) && (!$done)) {          while ( (my $token = $p->get_tag("version")) && (!$done)) {
             my $num = $token->[1]{num};              my $num = $token->[1]{num};
             my $text = $p->get_text("/version");              my $text = $p->get_text("/version");
Line 2128  sub fail_redirect { Line 2110  sub fail_redirect {
   my ($r,$feedurl) = @_;    my ($r,$feedurl) = @_;
   if ($feedurl=~/^\/adm\//) { $feedurl.='?register=1' };    if ($feedurl=~/^\/adm\//) { $feedurl.='?register=1' };
   my $logo=&Apache::loncommon::lonhttpdurl('/adm/lonIcons/lonlogos.gif');    my $logo=&Apache::loncommon::lonhttpdurl('/adm/lonIcons/lonlogos.gif');
   my $html=&Apache::lonxml::xmlbegin();    $r->print(&Apache::loncommon::start_page('Feedback not sent',undef,
   $r->print (<<ENDFAILREDIR);     {'redirect'  => [2,$feedurl],
 $html      'only_body' => 1,}));
 <head>    $r->print(<<ENDFAILREDIR);
 <title>Feedback not sent</title>  
 <meta http-equiv="pragma" content="no-cache" />  
 <meta HTTP-EQUIV="Refresh" CONTENT="2; url=$feedurl" />  
 </head>  
 <body bgcolor="#FFFFFF">  
 <img align="right" src="$logo" />  <img align="right" src="$logo" />
 <b>Sorry, no recipients  ...</b>  <b>Sorry, no recipients  ...</b>
 <br /><a href="$feedurl">Continue</a>  
 </body>  
 </html>  
 ENDFAILREDIR  ENDFAILREDIR
     $r->print(&Apache::loncommon::end_page());
 }  }
   
 sub redirect_back {  sub redirect_back {
Line 2216  sub redirect_back { Line 2191  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 $html=&Apache::lonxml::xmlbegin();    my %onload;
   $r->print (<<ENDREDIR);    if ($env{'environment.remote'} ne 'off') {
 $html        $onload{'onload'} =
 <head>    "if (window.name!='loncapaclient') { this.document.reldt.submit(); self.window.close(); }";
 <title>Feedback sent</title>    }
 <meta http-equiv="pragma" content="no-cache" />    my $start_page=
 <meta HTTP-EQUIV="Refresh" CONTENT="2; url=$feedurl" />        &Apache::loncommon::start_page('New posts marked as read',undef,
 </head>       {'redirect'    => [2,$feedurl],
 <body bgcolor="#FFFFFF" onLoad='if (window.name!="loncapaclient") { this.document.reldt.submit(); self.close(); }'>        'only_body'   => 1,
         'add_entries' => \%onload});
     my $end_page = &Apache::loncommon::end_page();
   
     $r->print(<<ENDREDIR);
   $start_page
 <img align="right" src="$logo" />  <img align="right" src="$logo" />
 $typestyle  $typestyle
 <b>Sent $sendsomething message(s), and $sendposts post(s).</b>  <b>Sent $sendsomething message(s), and $sendposts post(s).</b>
Line 2238  $roletag Line 2218  $roletag
 $sectag  $sectag
 $userpicktag  $userpicktag
 </form>  </form>
 <br /><a href="$feedurl">Continue</a>  $end_page
 </body>  
 </html>  
 ENDREDIR  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');   
   my $html=&Apache::lonxml::xmlbegin();    my %onload;
   $r->print (<<ENDNOREDIR);    if ($env{'environment.remote'} ne 'off') {
 $html        $onload{'onload'} = 
 <head>    "if (window.name!='loncapaclient') { self.window.close(); }";
 <title>Feedback not sent</title>    }
 <meta http-equiv="pragma" content="no-cache" />  
 ENDNOREDIR    my %body_options = ('only_body'   => 1,
         'bgcolor'     => '#FFFFFF',
   if ($feedurl!~/^\/adm\/feedback/) {         'add_entries' => \%onload,);
       $r->print('<meta HTTP-EQUIV="Refresh" CONTENT="2; url='.  
  &Apache::lonenc::check_encrypt($feedurl).'">');    if ($feedurl !~ m{^/adm/feedback}) { 
   }        $body_options{'rediect'} = [2,$feedurl];
     }
     my $start_page=
         &Apache::loncommon::start_page('Feedback not sent',undef,
        \%body_options);
         
     my $end_page = &Apache::loncommon::end_page();
   
   $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');
   $r->print (<<ENDNOREDIRTWO);    $r->print (<<ENDNOREDIRTWO);
 </head>  $start_page
 <body bgcolor="#FFFFFF" onLoad='if (window.name!="loncapaclient") { self.close(); }'>  
 <img align="right" src="$logo" />  <img align="right" src="$logo" />
 <b>$nofeed</b>  <b>$nofeed</b>
 <br /><a href="$feedurl">$continue</a>  <br />
 </body>  $end_page
 </html>  
 ENDNOREDIRTWO  ENDNOREDIRTWO
 }  }
   
Line 2280  sub screen_header { Line 2263  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>';
  }   }
     }      }
     if ($env{'request.course.id'}) {      if (($env{'request.course.id'}) && (!$env{'form.sendmessageonly'})) {
  if (&discussion_open(undef,$symb) &&   if (&discussion_open(undef,$symb) &&
     &Apache::lonnet::allowed('pch',      &Apache::lonnet::allowed('pch',
      $env{'request.course.id'}.       $env{'request.course.id'}.
      ($env{'request.course.sec'}?'/'.$env{'request.course.sec'}:''))) {       ($env{'request.course.sec'}?'/'.$env{'request.course.sec'}:''))) {
     $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>';
         }          }
         #$discussoptions.='<br /><label><input type="checkbox" name="blog" /> '.          $discussoptions.='<br /><label><input type="checkbox" name="blog" /> '.
  #    &mt('Add to my public course blog').'</label>';      &mt('Add to my public course blog').'</label>';
     }      }
     if ($msgoptions) { $msgoptions='<h2><img src="'.&Apache::loncommon::lonhttpdurl('/adm/lonMisc/feedback.gif').'" />'.&mt('Sending Messages').'</h2>'.$msgoptions; }      if ($msgoptions) { $msgoptions='<h2><img src="'.&Apache::loncommon::lonhttpdurl('/adm/lonMisc/feedback.gif').'" />'.&mt('Sending Messages').'</h2>'.$msgoptions; }
     if ($discussoptions) {       if ($discussoptions) { 
Line 2337  sub resource_output { Line 2319  sub resource_output {
 }  }
   
 sub clear_out_html {  sub clear_out_html {
   my ($message,$override)=@_;    my ($message,$override,$ignore_htmlarea)=@_;
   unless (&Apache::lonhtmlcommon::htmlareablocked()) { return $message; }    if (!$ignore_htmlarea
         && !&Apache::lonhtmlcommon::htmlareablocked()) { return $message; }
 # Always allow the <m>-tag  # Always allow the <m>-tag
   my %html=(M=>1);    my %html=(M=>1);
 # Check if more is allowed  # Check if more is allowed
Line 2354  sub clear_out_html { Line 2337  sub clear_out_html {
      H1=>1, H2=>1, H3=>1, H4=>1, H5=>1);       H1=>1, H2=>1, H3=>1, H4=>1, H5=>1);
   }    }
 # Do the substitution of everything that is not explicitly allowed  # Do the substitution of everything that is not explicitly allowed
   $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;
   $message =~ s/(\<?\s*(\w+)[^\<\>]*)\>/    $message =~ s/(\<?\s*(\w*)[^\<\>]*)\>/
   {($html{uc($2)}&&(length($1)<1000))?"$1\>":"$1\&gt;"}/ge;    {($html{uc($2)}&&(length($1)<1000))?"$1\>":"$1\&gt;"}/ge;
   return $message;    return $message;
 }  }
Line 2432  sub decide_receiver { Line 2415  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 2446  sub decide_receiver { Line 2429  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 2455  sub decide_receiver { Line 2438  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 2541  sub adddiscuss { Line 2524  sub adddiscuss {
     }      }
     if (($symb) && ($email)) {      if (($symb) && ($email)) {
         if ($env{'form.editdisc'}) {          if ($env{'form.editdisc'}) {
             my %newcontrib = ();  
             $contrib{'ip'}=$ENV{'REMOTE_ADDR'};              $contrib{'ip'}=$ENV{'REMOTE_ADDR'};
             $contrib{'host'}=$Apache::lonnet::perlvar{'lonHostID'};              $contrib{'host'}=$Apache::lonnet::perlvar{'lonHostID'};
             $contrib{'timestamp'} = time;              $contrib{'timestamp'} = time;
Line 2584  sub adddiscuss { Line 2566  sub adddiscuss {
                 }                  }
             }              }
             $contrib{'history'} .= $oldcontrib{$oldidx.':timestamp'};              $contrib{'history'} .= $oldcontrib{$oldidx.':timestamp'};
             foreach (keys %contrib) {  
                 my $key = $oldidx.':'.&Apache::lonnet::escape($oldsymb).':'.$_;                                                                                 
                 $newcontrib{$key} = $contrib{$_};  
             }  
             my $put_reply = &Apache::lonnet::putstore($env{'request.course.id'},              my $put_reply = &Apache::lonnet::putstore($env{'request.course.id'},
                   $oldsymb,$oldidx,\%contrib,                    $oldsymb,$oldidx,\%contrib,
                   $env{'course.'.$env{'request.course.id'}.'.domain'},                    $env{'course.'.$env{'request.course.id'}.'.domain'},
Line 2623  sub adddiscuss { Line 2601  sub adddiscuss {
 # ----------------------------------------------------------- Preview function  # ----------------------------------------------------------- Preview function
   
 sub show_preview {  sub show_preview {
     my $r=shift;      my ($r) = @_;
     &Apache::loncommon::content_type($r,'text/html');      &Apache::loncommon::content_type($r,'text/html');
     $r->send_http_header;      $r->send_http_header;
     my $message=&clear_out_html($env{'form.comment'});      my $message=&clear_out_html($env{'form.comment'});
     &newline_to_br(\$message);      &newline_to_br(\$message);
     $message=&Apache::lonspeller::markeduptext($message);      $message=&Apache::lonspeller::markeduptext($message);
     $message=&Apache::lontexconvert::msgtexconverted($message);      $message=&Apache::lontexconvert::msgtexconverted($message);
     my $subject=&clear_out_html($env{'form.subject'});      my $subject=&clear_out_html($env{'form.subject'},undef,1);
     $subject=~s/\n/\<br \/\>/g;      $subject=~s/\n/\<br \/\>/g;
     $subject=&Apache::lontexconvert::msgtexconverted($subject);      $subject=&Apache::lontexconvert::msgtexconverted($subject);
     my $html=&Apache::lonxml::xmlbegin();      my $start_page=
     $r->print($html.'<head>'.   &Apache::loncommon::start_page('Preview',undef,
       '</head><body><table border="2"><tr><td>'.         {'only_body'   => 1,});
   
       my $end_page = &Apache::loncommon::end_page();
   
       $r->print($start_page.'<table border="2"><tr><td>'.
       '<b>Subject:</b> '.$subject.'<br /><br />'.        '<b>Subject:</b> '.$subject.'<br /><br />'.
       $message.'</td></tr></table></body></html>');        $message.'</td></tr></table>'.$end_page);
 }  }
   
   
Line 2668  sub generate_preview_button { Line 2650  sub generate_preview_button {
     unless ($fieldname) { $fieldname='comment'; }      unless ($fieldname) { $fieldname='comment'; }
     my $pre=&mt("Show Preview and Check Spelling");      my $pre=&mt("Show Preview and Check Spelling");
     return(<<ENDPREVIEW);      return(<<ENDPREVIEW);
   <br />
 <form name="preview" action="/adm/feedback?preview=1" method="post" target="preview">  <form name="preview" action="/adm/feedback?preview=1" method="post" target="preview">
 <input type="hidden" name="subject">  <input type="hidden" name="subject">
 <input type="hidden" name="comment" />  <input type="hidden" name="comment" />
Line 2679  ENDPREVIEW Line 2662  ENDPREVIEW
   
 sub modify_attachments {  sub modify_attachments {
     my ($r,$currnewattach,$currdelold,$symb,$idx,$attachmenturls)=@_;      my ($r,$currnewattach,$currdelold,$symb,$idx,$attachmenturls)=@_;
     my $orig_subject = &Apache::lonnet::unescape($env{'form.subject'});      my $orig_subject = &unescape($env{'form.subject'});
     my $subject=&clear_out_html($orig_subject);      my $subject=&clear_out_html($orig_subject,undef,1);
     $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'};
     my $numoldver=$env{'form.numoldver'};      my $numoldver=$env{'form.numoldver'};
     my $bodytag=&Apache::loncommon::bodytag('Discussion Post Attachments',  
                                           '','');  
     my $msg = '';      my $msg = '';
     my %attachments = ();      my %attachments = ();
     my %currattach = ();      my %currattach = ();
Line 2694  sub modify_attachments { Line 2676  sub modify_attachments {
         &extract_attachments($attachmenturls,$idx,$numoldver,\$msg,\%attachments,\%currattach,$currdelold);          &extract_attachments($attachmenturls,$idx,$numoldver,\$msg,\%attachments,\%currattach,$currdelold);
     }      }
     &Apache::lonenc::check_encrypt(\$symb);      &Apache::lonenc::check_encrypt(\$symb);
     my $html=&Apache::lonxml::xmlbegin();      my $js = <<END;
     $r->print(<<END);  <script type="text/javascript">
 $html  
 <head>  
 <title>Managing Attachments</title>  
 <script>  
  function setAction () {   function setAction () {
    document.modattachments.action = document.modattachments.origpage.value;     document.modattachments.action = document.modattachments.origpage.value;
    document.modattachments.submit();     document.modattachments.submit();
  }   }
 </script>   </script> 
 </head>  END
 $bodytag  
       my $start_page = 
    &Apache::loncommon::start_page('Discussion Post Attachments',$js);
       my $end_page = 
    &Apache::loncommon::end_page();
          
       $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 2746  END Line 2731  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 2759  END Line 2743  END
     $r->print(<<END);      $r->print(<<END);
  <input type="button" name="rtntoedit" value="Store Changes" onClick="setAction()"/>   <input type="button" name="rtntoedit" value="Store Changes" onClick="setAction()"/>
 </form>  </form>
 </body>  $end_page
 </html>  
 END  END
     return;      return;
 }  }
Line 2798  sub generate_attachments_button { Line 2781  sub generate_attachments_button {
     my $origpage = $ENV{'REQUEST_URI'};      my $origpage = $ENV{'REQUEST_URI'};
     my $att=$attachnum.' '.&mt("attachments");      my $att=$attachnum.' '.&mt("attachments");
     my $response = (<<END);      my $response = (<<END);
   <br />
 <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="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);  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);
Line 2813  this.form.submit();" /> Line 2797  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 2993  sub handler { Line 2976  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','cmd','symb','onlyunread','allposts','onlyunmark','previous','markread','markonread','markondisp','toggoff','toggon','modifydisp','changes','navtime','navmaps','navurl','sortposts','applysort','rolefilter','statusfilter','sectionpick','posterlist','userpick','attach','origpage','currnewattach','deloldattach','keepold','allversions','export']);           ['hide','unhide','deldisc','postdata','preview','replydisc','editdisc','cmd','symb','onlyunread','allposts','onlyunmark','previous','markread','markonread','markondisp','toggoff','toggon','modifydisp','changes','navtime','navmaps','navurl','sortposts','applysort','rolefilter','statusfilter','sectionpick','posterlist','userpick','attach','origpage','currnewattach','deloldattach','keepold','allversions','export','sendmessageonly']);
   if ($env{'form.editdisc'}) {    if ($env{'form.editdisc'}) {
       if (!(&editing_allowed())) {        if (!(&editing_allowed())) {
           my $symb=(split(/\:\:\:/,$env{'form.editdisc'}))[0];            my $symb=(split(/\:\:\:/,$env{'form.editdisc'}))[0];
Line 3031  sub handler { Line 3014  sub handler {
   }    }
   if ($env{'form.allversions'}) {    if ($env{'form.allversions'}) {
       &Apache::loncommon::content_type($r,'text/html');        &Apache::loncommon::content_type($r,'text/html');
         &Apache::loncommon::no_cache($r);
       $r->send_http_header;        $r->send_http_header;
       my $html=&Apache::lonxml::xmlbegin();  
       my $bodytag=&Apache::loncommon::bodytag('Discussion Post Versions');        $r->print(&Apache::loncommon::start_page('Discussion Post Versions'));
       $r->print(<<END);  
 $html  
 <head>  
 <title>Post Versions</title>  
 <meta http-equiv="pragma" content="no-cache" />  
 </head>  
 $bodytag  
 END  
       my $crs='/'.$env{'request.course.id'};        my $crs='/'.$env{'request.course.id'};
       if ($env{'request.course.sec'}) {        if ($env{'request.course.sec'}) {
           $crs.='_'.$env{'request.course.sec'};            $crs.='_'.$env{'request.course.sec'};
Line 3062  END Line 3039  END
                            $env{'course.'.$env{'request.course.id'}.'.num'});                             $env{'course.'.$env{'request.course.id'}.'.num'});
           $r->print(&get_post_contents(\%contrib,$idx,$seeid,'allversions',\%messages,\%subjects,\%allattachments,\%attachmsgs,\%imsfiles,\$screenname,\$plainname));            $r->print(&get_post_contents(\%contrib,$idx,$seeid,'allversions',\%messages,\%subjects,\%allattachments,\%attachmsgs,\%imsfiles,\$screenname,\$plainname));
       }        }
         $r->print(&Apache::loncommon::end_page());
       return OK;        return OK;
   }    }
   if ($env{'form.posterlist'}) {    if ($env{'form.posterlist'}) {
Line 3130  END Line 3108  END
       &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 $html=&Apache::lonxml::xmlbegin();        my %onload;
         if ($env{'environment.remote'} ne 'off') {
     $onload{'onload'} =
         "if (window.name!='loncapaclient') { this.document.reldt.submit(); self.window.close(); }";
         }
   
         my $start_page=
     &Apache::loncommon::start_page('New posts marked as read',undef,
    {'redirect'    => [2,$feedurl],
     'only_body'   => 1,
     'add_entries' => \%onload});
         my $end_page = &Apache::loncommon::end_page();
       $r->print (<<ENDREDIR);        $r->print (<<ENDREDIR);
 $html  $start_page
 <head>  
 <title>New posts marked as read</title>  
 <meta http-equiv="pragma" content="no-cache" />  
 <meta HTTP-EQUIV="Refresh" CONTENT="2; url=$feedurl" />  
 </head>  
 <body bgcolor="#FFFFFF" onLoad='if (window.name!="loncapaclient") { this.document.reldt.submit(); self.close(); }'>  
 <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="loncapaclient">
 </form>  </form>
 <br /><a href="$feedurl">Continue</a>  <br />
 </body>  $end_page
 </html>  
 ENDREDIR  ENDREDIR
       return OK;        return OK;
   } elsif ($env{'form.modifydisp'}) {    } elsif ($env{'form.modifydisp'}) {
Line 3270  ENDREDIR Line 3252  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 3304  ENDREDIR Line 3286  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); 
       my $bodytag=&Apache::loncommon::bodytag('Resource Feedback and Discussion');        my $start_page = 
       $r->print($bodytag.$discussion);                                         &Apache::loncommon::start_page('Resource Feedback and Discussion');
         my $end_page = 
     &Apache::loncommon::end_page();
         $r->print($start_page.$discussion.$end_page);
       return OK;        return OK;
   } else {    } else {
 # ------------------------------------------------------------- Normal feedback  # ------------------------------------------------------------- Normal feedback
Line 3426  ENDREDIR Line 3411  ENDREDIR
       my ($typestyle,%to) = &decide_receiver($feedurl);        my ($typestyle,%to) = &decide_receiver($feedurl);
   
 # Actually send mail  # Actually send mail
       my ($status,$numsent)=&send_msg(&clear_out_html($env{'form.subject'}),$feedurl,$email,$citations,        my ($status,$numsent)=&send_msg(&clear_out_html($env{'form.subject'},
         undef,1),
         $feedurl,$email,$citations,
       $attachmenturl,%to);        $attachmenturl,%to);
   
 # 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$/ 
   my $subject = &clear_out_html($env{'form.subject'});    || $env{'form.anondiscuss'}) {
   my $anonmode=(defined($env{'form.anondiscuss'}));    my $subject = &clear_out_html($env{'form.subject'},undef,1);
     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++;
Line 3444  ENDREDIR Line 3432  ENDREDIR
   
       my $blog='';        my $blog='';
       if ($env{'form.blog'}) {        if ($env{'form.blog'}) {
   my $subject = &clear_out_html($env{'form.subject'});    my $subject = &clear_out_html($env{'form.subject'},undef,1);
   $status.=&Apache::lonrss::addentry($env{'user.name'},    $status.=&Apache::lonrss::addentry($env{'user.name'},
     $env{'user.domain'},      $env{'user.domain'},
     'CourseBlog_'.$env{'request.course.id'},      'CourseBlog_'.$env{'request.course.id'},
Line 3498  sub editing_allowed { Line 3486  sub editing_allowed {
     my $cid = $env{'request.course.id'};      my $cid = $env{'request.course.id'};
     my $role = (split(/\./,$env{'request.role'}))[0];      my $role = (split(/\./,$env{'request.role'}))[0];
     my $section = $env{'request.course.sec'};      my $section = $env{'request.course.sec'};
     my $allow_editing_config = $env{'course.'.$env{'request.course.id'}.      my $allow_editing_config = 
                                '.allow_discussion_post_editing'};   $env{'course.'.$cid.'.allow_discussion_post_editing'};
     if ($allow_editing_config =~ m/^\s*yes\s*$/i) {      if ($allow_editing_config =~ m/^\s*yes\s*$/i) {
         $can_edit = 1;          $can_edit = 1;
     } else {      } else {
         my @editor_roles = split(/,/,$allow_editing_config);   foreach my $editor (split(/,/,$allow_editing_config)) {
         if (@editor_roles > 0) {      my ($editor_role,$editor_sec) = split(/:/,$editor);
             foreach my $editor (@editor_roles) {      if ($editor_role eq $role
                 my ($editor_role,$editor_sec) = split(/:/,$editor);   && defined($editor_sec)
                 if ($editor_role eq $role) {   && defined($section)
                     if (defined($editor_sec)) {   && $editor_sec eq $section) {
                         if (defined($section)) {   $can_edit = 1;
                             if ($editor_sec eq $section) {   last;
                                 $can_edit = 1;      }
                                 last;      if ($editor_role eq $role
                             }   && !defined($editor_sec)) {
                         }   $can_edit = 1;
                     } else {      }
                         $can_edit = 1;   }
                         last;  
                     }  
                 }  
             }  
         }  
     }      }
     return $can_edit;      return $can_edit;
 }  }

Removed from v.1.182  
changed lines
  Added in v.1.206


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