Diff for /loncom/interface/lonfeedback.pm between versions 1.179 and 1.197

version 1.179, 2006/02/09 20:30:47 version 1.197, 2006/05/09 15:09:27
Line 744  ENDDISCUSS Line 744  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.'>'.      &Apache::lonnet::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='.
       &Apache::lonnet::escape($ressymb).
       '"><img src="'.&Apache::loncommon::lonhttpdurl('/adm/lonMisc/feedback.gif').'" border="0" />'.
       &mt('Send Message').'</td></tr></table>';
     }      }
     return $discussion;      return $discussion;
 }  }
Line 906  sub build_posting_display { Line 911  sub build_posting_display {
                             } else {                              } else {
                                 @{$$namesort{$lastname}{$firstname}} = ("$idx");                                  @{$$namesort{$lastname}{$firstname}} = ("$idx");
                             }                              }
                             if ($env{'course.'.$env{'request.course.id'}.'.allow_discussion_post_editing'} =~ m/yes/i) {                              if (&editing_allowed()) {
                                 if (($env{'user.domain'} eq $contrib{$idx.':senderdomain'}) && ($env{'user.name'} eq $contrib{$idx.':sendername'})) {                                  if (($env{'user.domain'} eq $contrib{$idx.':senderdomain'}) && ($env{'user.name'} eq $contrib{$idx.':sendername'})) {
                                     $sender.=' <a href="/adm/feedback?editdisc='.                                      $sender.=' <a href="/adm/feedback?editdisc='.
                                          $escsymb.':::'.$idx;                                           $escsymb.':::'.$idx;
Line 1253  END Line 1258  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 1308  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 1442  END Line 1446  END
       &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() {
Line 1504  $htmlheader Line 1501  $htmlheader
     $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 1602  END Line 1606  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 1618  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 1677  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 1746  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 1805  $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 1817  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 1840  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 1857  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 1883  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 1957  $bodytag
 <br />  <br />
 <br />  <br />
 </form>  </form>
 </body>  $end_page
 </html>  
 END  END
 }  }
   
Line 1978  sub print_showposters { Line 1979  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 2011  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 2035  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 2061  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 2123  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 2204  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 = ('onload' => "if (window.name!='loncapaclient') { this.document.reldt.submit(); self.window.close(); }");
   $r->print (<<ENDREDIR);    my $start_page=
 $html        &Apache::loncommon::start_page('New posts marked as read',undef,
 <head>       {'redirect'    => [2,$feedurl],
 <title>Feedback sent</title>        'only_body'   => 1,
 <meta http-equiv="pragma" content="no-cache" />        'add_entries' => \%onload});
 <meta HTTP-EQUIV="Refresh" CONTENT="2; url=$feedurl" />    my $end_page = &Apache::loncommon::end_page();
 </head>  
 <body bgcolor="#FFFFFF" onLoad='if (window.name!="loncapaclient") { this.document.reldt.submit(); self.close(); }'>    $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 2227  $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 %body_options = ('only_body'   => 1,
   $r->print (<<ENDNOREDIR);        'bgcolor'     => '#FFFFFF',
 $html        'add_entries' => {'onload' => "if (window.name!='loncapaclient') { self.window.close(); }"});
 <head>  
 <title>Feedback not sent</title>    if ($feedurl !~ m{^/adm/feedback}) { 
 <meta http-equiv="pragma" content="no-cache" />        $body_options{'rediect'} = [2,$feedurl];
 ENDNOREDIR    }
     my $start_page=
   if ($feedurl!~/^\/adm\/feedback/) {         &Apache::loncommon::start_page('Feedback not sent',undef,
       $r->print('<meta HTTP-EQUIV="Refresh" CONTENT="2; url='.       \%body_options);
  &Apache::lonenc::check_encrypt($feedurl).'">');        
   }    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 2301  sub screen_header { Line 2287  sub screen_header {
  '</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'}.
Line 2314  sub screen_header { Line 2300  sub screen_header {
  ' <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 2323  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 2341  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 2478  sub feedback_available { Line 2465  sub feedback_available {
 }  }
   
 sub send_msg {  sub send_msg {
   my ($feedurl,$email,$citations,$attachmenturl,%to)=@_;    my ($title,$feedurl,$email,$citations,$attachmenturl,%to)=@_;
   my $status='';    my $status='';
   my $sendsomething=0;    my $sendsomething=0;
     if ($title=~/^Error/) { $title=&mt('Feedback').': '.$title; }
     unless ($title=~/\w/) { $title=&mt('Feedback'); }
   foreach (keys %to) {    foreach (keys %to) {
     if ($_) {      if ($_) {
       my $declutter=&Apache::lonnet::declutter($feedurl);        my $declutter=&Apache::lonnet::declutter($feedurl);
       unless (&Apache::lonmsg::user_normal_msg(split(/\:/,$_),        unless (&Apache::lonmsg::user_normal_msg(split(/\:/,$_),
                'Feedback ['.$declutter.']',$email,$citations,$feedurl,                 $title.' ['.$declutter.']',$email,$citations,$feedurl,
                 $attachmenturl)=~/ok/) {                  $attachmenturl)=~/ok/) {
  $status.='<br />'.&mt('Error sending message to').' '.$_.'<br />';   $status.='<br />'.&mt('Error sending message to').' '.$_.'<br />';
       } else {        } else {
Line 2539  sub adddiscuss { Line 2528  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 2582  sub adddiscuss { Line 2570  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'},
                   \%newcontrib,                    $oldsymb,$oldidx,\%contrib,
                   $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'});
             $status='Editing class discussion'.($anon?' (anonymous)':'');              $status='Editing class discussion'.($anon?' (anonymous)':'');
Line 2621  sub adddiscuss { Line 2605  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 2678  ENDPREVIEW Line 2666  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 = &Apache::lonnet::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 2692  sub modify_attachments { Line 2679  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);
 <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 2757  END Line 2746  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 2991  sub handler { Line 2979  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 (!(&editing_allowed())) {
             my $symb=(split(/\:\:\:/,$env{'form.editdisc'}))[0];
             my ($map,$id,$url)=&Apache::lonnet::decode_symb($symb);
             my $feedurl=&Apache::lonnet::clutter($url);
             &redirect_back($r,$feedurl,&mt('Editing not permitted').'<br />',                     '0','0','','',$env{'form.previous'},'','','',);
             return OK;
         }
     } 
   if ($env{'form.discsymb'}) {    if ($env{'form.discsymb'}) {
       my ($symb,$feedurl) = &get_feedurl_and_clean_symb($env{'form.discsymb'});        my ($symb,$feedurl) = &get_feedurl_and_clean_symb($env{'form.discsymb'});
       my $readkey = $symb.'_read';        my $readkey = $symb.'_read';
Line 3021  sub handler { Line 3017  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 3052  END Line 3042  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 3120  END Line 3111  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 = ('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 3187  ENDREDIR Line 3177  ENDREDIR
       my ($symb,$idx)=split(/\:\:\:/,$entry);        my ($symb,$idx)=split(/\:\:\:/,$entry);
       ($symb,my $feedurl)=&get_feedurl_and_clean_symb($symb);        ($symb,my $feedurl)=&get_feedurl_and_clean_symb($symb);
   
         my $crs='/'.$env{'request.course.id'};
         if ($env{'request.course.sec'}) {
             $crs.='_'.$env{'request.course.sec'};
         }
         $crs=~s/\_/\//g;
         my $seeid=&Apache::lonnet::allowed('rin',$crs);
   
         if ($env{'form.hide'} && !$seeid && !(&editing_allowed())) {
             &redirect_back($r,$feedurl,&mt('Deletion not permitted').'<br />',                 '0','0','','',$env{'form.previous'},'','','',);
             return OK;
         }
   
       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 3194  ENDREDIR Line 3196  ENDREDIR
       my $currenthidden=$contrib{'hidden'};        my $currenthidden=$contrib{'hidden'};
       my $currentstudenthidden=$contrib{'studenthidden'};        my $currentstudenthidden=$contrib{'studenthidden'};
   
       my $crs='/'.$env{'request.course.id'};  
       if ($env{'request.course.sec'}) {  
   $crs.='_'.$env{'request.course.sec'};  
       }  
       $crs=~s/\_/\//g;  
       my $seeid=&Apache::lonnet::allowed('rin',$crs);  
   
       if ($env{'form.hide'}) {        if ($env{'form.hide'}) {
   $currenthidden.='.'.$idx.'.';    $currenthidden.='.'.$idx.'.';
   unless ($seeid) {    unless ($seeid) {
Line 3289  ENDREDIR Line 3284  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 3411  ENDREDIR Line 3409  ENDREDIR
       my ($typestyle,%to) = &decide_receiver($feedurl);        my ($typestyle,%to) = &decide_receiver($feedurl);
   
 # Actually send mail  # Actually send mail
       my ($status,$numsent)=&send_msg($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'} || $env{'form.anondiscuss'}) {
   my $subject = &clear_out_html($env{'form.subject'});    my $subject = &clear_out_html($env{'form.subject'},undef,1);
   my $anonmode=(defined($env{'form.anondiscuss'}));    my $anonmode=(defined($env{'form.anondiscuss'}));
   $typestyle.=&adddiscuss($symb,$message,$anonmode,$attachmenturl,    $typestyle.=&adddiscuss($symb,$message,$anonmode,$attachmenturl,
   $subject);    $subject);
Line 3429  ENDREDIR Line 3429  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 3477  sub get_feedurl_and_clean_symb { Line 3477  sub get_feedurl_and_clean_symb {
     my $feedurl = &get_feedurl($symb);      my $feedurl = &get_feedurl($symb);
     return ($symb,$feedurl);      return ($symb,$feedurl);
 }  }
   
   sub editing_allowed {
       my $can_edit = 0;
       my $cid = $env{'request.course.id'};
       my $role = (split(/\./,$env{'request.role'}))[0];
       my $section = $env{'request.course.sec'};
       my $allow_editing_config = 
    $env{'course.'.$cid.'.allow_discussion_post_editing'};
       if ($allow_editing_config =~ m/^\s*yes\s*$/i) {
           $can_edit = 1;
       } else {
    foreach my $editor (split(/,/,$allow_editing_config)) {
       my ($editor_role,$editor_sec) = split(/:/,$editor);
       if ($editor_role eq $role
    && defined($editor_sec)
    && defined($section)
    && $editor_sec eq $section) {
    $can_edit = 1;
    last;
       }
       if ($editor_role eq $role
    && !defined($editor_sec)) {
    $can_edit = 1;
       }
    }
       }
       return $can_edit;
   }
   
 1;  1;
 __END__  __END__

Removed from v.1.179  
changed lines
  Added in v.1.197


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